1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/canvas/test/chrome/nonchrome_webgl_debug_renderer_info.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,57 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<script> 1.7 + 1.8 +// This file has the portion of the test_webgl_renderer_info chrome mochitest 1.9 +// that has to run as non-chrome to check that this WebGL extension is not exposed to content 1.10 + 1.11 +// we can't call the chrome Mochitest ok() function ourselves from non-chrome code. 1.12 +// So we remote it to the chrome test. 1.13 + 1.14 +function ok(res, msg) { 1.15 + // Note we post to ourselves as posting to the chrome code doesn't seem to work here. 1.16 + // This works by having the chrome code put an event handler on our own window. 1.17 + window.postMessage({ subTestFinished: true, result: res, message: msg }, "*"); 1.18 +} 1.19 + 1.20 +function messageListener(e) { 1.21 + // This is how the chrome test tells us to start running -- we have to wait for this 1.22 + // message to avoid running before it's set up its event handler. 1.23 + if (e.data == "run") { 1.24 + run(); 1.25 + } 1.26 +} 1.27 + 1.28 +window.addEventListener("message", messageListener, true); 1.29 + 1.30 +function run() { 1.31 + const UNMASKED_VENDOR_WEBGL = 0x9245; 1.32 + const UNMASKED_RENDERER_WEBGL = 0x9246; 1.33 + 1.34 + var canvas = document.createElement("canvas"); 1.35 + var gl = canvas.getContext("experimental-webgl"); 1.36 + 1.37 + ok(!gl.getError(), "getError on newly created WebGL context should return NO_ERROR"); 1.38 + 1.39 + ok(!gl.getParameter(UNMASKED_VENDOR_WEBGL) && gl.getError() == gl.INVALID_ENUM, 1.40 + "Should not be able to query UNMASKED_VENDOR_WEBGL without having enabled the WEBGL_debug_renderer_info extension"); 1.41 + ok(!gl.getParameter(UNMASKED_RENDERER_WEBGL) && gl.getError() == gl.INVALID_ENUM, 1.42 + "Should not be able to query UNMASKED_RENDERER_WEBGL without having enabled the WEBGL_debug_renderer_info extension"); 1.43 + 1.44 + var exts = gl.getSupportedExtensions(); 1.45 + ok(exts.indexOf("WEBGL_debug_renderer_info") == -1, 1.46 + "WEBGL_debug_renderer_info should not be listed by getSupportedExtensions in non-chrome contexts"); 1.47 + var debugRendererInfoExtension = gl.getExtension("WEBGL_debug_renderer_info"); 1.48 + ok(!debugRendererInfoExtension, 1.49 + "WEBGL_debug_renderer_info should not be available through getExtension in non-chrome contexts"); 1.50 + 1.51 + ok(!gl.getParameter(UNMASKED_VENDOR_WEBGL) && gl.getError() == gl.INVALID_ENUM, 1.52 + "Should not be able to query UNMASKED_VENDOR_WEBGL if enabling WEBGL_debug_renderer_info failed"); 1.53 + ok(!gl.getParameter(UNMASKED_RENDERER_WEBGL) && gl.getError() == gl.INVALID_ENUM, 1.54 + "Should not be able to query UNMASKED_RENDERER_WEBGL if enabling WEBGL_debug_renderer_info failed"); 1.55 + 1.56 + window.postMessage({allTestsFinished: true}, "*"); 1.57 +} 1.58 + 1.59 +</script> 1.60 +</html> 1.61 \ No newline at end of file