tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

webgl-debug-renderer-info.html (3384B)


      1 <!--
      2 Copyright (c) 2019 The Khronos Group Inc.
      3 Use of this source code is governed by an MIT-style license that can be
      4 found in the LICENSE.txt file.
      5 -->
      6 
      7 <!DOCTYPE html>
      8 <html>
      9 <head>
     10 <meta charset="utf-8">
     11 <title>WebGL WebGL_debug_renderer_info Conformance Tests</title>
     12 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
     13 <script src="../../js/js-test-pre.js"></script>
     14 <script src="../../js/webgl-test-utils.js"></script>
     15 </head>
     16 <body>
     17 <div id="description"></div>
     18 <canvas id="canvas" style="width: 1px; height: 1px;"> </canvas>
     19 <div id="console"></div>
     20 <!-- Shaders for testing standard derivatives -->
     21 
     22 <script>
     23 "use strict";
     24 description("This test verifies the functionality of the WEBGL_debug_renderer_info extension, if it is available.");
     25 
     26 debug("");
     27 
     28 var wtu = WebGLTestUtils;
     29 var gl = wtu.create3DContext("canvas");
     30 var ext = null;
     31 var vao = null;
     32 
     33 if (!gl) {
     34    testFailed("WebGL context does not exist");
     35 } else {
     36    testPassed("WebGL context exists");
     37 
     38    // Run tests with extension disabled
     39    runTestDisabled();
     40 
     41    // Query the extension and store globally so shouldBe can access it
     42    ext = gl.getExtension("WEBGL_debug_renderer_info");
     43    if (!ext) {
     44        testPassed("No WEBGL_debug_renderer_info support -- this is legal");
     45 
     46        runSupportedTest(false);
     47    } else {
     48        testPassed("Successfully enabled WEBGL_debug_renderer_info extension");
     49 
     50        runSupportedTest(true);
     51        runTestEnabled();
     52    }
     53 }
     54 
     55 function runSupportedTest(extensionEnabled) {
     56    var supported = gl.getSupportedExtensions();
     57    if (supported.indexOf("WEBGL_debug_renderer_info") >= 0) {
     58        if (extensionEnabled) {
     59            testPassed("WEBGL_debug_renderer_info listed as supported and getExtension succeeded");
     60        } else {
     61            testFailed("WEBGL_debug_renderer_info listed as supported but getExtension failed");
     62        }
     63    } else {
     64        if (extensionEnabled) {
     65            testFailed("WEBGL_debug_renderer_info not listed as supported but getExtension succeeded");
     66        } else {
     67            testPassed("WEBGL_debug_renderer_info not listed as supported and getExtension failed -- this is legal");
     68        }
     69    }
     70 }
     71 
     72 function runTestDisabled() {
     73    debug("Testing enums with extension disabled");
     74 
     75    // Use the constants directly as we don't have the extension
     76 
     77    var UNMASKED_VENDOR_WEBGL = 0x9245;
     78    gl.getParameter(UNMASKED_VENDOR_WEBGL);
     79    wtu.glErrorShouldBe(gl, gl.INVALID_ENUM, "UNMASKED_VENDOR_WEBGL should not be queryable if extension is disabled");
     80 
     81    var UNMASKED_RENDERER_WEBGL = 0x9246;
     82    gl.getParameter(UNMASKED_RENDERER_WEBGL);
     83    wtu.glErrorShouldBe(gl, gl.INVALID_ENUM, "UNMASKED_RENDERER_WEBGL should not be queryable if extension is disabled");
     84 }
     85 
     86 function runTestEnabled() {
     87    debug("Testing enums with extension enabled");
     88 
     89    shouldBe("ext.UNMASKED_VENDOR_WEBGL", "0x9245");
     90    gl.getParameter(ext.UNMASKED_VENDOR_WEBGL);
     91    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "UNMASKED_VENDOR_WEBGL query should succeed if extension is enable");
     92 
     93    shouldBe("ext.UNMASKED_RENDERER_WEBGL", "0x9246");
     94    gl.getParameter(ext.UNMASKED_RENDERER_WEBGL);
     95    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "UNMASKED_RENDERER_WEBGL query should succeed if extension is enable");
     96 }
     97 
     98 debug("");
     99 var successfullyParsed = true;
    100 </script>
    101 <script src="../../js/js-test-post.js"></script>
    102 
    103 </body>
    104 </html>