Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / canvas / webgl / uniform-location.html
blobea090de578b4a78eed7cda9d255388aa7dcba8b1
1 <html>
2 <head>
3 <script src="../../../resources/js-test.js"></script>
4 <script src="resources/webgl-test.js"></script>
5 </head>
6 <body>
7 <div id="description"></div>
8 <div id="console"></div>
10 <script>
11 description("Tests the WebGLUniformLocation API");
13 if (window.internals)
14 window.internals.settings.setWebGLErrorsToConsoleEnabled(false);
16 var contextA = create3DContext();
17 var contextB = create3DContext();
18 var programA1 = loadStandardProgram(contextA);
19 var programA2 = loadStandardProgram(contextA);
20 var programB = loadStandardProgram(contextB);
21 var programS = loadProgram(contextA, "resources/structUniformShader.vert", "resources/fragmentShader.frag");
22 var programV = loadProgram(contextA, "resources/floatUniformShader.vert", "resources/noopUniformShader.frag");
23 var locationA = contextA.getUniformLocation(programA1, 'u_modelViewProjMatrix');
24 var locationB = contextB.getUniformLocation(programB, 'u_modelViewProjMatrix');
25 var locationSx = contextA.getUniformLocation(programS, "u_struct.x");
26 var locationArray0 = contextA.getUniformLocation(programS, "u_array[0]");
27 var locationArray1 = contextA.getUniformLocation(programS, "u_array[1]");
28 var locationVec4 = contextA.getUniformLocation(programV, "fval4");
30 var vec = [1, 2, 3, 4];
31 var mat = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16];
33 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.useProgram(programA2)");
34 shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.uniformMatrix4fv(locationA, false, mat)");
35 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.useProgram(programA1)");
36 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniformMatrix4fv(locationA, false, mat)");
37 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniformMatrix4fv(null, false, mat)");
39 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.useProgram(programS)");
40 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniform1i(locationSx, 3)");
41 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniform1f(locationArray0, 4.0)");
42 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniform1f(locationArray1, 5.0)");
44 shouldBe("contextA.getUniform(programS, locationSx)", "3");
45 shouldBe("contextA.getUniform(programS, locationArray0)", "4.0");
46 shouldBe("contextA.getUniform(programS, locationArray1)", "5.0");
48 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.useProgram(programV)");
49 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniform4fv(locationVec4, vec)");
50 shouldBe("contextA.getUniform(programV, locationVec4)", "vec");
52 shouldBeNull("contextA.getUniformLocation(programV, \"IDontExist\")");
53 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.linkProgram(programA1)");
54 // After linking all boxes are bad.
55 shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.uniformMatrix4fv(locationA, false, mat)");
57 // after re-linking the same program, all uniform locations become invalid.
58 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.useProgram(programS)");
59 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.linkProgram(programS)");
60 shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.uniform1i(locationSx, 3)");
61 shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.getUniform(programS, locationSx)");
63 // Retrieve the locations again, and they should be good.
64 locationSx = contextA.getUniformLocation(programS, "u_struct.x");
65 locationArray0 = contextA.getUniformLocation(programS, "u_array[0]");
66 shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniform1i(locationSx, 3)");
67 shouldBe("contextA.getUniform(programS, locationSx)", "3");
68 </script>
70 </body>
71 </html>