content/canvas/test/webgl-conformance/conformance/extensions/webgl-debug-shaders.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-shaders.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,97 @@
     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_shaders 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_shaders 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 shader = 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 +    // Query the extension and store globally so shouldBe can access it
    1.42 +    ext = gl.getExtension("WEBGL_debug_shaders");
    1.43 +    if (!ext) {
    1.44 +        testPassed("No WEBGL_debug_shaders support -- this is legal");
    1.45 +
    1.46 +        runSupportedTest(false);
    1.47 +    } else {
    1.48 +        testPassed("Successfully enabled WEBGL_debug_shaders extension");
    1.49 +
    1.50 +        runSupportedTest(true);
    1.51 +        runTestEnabled();
    1.52 +    }
    1.53 +}
    1.54 +
    1.55 +function runSupportedTest(extensionEnabled) {
    1.56 +    var supported = gl.getSupportedExtensions();
    1.57 +    if (supported.indexOf("WEBGL_debug_shaders") >= 0) {
    1.58 +        if (extensionEnabled) {
    1.59 +            testPassed("WEBGL_debug_shaders listed as supported and getExtension succeeded");
    1.60 +        } else {
    1.61 +            testFailed("WEBGL_debug_shaders listed as supported but getExtension failed");
    1.62 +        }
    1.63 +    } else {
    1.64 +        if (extensionEnabled) {
    1.65 +            testFailed("WEBGL_debug_shaders not listed as supported but getExtension succeeded");
    1.66 +        } else {
    1.67 +            testPassed("WEBGL_debug_shaders not listed as supported and getExtension failed -- this is legal");
    1.68 +        }
    1.69 +    }
    1.70 +}
    1.71 +
    1.72 +function runTestEnabled() {
    1.73 +    debug("Testing function with extension enabled");
    1.74 +
    1.75 +    var source = "void main() { gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); }";
    1.76 +
    1.77 +    shader = gl.createShader(gl.FRAGMENT_SHADER);
    1.78 +
    1.79 +    // if no source has been defined or compileShader() has not been called,
    1.80 +    // getTranslatedShaderSource() should return an empty string.
    1.81 +    shouldBe("ext.getTranslatedShaderSource(shader)", '""');
    1.82 +    gl.shaderSource(shader, source);
    1.83 +    shouldBe("ext.getTranslatedShaderSource(shader)", '""');
    1.84 +    gl.compileShader(shader);
    1.85 +    shouldBeTrue("gl.getShaderParameter(shader, gl.COMPILE_STATUS)");
    1.86 +    var translatedSource = ext.getTranslatedShaderSource(shader);
    1.87 +    glErrorShouldBe(gl, gl.NO_ERROR, "No gl error should occur");
    1.88 +    if (translatedSource.length > 0)
    1.89 +        testPassed("Successfully called getTranslatedShaderSource()");
    1.90 +    else
    1.91 +        testFailed("Calling getTranslatedShaderSource() failed");
    1.92 +}
    1.93 +
    1.94 +debug("");
    1.95 +successfullyParsed = true;
    1.96 +</script>
    1.97 +<script>finishTest();</script>
    1.98 +
    1.99 +</body>
   1.100 +</html>

mercurial