r?jrmuizel - Add a test. draft
authorJeff Gilbert <jdashg@gmail.com>
Wed, 11 May 2016 12:23:18 -0700
changeset 365993 1fb5a5295c0295d486d51d9aa419608c14ef7ab5
parent 365992 81bc18932d05fbb7e46ef71de1e6058e03bfed25
child 365994 8c83d026f0d86966e40d66903afff2a31f7260d1
push id17876
push userjgilbert@mozilla.com
push dateWed, 11 May 2016 19:35:30 +0000
bugs100644
milestone49.0a1
r?jrmuizel - Add a test. From afb6a9ee97c0a96d0586040fe1ae01b30a01344f Mon Sep 17 00:00:00 2001 --- dom/canvas/moz.build | 4 +- dom/canvas/test/webgl-mochitest/mochitest.ini | 1 + .../test_webglcontextcreationerror.html | 66 ++++++++++++++++++++++ 3 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 dom/canvas/test/webgl-mochitest/test_webglcontextcreationerror.html MozReview-Commit-ID: IlMdsEnqOWN
dom/canvas/moz.build
dom/canvas/test/webgl-mochitest/mochitest.ini
dom/canvas/test/webgl-mochitest/test_webglcontextcreationerror.html
--- a/dom/canvas/moz.build
+++ b/dom/canvas/moz.build
@@ -1,18 +1,18 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 TEST_DIRS += ['compiledtest']
 
-# Number changes to this file to avoid bug 1081323 (clobber after changing a manifest):
-# 12
+# Change the following line to avoid bug 1081323 (clobber after changing a manifest):
+# Add test for webglcontextcreationerror.
 
 MOCHITEST_MANIFESTS += [
     'test/crossorigin/mochitest.ini',
     'test/mochitest.ini',
     'test/webgl-conf/generated-mochitest.ini',
     'test/webgl-mochitest/mochitest.ini',
 ]
 
--- a/dom/canvas/test/webgl-mochitest/mochitest.ini
+++ b/dom/canvas/test/webgl-mochitest/mochitest.ini
@@ -89,8 +89,9 @@ skip-if = toolkit == 'android' #bug 8654
 skip-if = toolkit == 'android' #bug 865443- seperate suite - the non_conf* tests pass except for one on armv6 tests
 [test_webgl2_not_exposed.html]
 skip-if = toolkit == 'android' #bug 865443- seperate suite - the non_conf* tests pass except for one on armv6 tests
 [test_webgl2_invalidate_framebuffer.html]
 skip-if = toolkit == 'android' #bug 865443- seperate suite - the non_conf* tests pass except for one on armv6 tests
 [test_webgl2_alpha_luminance.html]
 skip-if = toolkit == 'android' #bug 865443- seperate suite - the non_conf* tests pass except for one on armv6 tests
 [test_fuzzing_bugs.html]
+[test_webglcontextcreationerror.html]
new file mode 100644
--- /dev/null
+++ b/dom/canvas/test/webgl-mochitest/test_webglcontextcreationerror.html
@@ -0,0 +1,66 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+  <meta charset='UTF-8'>
+  <script src='/tests/SimpleTest/SimpleTest.js'></script>
+  <link rel='stylesheet' href='/tests/SimpleTest/test.css'>
+</head>
+<body>
+<script>
+'use strict';
+
+function RunWithPrefs(prefPairList, func) {
+  var prefEnv = {'set': prefPairList};
+  try {
+    SpecialPowers.pushPrefEnv(prefEnv, func);
+  } catch (e) {
+    console.log('Warning: Failed to set prefs: ' + JSON.stringify(prefPairList));
+    func();
+  }
+}
+
+////////////////////////////////////////
+
+function Check(expr, text) {
+  ok(expr, text);
+  return expr;
+}
+
+function TestWhenDisabled() {
+  var c = document.createElement('canvas');
+
+  var generatedEvent = null;
+  var f = function(event) { generatedEvent = event; };
+  c.addEventListener('webglcontextcreationerror', f);
+
+  var gl = c.getContext('webgl'); // Should fail.
+
+  do {
+    if (!Check(!gl, 'When disabled, context creation should fail.'))
+      break;
+
+    if (!Check(generatedEvent, 'Context creation failure should generate an event.'))
+      break;
+
+    var reason = generatedEvent.statusMessage;
+    if (!Check(reason !== undefined, 'generatedEvent.statusMessage should be defined.'))
+      break;
+
+    ok(reason.length, 'statusMessage should be non-empty.');
+  } while (false);
+
+  SimpleTest.finish();
+}
+
+////////////////////////////////////////
+
+SimpleTest.waitForExplicitFinish();
+
+var prefPairList = [
+  ['webgl.disabled', true],
+];
+RunWithPrefs(prefPairList, TestWhenDisabled);
+
+</script>
+</body>
+</html>