test_webgl_request_context.html (1060B)
1 <!DOCTYPE HTML> 2 <title>WebGL test: 'webgl' and 'experimental-webgl' context requests succeed, 3 'moz-webgl' context requests fail.</title> 4 <script src="/tests/SimpleTest/SimpleTest.js"></script> 5 <link rel="stylesheet" href="/tests/SimpleTest/test.css"> 6 <script src="driver-info.js"></script> 7 <body> 8 <canvas id="c1"></canvas> 9 <canvas id="c2"></canvas> 10 <script> 11 12 var testFunc = ok; 13 14 function testContextRetrieval(canvasId, creationId, shouldSucceed) { 15 var canvas = document.getElementById(canvasId); 16 ok(canvas, 'Invalid `canvasId`: ' + canvasId); 17 18 var createdGL = canvas.getContext(creationId); 19 if (shouldSucceed) { 20 testFunc(createdGL, 'Request for \'' + creationId + '\' should succeed.'); 21 } else { 22 ok(!createdGL, 'Request for \'' + creationId + '\' should fail.'); 23 } 24 } 25 26 SimpleTest.waitForExplicitFinish(); 27 SpecialPowers.pushPrefEnv({'set': [ 28 ['webgl.force-enabled', true] 29 ]}, function() { 30 testContextRetrieval('c1', 'experimental-webgl', true); 31 testContextRetrieval('c2', 'moz-webgl', false); 32 SimpleTest.finish(); 33 }); 34 35 </script>