Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: conformance/misc/boolean-argument-conversion.html

Issue 41503006: Add ToT WebGL conformance tests : part 8 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/webgl/sdk/tests/
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « conformance/misc/bad-arguments-test.html ('k') | conformance/misc/delayed-drawing.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
## -0,0 +1 ##
+LF
\ No newline at end of property
OLDNEW
(Empty)
1 <!--
2
3 /*
4 ** Copyright (c) 2012 The Khronos Group Inc.
5 **
6 ** Permission is hereby granted, free of charge, to any person obtaining a
7 ** copy of this software and/or associated documentation files (the
8 ** "Materials"), to deal in the Materials without restriction, including
9 ** without limitation the rights to use, copy, modify, merge, publish,
10 ** distribute, sublicense, and/or sell copies of the Materials, and to
11 ** permit persons to whom the Materials are furnished to do so, subject to
12 ** the following conditions:
13 **
14 ** The above copyright notice and this permission notice shall be included
15 ** in all copies or substantial portions of the Materials.
16 **
17 ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
24 */
25
26 -->
27
28 <!DOCTYPE html>
29 <html>
30 <head>
31 <meta charset="utf-8">
32 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
33 <script src="../../resources/js-test-pre.js"></script>
34 <script src="../resources/webgl-test.js"></script>
35 <script src="../resources/webgl-test-utils.js"></script>
36 <script src="../../resources/test-eval.js"></script>
37 </head>
38 <body>
39 <div id="description"></div>
40 <div id="console"></div>
41
42 <script>
43 "use strict";
44 var wtu = WebGLTestUtils;
45 description("Test that conversion of boolean arguments of WebGL functions follow s EcmaScript 9.2. ToBoolean");
46 debug("");
47 debug("When an object is converted to a boolean, it should always evaluate as tr ue. Any valueOf() method should not even get called. See Mozilla bug 727590 wher e Gecko incorrectly converted such an argument to a Number instead of a Boolean, giving the wrong behavior. See 9.2 and 9.3 in the EcmaScript specification.");
48 debug("");
49 var gl = wtu.create3DContext();
50 var program = wtu.loadStandardProgram(gl);
51 var shader = wtu.loadStandardVertexShader(gl);
52 var shouldGenerateGLError = wtu.shouldGenerateGLError;
53
54 assertMsg(program != null, "Program Compiled");
55 assertMsg(shader != null, "Shader Compiled");
56
57 var uloc = gl.getUniformLocation(program, "u_modelViewProjMatrix");
58 var aloc = gl.getAttribLocation(program, "a_vertex");
59
60 gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());
61
62 glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from initialization.");
63 assertMsg(uloc, "Uniform not found");
64 assertMsg(aloc >= 0, "Attribute not found");
65
66 var boolArg = { valueOf: function() { throw "Converting an Object to a Boolean s hould just give 'true' without further evaluation"; } }
67
68 function shouldNotThrowWithBoolArgs(code) {
69 try {
70 TestEval(code);
71 } catch(e) {
72 testFailed(code + " threw exception: " + e);
73 return;
74 }
75 testPassed(code + " converted its boolean arguments correctly");
76 }
77
78 shouldNotThrowWithBoolArgs(
79 "gl.colorMask(boolArg, boolArg, boolArg, boolArg)"
80 );
81
82 shouldNotThrowWithBoolArgs(
83 "gl.depthMask(boolArg)"
84 );
85
86 shouldNotThrowWithBoolArgs(
87 "gl.sampleCoverage(1, boolArg)"
88 );
89
90 function zeroArray(length) {
91 var a = new Array(length);
92 for (var i = 0; i < length; i++)
93 a[i] = 0;
94 return a;
95 }
96
97 function zeroFloat32Array(length) {
98 var a = new Float32Array(length);
99 for (var i = 0; i < length; i++)
100 a[i] = 0;
101 return a;
102 }
103
104 shouldNotThrowWithBoolArgs(
105 "gl.uniformMatrix2fv(uloc, boolArg, zeroFloat32Array(4))"
106 );
107
108 shouldNotThrowWithBoolArgs(
109 "gl.uniformMatrix2fv(uloc, boolArg, zeroArray(4))"
110 );
111
112 shouldNotThrowWithBoolArgs(
113 "gl.uniformMatrix3fv(uloc, boolArg, zeroFloat32Array(9))"
114 );
115
116 shouldNotThrowWithBoolArgs(
117 "gl.uniformMatrix3fv(uloc, boolArg, zeroArray(9))"
118 );
119
120 shouldNotThrowWithBoolArgs(
121 "gl.uniformMatrix4fv(uloc, boolArg, zeroFloat32Array(16))"
122 );
123
124 shouldNotThrowWithBoolArgs(
125 "gl.uniformMatrix4fv(uloc, boolArg, zeroArray(16))"
126 );
127
128 shouldNotThrowWithBoolArgs(
129 "gl.vertexAttribPointer(aloc, 4, gl.FLOAT, boolArg, 4, 0)"
130 );
131
132 var successfullyParsed = true;
133 </script>
134
135 <script src="../../resources/js-test-post.js"></script>
136 </body>
137 </html>
OLDNEW
« no previous file with comments | « conformance/misc/bad-arguments-test.html ('k') | conformance/misc/delayed-drawing.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698