Backed out changeset b462e7b742d8 (bug 1908261) for causing multiple reftest failures...
[gecko.git] / dom / canvas / test / webgl-conf / checkout / conformance / uniforms / gl-get-uniform-non-current-program.html
blobf6628748f026b23c7c153582ac258bc7ebed576a
1 <!--
2 Copyright (c) 2022 The Khronos Group Inc.
3 Use of this source code is governed by an MIT-style license that can be
4 found in the LICENSE.txt file.
5 -->
7 <!DOCTYPE html>
8 <html>
9 <head>
10 <meta charset="utf-8">
11 <title>WebGL getUniform from non-current program</title>
12 <link rel="stylesheet" href="../../resources/js-test-style.css"/>
13 <script src="../../js/js-test-pre.js"></script>
14 <script src="../../js/webgl-test-utils.js"></script>
15 </head>
16 <body>
17 <div id="description"></div>
18 <div id="console"></div>
19 <canvas id="example" width="2" height="2"> </canvas>
20 <script id="vshader" type="x-shader/x-vertex">
21 attribute vec4 vPosition;
22 void main()
24 gl_Position = vPosition;
26 </script>
28 <script id="fshader" type="x-shader/x-fragment">
29 precision mediump float;
30 uniform float color;
31 void main()
33 gl_FragColor = vec4(color);
35 </script>
36 <script>
37 "use strict";
38 description("This test ensures WebGL implementations handle getUniform when the program is not the current program");
40 debug("");
42 var wtu = WebGLTestUtils;
43 var gl = wtu.create3DContext("example");
44 var program1 = wtu.setupProgram(gl, ["vshader", "fshader"], ["vPosition"]);
45 var program2 = wtu.setupProgram(gl, ["vshader", "fshader"], ["vPosition"]);
46 var loc = gl.getUniformLocation(program1, "color");
48 debug("check we can call getUniform when the program is current")
49 gl.useProgram(program1);
50 shouldBe("gl.getUniform(program1, loc)", "0");
51 debug("check we can call getUniform when a different program is current")
52 gl.useProgram(program2);
53 shouldBe("gl.getUniform(program1, loc)", "0");
54 debug("check we can call getUniform when no program is current")
55 gl.useProgram(null);
56 shouldBe("gl.getUniform(program1, loc)", "0");
58 debug("check we can call getUniform when the program is current")
59 gl.useProgram(program1);
60 gl.uniform1f(loc, 123)
61 shouldBe("gl.getUniform(program1, loc)", "123");
62 debug("check we can call getUniform when a different program is current")
63 gl.useProgram(program2);
64 shouldBe("gl.getUniform(program1, loc)", "123");
65 debug("check we can call getUniform when no program is current")
66 gl.useProgram(null);
67 shouldBe("gl.getUniform(program1, loc)", "123");
70 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should no errors");
72 debug("");
73 var successfullyParsed = true;
75 </script>
76 <script src="../../js/js-test-post.js"></script>
78 </body>
79 </html>