5 <script src='/tests/SimpleTest/SimpleTest.js'
></script>
6 <link rel='stylesheet' href='/tests/SimpleTest/test.css'
>
12 function RunWithPrefs(prefPairList
, func
) {
13 var prefEnv
= {'set': prefPairList
};
15 SpecialPowers
.pushPrefEnv(prefEnv
, func
);
17 console
.log('Warning: Failed to set prefs: ' + JSON
.stringify(prefPairList
));
22 ////////////////////////////////////////
24 function Check(expr
, text
) {
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.
39 if (!Check(!gl
, 'When disabled, context creation should fail.'))
42 if (!Check(generatedEvent
, 'Context creation failure should generate an event.'))
45 var reason
= generatedEvent
.statusMessage
;
46 if (!Check(reason
!== undefined, 'generatedEvent.statusMessage should be defined.'))
49 ok(reason
.length
, 'statusMessage should be non-empty.');
55 ////////////////////////////////////////
57 SimpleTest
.waitForExplicitFinish();
60 ['webgl.disabled', true],
62 RunWithPrefs(prefPairList
, TestWhenDisabled
);