servo: Merge #17189 - Add pref to force WebGL context creation failure (from bd339:iss17038); r=emilio
authorBenjamin Dahse <ronoueb@gmail.com>
Wed, 07 Jun 2017 02:27:29 -0700
changeset 413273 162d1c8539dccd359502a8abcb2f08cbe98b5bd3
parent 413272 2f14337def2d952661fd523c175c27775f7c000a
child 413274 28b38b97ffbd4ae196f4a04983ca5e48d6f8c0dd
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
servo: Merge #17189 - Add pref to force WebGL context creation failure (from bd339:iss17038); r=emilio <!-- Please describe your changes on the following line: --> Introduces the pref `webgl.testing.context_creation_error`, to force creation of a new WebGLRenderingContext to fail. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #17038 (github issue number if applicable). <!-- Either: --> - [X] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: https://github.com/servo/servo Source-Revision: 3db7f5d556d85ff6af9bb81f693a2c65e6e791fa
servo/components/script/dom/webglrenderingcontext.rs
servo/resources/prefs.json
--- a/servo/components/script/dom/webglrenderingcontext.rs
+++ b/servo/components/script/dom/webglrenderingcontext.rs
@@ -46,16 +46,17 @@ use ipc_channel::ipc::{self, IpcSender};
 use js::conversions::ConversionBehavior;
 use js::jsapi::{JSContext, JSObject, Type, Rooted};
 use js::jsval::{BooleanValue, DoubleValue, Int32Value, JSVal, NullValue, UndefinedValue};
 use js::typedarray::{TypedArray, TypedArrayElement, Float32, Int32};
 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;
 use webrender_traits::{WebGLCommand, WebGLError, WebGLFramebufferBindingRequest, WebGLParameter};
 use webrender_traits::WebGLError::*;
 
 type ImagePixelResult = Result<(Vec<u8>, Size2D<i32>, bool), ()>;
 pub const MAX_UNIFORM_AND_ATTRIBUTE_LEN: usize = 256;
@@ -161,16 +162,20 @@ pub struct WebGLRenderingContext {
 }
 
 impl WebGLRenderingContext {
     fn new_inherited(window: &Window,
                      canvas: &HTMLCanvasElement,
                      size: Size2D<i32>,
                      attrs: GLContextAttributes)
                      -> Result<WebGLRenderingContext, String> {
+        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::<GlobalScope>().constellation_chan();
         constellation_chan.send(ConstellationMsg::CreateWebGLPaintThread(size, attrs, sender))
                           .unwrap();
         let result = receiver.recv().unwrap();
 
         result.map(|(ipc_renderer, context_limits)| {
             WebGLRenderingContext {
--- a/servo/resources/prefs.json
+++ b/servo/resources/prefs.json
@@ -61,10 +61,11 @@
   "layout.viewport.enabled": false,
   "layout.writing-mode.enabled": false,
   "network.mime.sniff": false,
   "session-history.max-length": 20,
   "shell.builtin-key-shortcuts.enabled": true,
   "shell.homepage": "https://servo.org",
   "shell.keep_screen_on.enabled": false,
   "shell.native-orientation": "both",
-  "shell.native-titlebar.enabled": true
+  "shell.native-titlebar.enabled": true,
+  "webgl.testing.context_creation_error": false
 }