Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / webgl / src / conformance-suites / 1.0.1 / conformance / extensions / webgl-debug-shaders.html
1 <!--
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.
5  -->
6 <!DOCTYPE html>
7 <html>
8 <head>
9 <meta charset="utf-8">
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>
16 </head>
17 <body>
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 -->
22
23 <script>
24 description("This test verifies the functionality of the WEBGL_debug_shaders 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 shader = null;
32
33 if (!gl) {
34     testFailed("WebGL context does not exist");
35 } else {
36     testPassed("WebGL context exists");
37
38     // Query the extension and store globally so shouldBe can access it
39     ext = gl.getExtension("WEBGL_debug_shaders");
40     if (!ext) {
41         testPassed("No WEBGL_debug_shaders support -- this is legal");
42
43         runSupportedTest(false);
44     } else {
45         testPassed("Successfully enabled WEBGL_debug_shaders extension");
46
47         runSupportedTest(true);
48         runTestEnabled();
49     }
50 }
51
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");
57         } else {
58             testFailed("WEBGL_debug_shaders listed as supported but getExtension failed");
59         }
60     } else {
61         if (extensionEnabled) {
62             testFailed("WEBGL_debug_shaders not listed as supported but getExtension succeeded");
63         } else {
64             testPassed("WEBGL_debug_shaders not listed as supported and getExtension failed -- this is legal");
65         }
66     }
67 }
68
69 function runTestEnabled() {
70     debug("Testing function with extension enabled");
71
72     var source = "void main() { gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); }";
73
74     shader = gl.createShader(gl.FRAGMENT_SHADER);
75
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()");
87     else
88         testFailed("Calling getTranslatedShaderSource() failed");
89 }
90
91 debug("");
92 successfullyParsed = true;
93 </script>
94 <script src="../../resources/js-test-post.js"></script>
95
96 </body>
97 </html>