|
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_renderer_info 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_renderer_info 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 vao = null; |
|
32 |
|
33 if (!gl) { |
|
34 testFailed("WebGL context does not exist"); |
|
35 } else { |
|
36 testPassed("WebGL context exists"); |
|
37 |
|
38 // Run tests with extension disabled |
|
39 runTestDisabled(); |
|
40 |
|
41 // Query the extension and store globally so shouldBe can access it |
|
42 ext = gl.getExtension("WEBGL_debug_renderer_info"); |
|
43 if (!ext) { |
|
44 testPassed("No WEBGL_debug_renderer_info support -- this is legal"); |
|
45 |
|
46 runSupportedTest(false); |
|
47 } else { |
|
48 testPassed("Successfully enabled WEBGL_debug_renderer_info extension"); |
|
49 |
|
50 runSupportedTest(true); |
|
51 runTestEnabled(); |
|
52 } |
|
53 } |
|
54 |
|
55 function runSupportedTest(extensionEnabled) { |
|
56 var supported = gl.getSupportedExtensions(); |
|
57 if (supported.indexOf("WEBGL_debug_renderer_info") >= 0) { |
|
58 if (extensionEnabled) { |
|
59 testPassed("WEBGL_debug_renderer_info listed as supported and getExtension succeeded"); |
|
60 } else { |
|
61 testFailed("WEBGL_debug_renderer_info listed as supported but getExtension failed"); |
|
62 } |
|
63 } else { |
|
64 if (extensionEnabled) { |
|
65 testFailed("WEBGL_debug_renderer_info not listed as supported but getExtension succeeded"); |
|
66 } else { |
|
67 testPassed("WEBGL_debug_renderer_info not listed as supported and getExtension failed -- this is legal"); |
|
68 } |
|
69 } |
|
70 } |
|
71 |
|
72 function runTestDisabled() { |
|
73 debug("Testing enums with extension disabled"); |
|
74 |
|
75 // Use the constants directly as we don't have the extension |
|
76 |
|
77 var UNMASKED_VENDOR_WEBGL = 0x9245; |
|
78 gl.getParameter(UNMASKED_VENDOR_WEBGL); |
|
79 glErrorShouldBe(gl, gl.INVALID_ENUM, "UNMASKED_VENDOR_WEBGL should not be queryable if extension is disabled"); |
|
80 |
|
81 var UNMASKED_RENDERER_WEBGL = 0x9246; |
|
82 gl.getParameter(UNMASKED_RENDERER_WEBGL); |
|
83 glErrorShouldBe(gl, gl.INVALID_ENUM, "UNMASKED_RENDERER_WEBGL should not be queryable if extension is disabled"); |
|
84 } |
|
85 |
|
86 function runTestEnabled() { |
|
87 debug("Testing enums with extension enabled"); |
|
88 |
|
89 shouldBe("ext.UNMASKED_VENDOR_WEBGL", "0x9245"); |
|
90 gl.getParameter(ext.UNMASKED_VENDOR_WEBGL); |
|
91 glErrorShouldBe(gl, gl.NO_ERROR, "UNMASKED_VENDOR_WEBGL query should succeed if extension is enable"); |
|
92 |
|
93 shouldBe("ext.UNMASKED_RENDERER_WEBGL", "0x9246"); |
|
94 gl.getParameter(ext.UNMASKED_RENDERER_WEBGL); |
|
95 glErrorShouldBe(gl, gl.NO_ERROR, "UNMASKED_RENDERER_WEBGL query should succeed if extension is enable"); |
|
96 } |
|
97 |
|
98 debug(""); |
|
99 successfullyParsed = true; |
|
100 </script> |
|
101 <script>finishTest();</script> |
|
102 |
|
103 </body> |
|
104 </html> |