Bug 1915045 Ensure decode tasks are scheduled on BufferingState::Enter() r=media...
[gecko.git] / dom / canvas / test / webgl-mochitest / test_webglcontextcreationerror.html
blob65d9b4eb2fa017fc4de17170ac68fca5f68b6e9c
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <meta charset='UTF-8'>
5 <script src='/tests/SimpleTest/SimpleTest.js'></script>
6 <link rel='stylesheet' href='/tests/SimpleTest/test.css'>
7 </head>
8 <body>
9 <script>
10 'use strict';
12 function RunWithPrefs(prefPairList, func) {
13 var prefEnv = {'set': prefPairList};
14 try {
15 SpecialPowers.pushPrefEnv(prefEnv, func);
16 } catch (e) {
17 console.log('Warning: Failed to set prefs: ' + JSON.stringify(prefPairList));
18 func();
22 ////////////////////////////////////////
24 function Check(expr, text) {
25 ok(expr, text);
26 return expr;
29 function TestWhenDisabled() {
30 var c = document.createElement('canvas');
32 var generatedEvent = null;
33 var f = function(event) { generatedEvent = event; };
34 c.addEventListener('webglcontextcreationerror', f);
36 var gl = c.getContext('webgl'); // Should fail.
38 do {
39 if (!Check(!gl, 'When disabled, context creation should fail.'))
40 break;
42 if (!Check(generatedEvent, 'Context creation failure should generate an event.'))
43 break;
45 var reason = generatedEvent.statusMessage;
46 if (!Check(reason !== undefined, 'generatedEvent.statusMessage should be defined.'))
47 break;
49 ok(reason.length, 'statusMessage should be non-empty.');
50 } while (false);
52 SimpleTest.finish();
55 ////////////////////////////////////////
57 SimpleTest.waitForExplicitFinish();
59 var prefPairList = [
60 ['webgl.disabled', true],
62 RunWithPrefs(prefPairList, TestWhenDisabled);
64 </script>
65 </body>
66 </html>