content/canvas/test/webgl-conformance/conformance/extensions/webgl-debug-renderer-info.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/canvas/test/webgl-conformance/conformance/extensions/webgl-debug-renderer-info.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,104 @@
     1.4 +<!--
     1.5 +Copyright (c) 2011 The Chromium Authors. All rights reserved.
     1.6 +Use of this source code is governed by a BSD-style license that can be
     1.7 +found in the LICENSE file.
     1.8 + -->
     1.9 +<!DOCTYPE html>
    1.10 +<html>
    1.11 +<head>
    1.12 +<meta charset="utf-8">
    1.13 +<title>WebGL WebGL_debug_renderer_info Conformance Tests</title>
    1.14 +<link rel="stylesheet" href="../../resources/js-test-style.css"/>
    1.15 +<script src="../../resources/desktop-gl-constants.js" type="text/javascript"></script>
    1.16 +<script src="../../resources/js-test-pre.js"></script>
    1.17 +<script src="../resources/webgl-test.js"></script>
    1.18 +<script src="../resources/webgl-test-utils.js"></script>
    1.19 +</head>
    1.20 +<body>
    1.21 +<div id="description"></div>
    1.22 +<canvas id="canvas" style="width: 1px; height: 1px;"> </canvas>
    1.23 +<div id="console"></div>
    1.24 +<!-- Shaders for testing standard derivatives -->
    1.25 +
    1.26 +<script>
    1.27 +description("This test verifies the functionality of the WEBGL_debug_renderer_info extension, if it is available.");
    1.28 +
    1.29 +debug("");
    1.30 +
    1.31 +var wtu = WebGLTestUtils;
    1.32 +var gl = wtu.create3DContext("canvas");
    1.33 +var ext = null;
    1.34 +var vao = null;
    1.35 +
    1.36 +if (!gl) {
    1.37 +    testFailed("WebGL context does not exist");
    1.38 +} else {
    1.39 +    testPassed("WebGL context exists");
    1.40 +
    1.41 +    // Run tests with extension disabled
    1.42 +    runTestDisabled();
    1.43 +
    1.44 +    // Query the extension and store globally so shouldBe can access it
    1.45 +    ext = gl.getExtension("WEBGL_debug_renderer_info");
    1.46 +    if (!ext) {
    1.47 +        testPassed("No WEBGL_debug_renderer_info support -- this is legal");
    1.48 +
    1.49 +        runSupportedTest(false);
    1.50 +    } else {
    1.51 +        testPassed("Successfully enabled WEBGL_debug_renderer_info extension");
    1.52 +
    1.53 +        runSupportedTest(true);
    1.54 +        runTestEnabled();
    1.55 +    }
    1.56 +}
    1.57 +
    1.58 +function runSupportedTest(extensionEnabled) {
    1.59 +    var supported = gl.getSupportedExtensions();
    1.60 +    if (supported.indexOf("WEBGL_debug_renderer_info") >= 0) {
    1.61 +        if (extensionEnabled) {
    1.62 +            testPassed("WEBGL_debug_renderer_info listed as supported and getExtension succeeded");
    1.63 +        } else {
    1.64 +            testFailed("WEBGL_debug_renderer_info listed as supported but getExtension failed");
    1.65 +        }
    1.66 +    } else {
    1.67 +        if (extensionEnabled) {
    1.68 +            testFailed("WEBGL_debug_renderer_info not listed as supported but getExtension succeeded");
    1.69 +        } else {
    1.70 +            testPassed("WEBGL_debug_renderer_info not listed as supported and getExtension failed -- this is legal");
    1.71 +        }
    1.72 +    }
    1.73 +}
    1.74 +
    1.75 +function runTestDisabled() {
    1.76 +    debug("Testing enums with extension disabled");
    1.77 +
    1.78 +    // Use the constants directly as we don't have the extension
    1.79 +
    1.80 +    var UNMASKED_VENDOR_WEBGL = 0x9245;
    1.81 +    gl.getParameter(UNMASKED_VENDOR_WEBGL);
    1.82 +    glErrorShouldBe(gl, gl.INVALID_ENUM, "UNMASKED_VENDOR_WEBGL should not be queryable if extension is disabled");
    1.83 +
    1.84 +    var UNMASKED_RENDERER_WEBGL = 0x9246;
    1.85 +    gl.getParameter(UNMASKED_RENDERER_WEBGL);
    1.86 +    glErrorShouldBe(gl, gl.INVALID_ENUM, "UNMASKED_RENDERER_WEBGL should not be queryable if extension is disabled");
    1.87 +}
    1.88 +
    1.89 +function runTestEnabled() {
    1.90 +    debug("Testing enums with extension enabled");
    1.91 +
    1.92 +    shouldBe("ext.UNMASKED_VENDOR_WEBGL", "0x9245");
    1.93 +    gl.getParameter(ext.UNMASKED_VENDOR_WEBGL);
    1.94 +    glErrorShouldBe(gl, gl.NO_ERROR, "UNMASKED_VENDOR_WEBGL query should succeed if extension is enable");
    1.95 +
    1.96 +    shouldBe("ext.UNMASKED_RENDERER_WEBGL", "0x9246");
    1.97 +    gl.getParameter(ext.UNMASKED_RENDERER_WEBGL);
    1.98 +    glErrorShouldBe(gl, gl.NO_ERROR, "UNMASKED_RENDERER_WEBGL query should succeed if extension is enable");
    1.99 +}
   1.100 +
   1.101 +debug("");
   1.102 +successfullyParsed = true;
   1.103 +</script>
   1.104 +<script>finishTest();</script>
   1.105 +
   1.106 +</body>
   1.107 +</html>

mercurial