content/canvas/test/chrome/nonchrome_webgl_debug_renderer_info.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <script>
michael@0 4
michael@0 5 // This file has the portion of the test_webgl_renderer_info chrome mochitest
michael@0 6 // that has to run as non-chrome to check that this WebGL extension is not exposed to content
michael@0 7
michael@0 8 // we can't call the chrome Mochitest ok() function ourselves from non-chrome code.
michael@0 9 // So we remote it to the chrome test.
michael@0 10
michael@0 11 function ok(res, msg) {
michael@0 12 // Note we post to ourselves as posting to the chrome code doesn't seem to work here.
michael@0 13 // This works by having the chrome code put an event handler on our own window.
michael@0 14 window.postMessage({ subTestFinished: true, result: res, message: msg }, "*");
michael@0 15 }
michael@0 16
michael@0 17 function messageListener(e) {
michael@0 18 // This is how the chrome test tells us to start running -- we have to wait for this
michael@0 19 // message to avoid running before it's set up its event handler.
michael@0 20 if (e.data == "run") {
michael@0 21 run();
michael@0 22 }
michael@0 23 }
michael@0 24
michael@0 25 window.addEventListener("message", messageListener, true);
michael@0 26
michael@0 27 function run() {
michael@0 28 const UNMASKED_VENDOR_WEBGL = 0x9245;
michael@0 29 const UNMASKED_RENDERER_WEBGL = 0x9246;
michael@0 30
michael@0 31 var canvas = document.createElement("canvas");
michael@0 32 var gl = canvas.getContext("experimental-webgl");
michael@0 33
michael@0 34 ok(!gl.getError(), "getError on newly created WebGL context should return NO_ERROR");
michael@0 35
michael@0 36 ok(!gl.getParameter(UNMASKED_VENDOR_WEBGL) && gl.getError() == gl.INVALID_ENUM,
michael@0 37 "Should not be able to query UNMASKED_VENDOR_WEBGL without having enabled the WEBGL_debug_renderer_info extension");
michael@0 38 ok(!gl.getParameter(UNMASKED_RENDERER_WEBGL) && gl.getError() == gl.INVALID_ENUM,
michael@0 39 "Should not be able to query UNMASKED_RENDERER_WEBGL without having enabled the WEBGL_debug_renderer_info extension");
michael@0 40
michael@0 41 var exts = gl.getSupportedExtensions();
michael@0 42 ok(exts.indexOf("WEBGL_debug_renderer_info") == -1,
michael@0 43 "WEBGL_debug_renderer_info should not be listed by getSupportedExtensions in non-chrome contexts");
michael@0 44 var debugRendererInfoExtension = gl.getExtension("WEBGL_debug_renderer_info");
michael@0 45 ok(!debugRendererInfoExtension,
michael@0 46 "WEBGL_debug_renderer_info should not be available through getExtension in non-chrome contexts");
michael@0 47
michael@0 48 ok(!gl.getParameter(UNMASKED_VENDOR_WEBGL) && gl.getError() == gl.INVALID_ENUM,
michael@0 49 "Should not be able to query UNMASKED_VENDOR_WEBGL if enabling WEBGL_debug_renderer_info failed");
michael@0 50 ok(!gl.getParameter(UNMASKED_RENDERER_WEBGL) && gl.getError() == gl.INVALID_ENUM,
michael@0 51 "Should not be able to query UNMASKED_RENDERER_WEBGL if enabling WEBGL_debug_renderer_info failed");
michael@0 52
michael@0 53 window.postMessage({allTestsFinished: true}, "*");
michael@0 54 }
michael@0 55
michael@0 56 </script>
michael@0 57 </html>

mercurial