2 Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 Use of this source code is governed by a BSD-style license that can be
4 found in the LICENSE file.
10 <title>WebGL WebGL_debug_shaders Conformance Tests</title>
11 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
12 <script src="../../resources/desktop-gl-constants.js" type="text/javascript"></script>
13 <script src="../../resources/js-test-pre.js"></script>
14 <script src="../resources/webgl-test.js"></script>
15 <script src="../resources/webgl-test-utils.js"></script>
18 <div id="description"></div>
19 <canvas id="canvas" style="width: 1px; height: 1px;"> </canvas>
20 <div id="console"></div>
21 <!-- Shaders for testing standard derivatives -->
24 description("This test verifies the functionality of the WEBGL_debug_shaders extension, if it is available.");
28 var wtu = WebGLTestUtils;
29 var gl = wtu.create3DContext("canvas");
34 testFailed("WebGL context does not exist");
36 testPassed("WebGL context exists");
38 // Query the extension and store globally so shouldBe can access it
39 ext = gl.getExtension("WEBGL_debug_shaders");
41 testPassed("No WEBGL_debug_shaders support -- this is legal");
43 runSupportedTest(false);
45 testPassed("Successfully enabled WEBGL_debug_shaders extension");
47 runSupportedTest(true);
52 function runSupportedTest(extensionEnabled) {
53 var supported = gl.getSupportedExtensions();
54 if (supported.indexOf("WEBGL_debug_shaders") >= 0) {
55 if (extensionEnabled) {
56 testPassed("WEBGL_debug_shaders listed as supported and getExtension succeeded");
58 testFailed("WEBGL_debug_shaders listed as supported but getExtension failed");
61 if (extensionEnabled) {
62 testFailed("WEBGL_debug_shaders not listed as supported but getExtension succeeded");
64 testPassed("WEBGL_debug_shaders not listed as supported and getExtension failed -- this is legal");
69 function runTestEnabled() {
70 debug("Testing function with extension enabled");
72 var source = "void main() { gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); }";
74 shader = gl.createShader(gl.FRAGMENT_SHADER);
76 // if no source has been defined or compileShader() has not been called,
77 // getTranslatedShaderSource() should return an empty string.
78 shouldBe("ext.getTranslatedShaderSource(shader)", '""');
79 gl.shaderSource(shader, source);
80 shouldBe("ext.getTranslatedShaderSource(shader)", '""');
81 gl.compileShader(shader);
82 shouldBeTrue("gl.getShaderParameter(shader, gl.COMPILE_STATUS)");
83 var translatedSource = ext.getTranslatedShaderSource(shader);
84 glErrorShouldBe(gl, gl.NO_ERROR, "No gl error should occur");
85 if (translatedSource.length > 0)
86 testPassed("Successfully called getTranslatedShaderSource()");
88 testFailed("Calling getTranslatedShaderSource() failed");
92 successfullyParsed = true;
94 <script src="../../resources/js-test-post.js"></script>