From c034d99880c1e2fe8e955cf673ce7f5e8b1e2a85 Mon Sep 17 00:00:00 2001 From: Benjamin Dahse Date: Tue, 6 Jun 2017 19:18:40 +0200 Subject: Add pref to force WebGL context creation failure The pref `webgl.testing.context_creation_error` will cause creation of a new WebGLRenderingContext to fail, iff set to true. Also update test expectation of `context_creation_error.html` to pass. --- components/script/dom/webglrenderingcontext.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'components/script/dom/webglrenderingcontext.rs') diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index eb1578d1b3a..8267c5bf2d1 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -51,6 +51,7 @@ use net_traits::image::base::PixelFormat; use net_traits::image_cache::ImageResponse; use offscreen_gl_context::{GLContextAttributes, GLLimits}; use script_traits::ScriptMsg as ConstellationMsg; +use servo_config::prefs::PREFS; use std::cell::Cell; use std::collections::HashMap; use webrender_traits; @@ -166,6 +167,10 @@ impl WebGLRenderingContext { size: Size2D, attrs: GLContextAttributes) -> Result { + if let Some(true) = PREFS.get("webgl.testing.context_creation_error").as_boolean() { + return Err("WebGL context creation error forced by pref `webgl.testing.context_creation_error`".into()); + } + let (sender, receiver) = ipc::channel().unwrap(); let constellation_chan = window.upcast::().constellation_chan(); constellation_chan.send(ConstellationMsg::CreateWebGLPaintThread(size, attrs, sender)) -- cgit v1.2.3