content/canvas/test/webgl-conformance/conformance/extensions/webgl-debug-shaders.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 <!--
michael@0 2 Copyright (c) 2011 The Chromium Authors. All rights reserved.
michael@0 3 Use of this source code is governed by a BSD-style license that can be
michael@0 4 found in the LICENSE file.
michael@0 5 -->
michael@0 6 <!DOCTYPE html>
michael@0 7 <html>
michael@0 8 <head>
michael@0 9 <meta charset="utf-8">
michael@0 10 <title>WebGL WebGL_debug_shaders Conformance Tests</title>
michael@0 11 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
michael@0 12 <script src="../../resources/desktop-gl-constants.js" type="text/javascript"></script>
michael@0 13 <script src="../../resources/js-test-pre.js"></script>
michael@0 14 <script src="../resources/webgl-test.js"></script>
michael@0 15 <script src="../resources/webgl-test-utils.js"></script>
michael@0 16 </head>
michael@0 17 <body>
michael@0 18 <div id="description"></div>
michael@0 19 <canvas id="canvas" style="width: 1px; height: 1px;"> </canvas>
michael@0 20 <div id="console"></div>
michael@0 21 <!-- Shaders for testing standard derivatives -->
michael@0 22
michael@0 23 <script>
michael@0 24 description("This test verifies the functionality of the WEBGL_debug_shaders extension, if it is available.");
michael@0 25
michael@0 26 debug("");
michael@0 27
michael@0 28 var wtu = WebGLTestUtils;
michael@0 29 var gl = wtu.create3DContext("canvas");
michael@0 30 var ext = null;
michael@0 31 var shader = null;
michael@0 32
michael@0 33 if (!gl) {
michael@0 34 testFailed("WebGL context does not exist");
michael@0 35 } else {
michael@0 36 testPassed("WebGL context exists");
michael@0 37
michael@0 38 // Query the extension and store globally so shouldBe can access it
michael@0 39 ext = gl.getExtension("WEBGL_debug_shaders");
michael@0 40 if (!ext) {
michael@0 41 testPassed("No WEBGL_debug_shaders support -- this is legal");
michael@0 42
michael@0 43 runSupportedTest(false);
michael@0 44 } else {
michael@0 45 testPassed("Successfully enabled WEBGL_debug_shaders extension");
michael@0 46
michael@0 47 runSupportedTest(true);
michael@0 48 runTestEnabled();
michael@0 49 }
michael@0 50 }
michael@0 51
michael@0 52 function runSupportedTest(extensionEnabled) {
michael@0 53 var supported = gl.getSupportedExtensions();
michael@0 54 if (supported.indexOf("WEBGL_debug_shaders") >= 0) {
michael@0 55 if (extensionEnabled) {
michael@0 56 testPassed("WEBGL_debug_shaders listed as supported and getExtension succeeded");
michael@0 57 } else {
michael@0 58 testFailed("WEBGL_debug_shaders listed as supported but getExtension failed");
michael@0 59 }
michael@0 60 } else {
michael@0 61 if (extensionEnabled) {
michael@0 62 testFailed("WEBGL_debug_shaders not listed as supported but getExtension succeeded");
michael@0 63 } else {
michael@0 64 testPassed("WEBGL_debug_shaders not listed as supported and getExtension failed -- this is legal");
michael@0 65 }
michael@0 66 }
michael@0 67 }
michael@0 68
michael@0 69 function runTestEnabled() {
michael@0 70 debug("Testing function with extension enabled");
michael@0 71
michael@0 72 var source = "void main() { gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); }";
michael@0 73
michael@0 74 shader = gl.createShader(gl.FRAGMENT_SHADER);
michael@0 75
michael@0 76 // if no source has been defined or compileShader() has not been called,
michael@0 77 // getTranslatedShaderSource() should return an empty string.
michael@0 78 shouldBe("ext.getTranslatedShaderSource(shader)", '""');
michael@0 79 gl.shaderSource(shader, source);
michael@0 80 shouldBe("ext.getTranslatedShaderSource(shader)", '""');
michael@0 81 gl.compileShader(shader);
michael@0 82 shouldBeTrue("gl.getShaderParameter(shader, gl.COMPILE_STATUS)");
michael@0 83 var translatedSource = ext.getTranslatedShaderSource(shader);
michael@0 84 glErrorShouldBe(gl, gl.NO_ERROR, "No gl error should occur");
michael@0 85 if (translatedSource.length > 0)
michael@0 86 testPassed("Successfully called getTranslatedShaderSource()");
michael@0 87 else
michael@0 88 testFailed("Calling getTranslatedShaderSource() failed");
michael@0 89 }
michael@0 90
michael@0 91 debug("");
michael@0 92 successfullyParsed = true;
michael@0 93 </script>
michael@0 94 <script>finishTest();</script>
michael@0 95
michael@0 96 </body>
michael@0 97 </html>

mercurial