content/canvas/test/chrome/nonchrome_webgl_debug_renderer_info.html

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

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

mercurial