summaryrefslogtreecommitdiffstats
path: root/dom/canvas/test/webgl-conf/checkout/conformance/uniforms
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/canvas/test/webgl-conf/checkout/conformance/uniforms
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/canvas/test/webgl-conf/checkout/conformance/uniforms')
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/uniforms/00_test_list.txt31
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/uniforms/gl-get-uniform-non-current-program.html79
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/uniforms/gl-uniform-arrays.html738
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/uniforms/gl-uniform-bool.html59
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/uniforms/gl-uniform-struct-unused.html83
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/uniforms/gl-uniform-unused-array-elements-get-truncated.html114
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/uniforms/gl-uniformmatrix4fv.html149
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/uniforms/gl-unknown-uniform.html67
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-00.html39
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-01.html39
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-02.html39
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-03.html39
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-04.html39
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-05.html39
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-06.html39
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-07.html39
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-08.html39
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-09.html39
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-10.html39
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-11.html39
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-12.html39
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-13.html39
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-14.html39
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-15.html39
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-16.html39
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-17.html39
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/uniforms/null-uniform-location.html81
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/uniforms/out-of-bounds-uniform-array-access.html168
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/uniforms/uniform-default-values.html339
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/uniforms/uniform-location.html96
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/uniforms/uniform-samplers-test.html111
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/uniforms/uniform-values-per-program.html179
32 files changed, 2996 insertions, 0 deletions
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/00_test_list.txt b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/00_test_list.txt
new file mode 100644
index 0000000000..2da0fc47a3
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/00_test_list.txt
@@ -0,0 +1,31 @@
+gl-uniform-arrays.html
+# This test is no longer valid with the new packing restrictions
+#--min-version 1.0.02 gl-uniform-unused-array-elements-get-truncated.html
+gl-uniform-bool.html
+--min-version 1.0.4 gl-get-uniform-non-current-program.html
+gl-uniformmatrix4fv.html
+gl-unknown-uniform.html
+no-over-optimization-on-uniform-array-00.html
+no-over-optimization-on-uniform-array-01.html
+no-over-optimization-on-uniform-array-02.html
+no-over-optimization-on-uniform-array-03.html
+no-over-optimization-on-uniform-array-04.html
+no-over-optimization-on-uniform-array-05.html
+no-over-optimization-on-uniform-array-06.html
+no-over-optimization-on-uniform-array-07.html
+no-over-optimization-on-uniform-array-08.html
+no-over-optimization-on-uniform-array-09.html
+no-over-optimization-on-uniform-array-10.html
+no-over-optimization-on-uniform-array-11.html
+no-over-optimization-on-uniform-array-12.html
+no-over-optimization-on-uniform-array-13.html
+no-over-optimization-on-uniform-array-14.html
+no-over-optimization-on-uniform-array-15.html
+no-over-optimization-on-uniform-array-16.html
+no-over-optimization-on-uniform-array-17.html
+null-uniform-location.html
+--min-version 1.0.2 out-of-bounds-uniform-array-access.html
+--min-version 1.0.2 uniform-default-values.html
+--min-version 1.0.3 uniform-values-per-program.html
+uniform-location.html
+uniform-samplers-test.html
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/gl-get-uniform-non-current-program.html b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/gl-get-uniform-non-current-program.html
new file mode 100644
index 0000000000..f6628748f0
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/gl-get-uniform-non-current-program.html
@@ -0,0 +1,79 @@
+<!--
+Copyright (c) 2022 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL getUniform from non-current program</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<canvas id="example" width="2" height="2"> </canvas>
+ <script id="vshader" type="x-shader/x-vertex">
+ attribute vec4 vPosition;
+ void main()
+ {
+ gl_Position = vPosition;
+ }
+ </script>
+
+ <script id="fshader" type="x-shader/x-fragment">
+ precision mediump float;
+ uniform float color;
+ void main()
+ {
+ gl_FragColor = vec4(color);
+ }
+ </script>
+<script>
+"use strict";
+description("This test ensures WebGL implementations handle getUniform when the program is not the current program");
+
+debug("");
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+var program1 = wtu.setupProgram(gl, ["vshader", "fshader"], ["vPosition"]);
+var program2 = wtu.setupProgram(gl, ["vshader", "fshader"], ["vPosition"]);
+var loc = gl.getUniformLocation(program1, "color");
+
+debug("check we can call getUniform when the program is current")
+gl.useProgram(program1);
+shouldBe("gl.getUniform(program1, loc)", "0");
+debug("check we can call getUniform when a different program is current")
+gl.useProgram(program2);
+shouldBe("gl.getUniform(program1, loc)", "0");
+debug("check we can call getUniform when no program is current")
+gl.useProgram(null);
+shouldBe("gl.getUniform(program1, loc)", "0");
+
+debug("check we can call getUniform when the program is current")
+gl.useProgram(program1);
+gl.uniform1f(loc, 123)
+shouldBe("gl.getUniform(program1, loc)", "123");
+debug("check we can call getUniform when a different program is current")
+gl.useProgram(program2);
+shouldBe("gl.getUniform(program1, loc)", "123");
+debug("check we can call getUniform when no program is current")
+gl.useProgram(null);
+shouldBe("gl.getUniform(program1, loc)", "123");
+
+
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should no errors");
+
+debug("");
+var successfullyParsed = true;
+
+</script>
+<script src="../../js/js-test-post.js"></script>
+
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/gl-uniform-arrays.html b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/gl-uniform-arrays.html
new file mode 100644
index 0000000000..7ffde96d84
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/gl-uniform-arrays.html
@@ -0,0 +1,738 @@
+<!--
+Copyright (c) 2019 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL uniform array Conformance Tests</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<canvas id="example" width="2" height="2"> </canvas>
+<script id="vshader" type="x-shader/x-vertex">
+ attribute vec4 a_position;
+ void main()
+ {
+ gl_Position = a_position;
+ }
+</script>
+
+<script id="fshader" type="x-shader/x-fragment">
+ precision mediump float;
+ uniform $(type) color[3];
+ void main()
+ {
+ gl_FragColor = vec4(color[0]$(elem), color[1]$(elem), color[2]$(elem), 1);
+ }
+</script>
+<script id="vshader300" type="x-shader/x-vertex">
+ #version 300 es
+ in vec4 a_position;
+ void main()
+ {
+ gl_Position = a_position;
+ }
+</script>
+
+<script id="fshader300" type="x-shader/x-fragment">
+ #version 300 es
+ precision mediump float;
+ uniform $(type) color[3];
+ out vec4 o_FragColor;
+ void main()
+ {
+ o_FragColor = vec4(color[0]$(elem), color[1]$(elem), color[2]$(elem), 1);
+ }
+</script>
+<script>
+"use strict";
+description();
+debug("");
+// MaxInt32 is 2^32-1. We need +1 of that to test overflow conditions.
+var MaxInt32PlusOne = 4294967296;
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+
+const contextVersion = wtu.getDefault3DContextVersion();
+
+let [vElemId, fElemId] = ["vshader", "fshader"];
+if (contextVersion >= 2) {
+ [vElemId, fElemId] = ["vshader300", "fshader300"];
+}
+
+var vSrc = wtu.getScript(vElemId).trim();
+var fTemplate = wtu.getScript(fElemId).trim();
+
+const typeInfos = [
+ { type: 'float',
+ jsTypeOf: 'number',
+ setter: 'uniform1fv',
+ elem: '',
+ numSrcValues: 3,
+ invalidSet: function(loc) {
+ gl.uniform2fv(loc, [1, 2]);
+ },
+ srcValueAsString: function(index, srcValues) {
+ return srcValues[index].toString();
+ },
+ returnValueAsString: function(value) {
+ return value === null ? 'null' : value.toString();
+ },
+ checkType: function(value) {
+ return typeof value === 'number';
+ },
+ checkValue: function(typeInfo, index, value) {
+ return typeInfo.srcValues[index] == value;
+ },
+ srcValues: [16, 15, 14],
+ srcValuesLess: [],
+ srcValuesLessMultiple: [16],
+ srcValuesMoreMultiple: [16, 15, 14, 13],
+ srcValuesNonMultiple: null,
+ },
+ { type: 'vec2',
+ jsTypeOf: 'Float32Array',
+ setter: 'uniform2fv',
+ elem: '[1]',
+ numSrcValues: 3,
+ invalidSet: function(loc) {
+ gl.uniform1fv(loc, [2]);
+ },
+ illegalSet: function(loc) {
+ gl.uniform1fv(loc, 2);
+ },
+ srcValueAsString: function(index, srcValues) {
+ return "[" + srcValues[index * 2 + 0].toString() + ", " +
+ srcValues[index * 2 + 1].toString() + "]";
+ },
+ returnValueAsString: function(value) {
+ return value === null ? 'null' : ("[" + value[0] + ", " + value[1] + "]");
+ },
+ checkType: function(value) {
+ return value &&
+ typeof value.length === 'number' &&
+ value.length == 2;
+ },
+ checkValue: function(typeInfo, index, value) {
+ return value !== null &&
+ typeInfo.srcValues[index * 2 + 0] == value[0] &&
+ typeInfo.srcValues[index * 2 + 1] == value[1];
+ },
+ srcValues: [16, 15, 14, 13, 12, 11],
+ srcValuesLess: [16],
+ srcValuesLessMultiple: [16, 15, 14, 13],
+ srcValuesMoreMultiple: [16, 15, 14, 13, 12, 11, 10, 9],
+ srcValuesNonMultiple: [16, 15, 14, 13, 12, 11, 10],
+ },
+ { type: 'vec3',
+ jsTypeOf: 'Float32Array',
+ setter: 'uniform3fv',
+ elem: '[2]',
+ numSrcValues: 3,
+ invalidSet: function(loc) {
+ gl.uniform1fv(loc, [2]);
+ },
+ illegalSet: function(loc) {
+ gl.uniform1fv(loc, 2);
+ },
+ srcValueAsString: function(index, srcValues) {
+ return "[" + srcValues[index * 3 + 0].toString() + ", " +
+ srcValues[index * 3 + 1].toString() + ", " +
+ srcValues[index * 3 + 2].toString() + "]";
+ },
+ returnValueAsString: function(value) {
+ return value === null ? 'null' :
+ ("[" + value[0] + ", " + value[1] + ", " + value[2] + "]");
+ },
+ checkType: function(value) {
+ return value &&
+ typeof value.length === 'number' &&
+ value.length == 3;
+ },
+ checkValue: function(typeInfo, index, value) {
+ return value !== null &&
+ typeInfo.srcValues[index * 3 + 0] == value[0] &&
+ typeInfo.srcValues[index * 3 + 1] == value[1] &&
+ typeInfo.srcValues[index * 3 + 2] == value[2];
+ },
+ srcValues: [16, 15, 14, 13, 12, 11, 10, 9, 8],
+ srcValuesLess: [16, 15],
+ srcValuesLessMultiple: [16, 15, 14, 13, 12, 11],
+ srcValuesMoreMultiple: [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2],
+ srcValuesNonMultiple: [16, 15, 14, 13, 12, 11, 10, 9, 8, 7],
+ },
+ { type: 'vec4',
+ jsTypeOf: 'Float32Array',
+ setter: 'uniform4fv',
+ elem: '[3]',
+ numSrcValues: 3,
+ invalidSet: function(loc) {
+ gl.uniform1fv(loc, [2]);
+ },
+ illegalSet: function(loc) {
+ gl.uniform1fv(loc, 2);
+ },
+ srcValueAsString: function(index, srcValues) {
+ return "[" + srcValues[index * 4 + 0].toString() + ", " +
+ srcValues[index * 4 + 1].toString() + ", " +
+ srcValues[index * 4 + 2].toString() + ", " +
+ srcValues[index * 4 + 3].toString() + "]";
+ },
+ returnValueAsString: function(value) {
+ return value === null ? 'null' :
+ ("[" + value[0] + ", " + value[1] +
+ ", " + value[2] + ", " + value[3] + "]");
+ },
+ checkType: function(value) {
+ return value &&
+ typeof value.length === 'number' &&
+ value.length == 4;
+ },
+ checkValue: function(typeInfo, index, value) {
+ return value !== null &&
+ typeInfo.srcValues[index * 4 + 0] == value[0] &&
+ typeInfo.srcValues[index * 4 + 1] == value[1] &&
+ typeInfo.srcValues[index * 4 + 2] == value[2] &&
+ typeInfo.srcValues[index * 4 + 3] == value[3];
+ },
+ srcValues: [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5],
+ srcValuesLess: [16, 15, 14],
+ srcValuesLessMultiple: [16, 15, 14, 13, 12, 11, 10, 9],
+ srcValuesMoreMultiple: [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],
+ srcValuesNonMultiple: [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4],
+ }
+];
+
+if (contextVersion >= 2) {
+ const more = [
+ { type: 'int',
+ jsTypeOf: 'number',
+ setter: 'uniform1iv',
+ elem: '',
+ numSrcValues: 3,
+ invalidSet: function(loc) {
+ gl.uniform2iv(loc, [1, 2]);
+ },
+ srcValueAsString: function(index, srcValues) {
+ return srcValues[index].toString();
+ },
+ returnValueAsString: function(value) {
+ return value === null ? 'null' : value.toString();
+ },
+ checkType: function(value) {
+ return typeof value === 'number';
+ },
+ checkValue: function(typeInfo, index, value) {
+ return typeInfo.srcValues[index] == value;
+ },
+ srcValues: [16, 15, 14],
+ srcValuesLess: [],
+ srcValuesLessMultiple: [16],
+ srcValuesMoreMultiple: [16, 15, 14, 13],
+ srcValuesNonMultiple: null,
+ },
+ { type: 'ivec2',
+ jsTypeOf: 'Int32Array',
+ setter: 'uniform2iv',
+ elem: '[1]',
+ numSrcValues: 3,
+ invalidSet: function(loc) {
+ gl.uniform1iv(loc, [2]);
+ },
+ illegalSet: function(loc) {
+ gl.uniform1iv(loc, 2);
+ },
+ srcValueAsString: function(index, srcValues) {
+ return "[" + srcValues[index * 2 + 0].toString() + ", " +
+ srcValues[index * 2 + 1].toString() + "]";
+ },
+ returnValueAsString: function(value) {
+ return value === null ? 'null' : ("[" + value[0] + ", " + value[1] + "]");
+ },
+ checkType: function(value) {
+ return value &&
+ typeof value.length === 'number' &&
+ value.length == 2;
+ },
+ checkValue: function(typeInfo, index, value) {
+ return value !== null &&
+ typeInfo.srcValues[index * 2 + 0] == value[0] &&
+ typeInfo.srcValues[index * 2 + 1] == value[1];
+ },
+ srcValues: [16, 15, 14, 13, 12, 11],
+ srcValuesLess: [16],
+ srcValuesLessMultiple: [16, 15, 14, 13],
+ srcValuesMoreMultiple: [16, 15, 14, 13, 12, 11, 10, 9],
+ srcValuesNonMultiple: [16, 15, 14, 13, 12, 11, 10],
+ },
+ { type: 'ivec3',
+ jsTypeOf: 'Int32Array',
+ setter: 'uniform3iv',
+ elem: '[2]',
+ numSrcValues: 3,
+ invalidSet: function(loc) {
+ gl.uniform1iv(loc, [2]);
+ },
+ illegalSet: function(loc) {
+ gl.uniform1iv(loc, 2);
+ },
+ srcValueAsString: function(index, srcValues) {
+ return "[" + srcValues[index * 3 + 0].toString() + ", " +
+ srcValues[index * 3 + 1].toString() + ", " +
+ srcValues[index * 3 + 2].toString() + "]";
+ },
+ returnValueAsString: function(value) {
+ return value === null ? 'null' :
+ ("[" + value[0] + ", " + value[1] + ", " + value[2] + "]");
+ },
+ checkType: function(value) {
+ return value &&
+ typeof value.length === 'number' &&
+ value.length == 3;
+ },
+ checkValue: function(typeInfo, index, value) {
+ return value !== null &&
+ typeInfo.srcValues[index * 3 + 0] == value[0] &&
+ typeInfo.srcValues[index * 3 + 1] == value[1] &&
+ typeInfo.srcValues[index * 3 + 2] == value[2];
+ },
+ srcValues: [16, 15, 14, 13, 12, 11, 10, 9, 8],
+ srcValuesLess: [16, 15],
+ srcValuesLessMultiple: [16, 15, 14, 13, 12, 11],
+ srcValuesMoreMultiple: [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2],
+ srcValuesNonMultiple: [16, 15, 14, 13, 12, 11, 10, 9, 8, 7],
+ },
+ { type: 'ivec4',
+ jsTypeOf: 'Int32Array',
+ setter: 'uniform4iv',
+ elem: '[3]',
+ numSrcValues: 3,
+ invalidSet: function(loc) {
+ gl.uniform1iv(loc, [2]);
+ },
+ illegalSet: function(loc) {
+ gl.uniform1iv(loc, 2);
+ },
+ srcValueAsString: function(index, srcValues) {
+ return "[" + srcValues[index * 4 + 0].toString() + ", " +
+ srcValues[index * 4 + 1].toString() + ", " +
+ srcValues[index * 4 + 2].toString() + ", " +
+ srcValues[index * 4 + 3].toString() + "]";
+ },
+ returnValueAsString: function(value) {
+ return value === null ? 'null' :
+ ("[" + value[0] + ", " + value[1] +
+ ", " + value[2] + ", " + value[3] + "]");
+ },
+ checkType: function(value) {
+ return value &&
+ typeof value.length === 'number' &&
+ value.length == 4;
+ },
+ checkValue: function(typeInfo, index, value) {
+ return value !== null &&
+ typeInfo.srcValues[index * 4 + 0] == value[0] &&
+ typeInfo.srcValues[index * 4 + 1] == value[1] &&
+ typeInfo.srcValues[index * 4 + 2] == value[2] &&
+ typeInfo.srcValues[index * 4 + 3] == value[3];
+ },
+ srcValues: [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5],
+ srcValuesLess: [16, 15, 14],
+ srcValuesLessMultiple: [16, 15, 14, 13, 12, 11, 10, 9],
+ srcValuesMoreMultiple: [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],
+ srcValuesNonMultiple: [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4],
+ },
+
+
+ { type: 'uint',
+ jsTypeOf: 'number',
+ setter: 'uniform1uiv',
+ elem: '',
+ numSrcValues: 3,
+ invalidSet: function(loc) {
+ gl.uniform2uiv(loc, [1, 2]);
+ },
+ srcValueAsString: function(index, srcValues) {
+ return srcValues[index].toString();
+ },
+ returnValueAsString: function(value) {
+ return value === null ? 'null' : value.toString();
+ },
+ checkType: function(value) {
+ return typeof value === 'number';
+ },
+ checkValue: function(typeInfo, index, value) {
+ return typeInfo.srcValues[index] == value;
+ },
+ srcValues: [16, 15, 14],
+ srcValuesLess: [],
+ srcValuesLessMultiple: [16],
+ srcValuesMoreMultiple: [16, 15, 14, 13],
+ srcValuesNonMultiple: null,
+ },
+ { type: 'uvec2',
+ jsTypeOf: 'Uint32Array',
+ setter: 'uniform2uiv',
+ elem: '[1]',
+ numSrcValues: 3,
+ invalidSet: function(loc) {
+ gl.uniform1uiv(loc, [2]);
+ },
+ illegalSet: function(loc) {
+ gl.uniform1uiv(loc, 2);
+ },
+ srcValueAsString: function(index, srcValues) {
+ return "[" + srcValues[index * 2 + 0].toString() + ", " +
+ srcValues[index * 2 + 1].toString() + "]";
+ },
+ returnValueAsString: function(value) {
+ return value === null ? 'null' : ("[" + value[0] + ", " + value[1] + "]");
+ },
+ checkType: function(value) {
+ return value &&
+ typeof value.length === 'number' &&
+ value.length == 2;
+ },
+ checkValue: function(typeInfo, index, value) {
+ return value !== null &&
+ typeInfo.srcValues[index * 2 + 0] == value[0] &&
+ typeInfo.srcValues[index * 2 + 1] == value[1];
+ },
+ srcValues: [16, 15, 14, 13, 12, 11],
+ srcValuesLess: [16],
+ srcValuesLessMultiple: [16, 15, 14, 13],
+ srcValuesMoreMultiple: [16, 15, 14, 13, 12, 11, 10, 9],
+ srcValuesNonMultiple: [16, 15, 14, 13, 12, 11, 10],
+ },
+ { type: 'uvec3',
+ jsTypeOf: 'Uint32Array',
+ setter: 'uniform3uiv',
+ elem: '[2]',
+ numSrcValues: 3,
+ invalidSet: function(loc) {
+ gl.uniform1uiv(loc, [2]);
+ },
+ illegalSet: function(loc) {
+ gl.uniform1uiv(loc, 2);
+ },
+ srcValueAsString: function(index, srcValues) {
+ return "[" + srcValues[index * 3 + 0].toString() + ", " +
+ srcValues[index * 3 + 1].toString() + ", " +
+ srcValues[index * 3 + 2].toString() + "]";
+ },
+ returnValueAsString: function(value) {
+ return value === null ? 'null' :
+ ("[" + value[0] + ", " + value[1] + ", " + value[2] + "]");
+ },
+ checkType: function(value) {
+ return value &&
+ typeof value.length === 'number' &&
+ value.length == 3;
+ },
+ checkValue: function(typeInfo, index, value) {
+ return value !== null &&
+ typeInfo.srcValues[index * 3 + 0] == value[0] &&
+ typeInfo.srcValues[index * 3 + 1] == value[1] &&
+ typeInfo.srcValues[index * 3 + 2] == value[2];
+ },
+ srcValues: [16, 15, 14, 13, 12, 11, 10, 9, 8],
+ srcValuesLess: [16, 15],
+ srcValuesLessMultiple: [16, 15, 14, 13, 12, 11],
+ srcValuesMoreMultiple: [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2],
+ srcValuesNonMultiple: [16, 15, 14, 13, 12, 11, 10, 9, 8, 7],
+ },
+ { type: 'uvec4',
+ jsTypeOf: 'Uint32Array',
+ setter: 'uniform4uiv',
+ elem: '[3]',
+ numSrcValues: 3,
+ invalidSet: function(loc) {
+ gl.uniform1uiv(loc, [2]);
+ },
+ illegalSet: function(loc) {
+ gl.uniform1uiv(loc, 2);
+ },
+ srcValueAsString: function(index, srcValues) {
+ return "[" + srcValues[index * 4 + 0].toString() + ", " +
+ srcValues[index * 4 + 1].toString() + ", " +
+ srcValues[index * 4 + 2].toString() + ", " +
+ srcValues[index * 4 + 3].toString() + "]";
+ },
+ returnValueAsString: function(value) {
+ return value === null ? 'null' :
+ ("[" + value[0] + ", " + value[1] +
+ ", " + value[2] + ", " + value[3] + "]");
+ },
+ checkType: function(value) {
+ return value &&
+ typeof value.length === 'number' &&
+ value.length == 4;
+ },
+ checkValue: function(typeInfo, index, value) {
+ return value !== null &&
+ typeInfo.srcValues[index * 4 + 0] == value[0] &&
+ typeInfo.srcValues[index * 4 + 1] == value[1] &&
+ typeInfo.srcValues[index * 4 + 2] == value[2] &&
+ typeInfo.srcValues[index * 4 + 3] == value[3];
+ },
+ srcValues: [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5],
+ srcValuesLess: [16, 15, 14],
+ srcValuesLessMultiple: [16, 15, 14, 13, 12, 11, 10, 9],
+ srcValuesMoreMultiple: [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],
+ srcValuesNonMultiple: [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4],
+ },
+
+
+ { type: 'bool',
+ jsTypeOf: 'boolean',
+ setter: 'uniform1iv',
+ elem: '',
+ numSrcValues: 3,
+ invalidSet: function(loc) {
+ gl.uniform2iv(loc, [1, 2]);
+ },
+ srcValueAsString: function(index, srcValues) {
+ return srcValues[index].toString();
+ },
+ returnValueAsString: function(value) {
+ return value === null ? 'null' : value.toString();
+ },
+ checkType: function(value) {
+ return typeof value === 'boolean';
+ },
+ checkValue: function(typeInfo, index, value) {
+ return typeInfo.srcValues[index] == value;
+ },
+ srcValues: [true, true, true],
+ srcValuesLess: [],
+ srcValuesLessMultiple: [16],
+ srcValuesMoreMultiple: [16, 15, 14, 13],
+ srcValuesNonMultiple: null,
+ },
+ { type: 'bvec2',
+ jsTypeOf: 'Float32Array',
+ setter: 'uniform2fv',
+ elem: '[1]',
+ numSrcValues: 3,
+ invalidSet: function(loc) {
+ gl.uniform1iv(loc, [2]);
+ },
+ illegalSet: function(loc) {
+ gl.uniform1iv(loc, 2);
+ },
+ srcValueAsString: function(index, srcValues) {
+ return "[" + srcValues[index * 2 + 0].toString() + ", " +
+ srcValues[index * 2 + 1].toString() + "]";
+ },
+ returnValueAsString: function(value) {
+ return value === null ? 'null' : ("[" + value[0] + ", " + value[1] + "]");
+ },
+ checkType: function(value) {
+ return value &&
+ typeof value.length === 'number' &&
+ value.length == 2;
+ },
+ checkValue: function(typeInfo, index, value) {
+ return value !== null &&
+ typeInfo.srcValues[index * 2 + 0] == value[0] &&
+ typeInfo.srcValues[index * 2 + 1] == value[1];
+ },
+ srcValues: [true, true, true, true, true, true],
+ srcValuesLess: [16],
+ srcValuesLessMultiple: [16, 15, 14, 13],
+ srcValuesMoreMultiple: [16, 15, 14, 13, 12, 11, 10, 9],
+ srcValuesNonMultiple: [16, 15, 14, 13, 12, 11, 10],
+ },
+ { type: 'bvec3',
+ jsTypeOf: 'Int32Array',
+ setter: 'uniform3iv',
+ elem: '[2]',
+ numSrcValues: 3,
+ invalidSet: function(loc) {
+ gl.uniform1iv(loc, [2]);
+ },
+ illegalSet: function(loc) {
+ gl.uniform1iv(loc, 2);
+ },
+ srcValueAsString: function(index, srcValues) {
+ return "[" + srcValues[index * 3 + 0].toString() + ", " +
+ srcValues[index * 3 + 1].toString() + ", " +
+ srcValues[index * 3 + 2].toString() + "]";
+ },
+ returnValueAsString: function(value) {
+ return value === null ? 'null' :
+ ("[" + value[0] + ", " + value[1] + ", " + value[2] + "]");
+ },
+ checkType: function(value) {
+ return value &&
+ typeof value.length === 'number' &&
+ value.length == 3;
+ },
+ checkValue: function(typeInfo, index, value) {
+ return value !== null &&
+ typeInfo.srcValues[index * 3 + 0] == value[0] &&
+ typeInfo.srcValues[index * 3 + 1] == value[1] &&
+ typeInfo.srcValues[index * 3 + 2] == value[2];
+ },
+ srcValues: [true, true, true, true, true, true, true, true, true],
+ srcValuesLess: [16, 15],
+ srcValuesLessMultiple: [16, 15, 14, 13, 12, 11],
+ srcValuesMoreMultiple: [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2],
+ srcValuesNonMultiple: [16, 15, 14, 13, 12, 11, 10, 9, 8, 7],
+ },
+ { type: 'bvec4',
+ jsTypeOf: 'Uint32Array',
+ setter: 'uniform4uiv',
+ elem: '[3]',
+ numSrcValues: 3,
+ invalidSet: function(loc) {
+ gl.uniform1iv(loc, [2]);
+ },
+ illegalSet: function(loc) {
+ gl.uniform1iv(loc, 2);
+ },
+ srcValueAsString: function(index, srcValues) {
+ return "[" + srcValues[index * 4 + 0].toString() + ", " +
+ srcValues[index * 4 + 1].toString() + ", " +
+ srcValues[index * 4 + 2].toString() + ", " +
+ srcValues[index * 4 + 3].toString() + "]";
+ },
+ returnValueAsString: function(value) {
+ return value === null ? 'null' :
+ ("[" + value[0] + ", " + value[1] +
+ ", " + value[2] + ", " + value[3] + "]");
+ },
+ checkType: function(value) {
+ return value &&
+ typeof value.length === 'number' &&
+ value.length == 4;
+ },
+ checkValue: function(typeInfo, index, value) {
+ return value !== null &&
+ typeInfo.srcValues[index * 4 + 0] == value[0] &&
+ typeInfo.srcValues[index * 4 + 1] == value[1] &&
+ typeInfo.srcValues[index * 4 + 2] == value[2] &&
+ typeInfo.srcValues[index * 4 + 3] == value[3];
+ },
+ srcValues: [true, true, true, true, true, true, true, true, true, true, true, true],
+ srcValuesLess: [16, 15, 14],
+ srcValuesLessMultiple: [16, 15, 14, 13, 12, 11, 10, 9],
+ srcValuesMoreMultiple: [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],
+ srcValuesNonMultiple: [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4],
+ }
+ ];
+ typeInfos.push(...more);
+}
+
+let loc;
+for (var tt = 0; tt < typeInfos.length; ++tt) {
+ var typeInfo = typeInfos[tt];
+ debug("");
+ debug("check " + typeInfo.type);
+ var fSrc = wtu.replaceParams(fTemplate, typeInfo);
+ //debug("fSrc: " + fSrc);
+ var program = wtu.loadProgram(gl, vSrc, fSrc);
+
+ var numUniforms = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS);
+ assertMsg(numUniforms == 1, "1 uniform found");
+ var info = gl.getActiveUniform(program, 0);
+ assertMsg(info.name == "color[0]",
+ "uniform name is 'color[0]' not 'color' as per OpenGL ES 2.0.24 section 2.10");
+ shouldBeNull("gl.getUniformLocation(program, 'color[" + MaxInt32PlusOne + "]');");
+ loc = gl.getUniformLocation(program, "color[0]");
+ if (!loc) throw 'Missing loc';
+ var srcValues = typeInfo.srcValues;
+ var srcValuesLess = typeInfo.srcValuesLess;
+ var srcValuesLessMultiple = typeInfo.srcValuesLessMultiple;
+ var srcValuesMoreMultiple = typeInfo.srcValuesMoreMultiple;
+ var srcValuesNonMultiple = typeInfo.srcValuesNonMultiple;
+
+ // Try setting the value before using the program
+ gl[typeInfo.setter](loc, srcValues);
+ wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION,
+ "should fail if there is no current program");
+
+ gl.useProgram(program);
+ gl[typeInfo.setter](loc, srcValuesLess);
+ wtu.glErrorShouldBe(gl, gl.INVALID_VALUE,
+ "should fail with insufficient array size with gl." + typeInfo.setter);
+ if (srcValuesNonMultiple) {
+ gl[typeInfo.setter](loc, srcValuesNonMultiple);
+ wtu.glErrorShouldBe(gl, gl.INVALID_VALUE,
+ "should fail with non-multiple array size with gl." + typeInfo.setter);
+ }
+
+ const validDatas = [
+ `new Float32Array(${srcValues.length})`,
+ `new Float32Array(new ArrayBuffer(4*${srcValues.length}))`,
+ ];
+ if (window.SharedArrayBuffer) {
+ validDatas.push(
+ `new Float32Array(new SharedArrayBuffer(4*${srcValues.length}))`
+ );
+ }
+ for (const x of validDatas) {
+ shouldNotThrow(`gl.${typeInfo.setter}(loc, ${x});`);
+ }
+
+ gl[typeInfo.setter](loc, srcValues);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR,
+ "can set an array of uniforms with gl." + typeInfo.setter);
+ gl[typeInfo.setter](loc, srcValuesLessMultiple);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR,
+ "can partially set an array of uniforms with gl." + typeInfo.setter + " with a smaller array");
+ gl[typeInfo.setter](loc, srcValuesMoreMultiple);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR,
+ "can set an array of uniforms with gl." + typeInfo.setter + " with a larger array");
+
+ var values = gl.getUniform(program, loc);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR,
+ "can call gl.getUniform");
+ assertMsg(typeInfo.checkType(values),
+ "gl.getUniform returns the correct type. " + `(was ${values.constructor.name})`);
+ for (var ii = 0; ii < typeInfo.numSrcValues; ++ii) {
+ shouldBeNull("gl.getUniformLocation(program, 'color[" + (MaxInt32PlusOne + ii) + "]')");
+ var elemLoc = gl.getUniformLocation(program, "color[" + ii + "]");
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR,
+ "can get location of element " + ii +
+ " of array from gl.getUniformLocation");
+ var value = gl.getUniform(program, elemLoc);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR,
+ "can get value of element " + ii + " of array from gl.getUniform");
+ assertMsg(typeInfo.checkValue(typeInfo, ii, value),
+ "value put in (" + typeInfo.srcValueAsString(ii, srcValues) +
+ ") matches value pulled out (" +
+ typeInfo.returnValueAsString(value) + ")");
+ }
+ typeInfo.invalidSet(loc);
+ wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION,
+ "using the wrong size of gl.Uniform fails");
+ var exceptionCaught = false;
+ if (typeInfo.illegalSet) {
+ try {
+ typeInfo.illegalSet(loc);
+ } catch (e) {
+ exceptionCaught = true;
+ }
+ assertMsg(exceptionCaught, "passing non-array to glUniform*fv should throw TypeError");
+ }
+
+ gl.useProgram(null);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR,
+ "can call gl.useProgram(null)");
+}
+
+var successfullyParsed = true;
+
+</script>
+<script src="../../js/js-test-post.js"></script>
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/gl-uniform-bool.html b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/gl-uniform-bool.html
new file mode 100644
index 0000000000..4f23cb4cf4
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/gl-uniform-bool.html
@@ -0,0 +1,59 @@
+<!--
+Copyright (c) 2019 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL uniformMatrix Conformance Tests</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<canvas id="example" width="2" height="2"> </canvas>
+ <script id="vshader" type="x-shader/x-vertex">
+ attribute vec4 vPosition;
+ void main()
+ {
+ gl_Position = vPosition;
+ }
+ </script>
+
+ <script id="fshader" type="x-shader/x-fragment">
+ uniform bool color;
+ void main()
+ {
+ gl_FragColor = vec4(float(color),0.0,0.0,1.0);
+ }
+ </script>
+<script>
+"use strict";
+description("This test ensures WebGL implementations handle bool uniforms in a OpenGL ES 2.0 spec compliant way");
+
+debug("");
+debug("NOTE: Some OpenGL drivers do not handle this correctly");
+debug("");
+debug("Checking gl.uniform1f with bool.");
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+var program = wtu.setupProgram(gl, ["vshader", "fshader"], ["vPosition"]);
+var loc = gl.getUniformLocation(program, "color");
+gl.uniform1f(loc, 1);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR,
+ "should be able to set bool with gl.uniform1f");
+
+debug("");
+var successfullyParsed = true;
+
+</script>
+<script src="../../js/js-test-post.js"></script>
+
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/gl-uniform-struct-unused.html b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/gl-uniform-struct-unused.html
new file mode 100644
index 0000000000..b755e59ee2
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/gl-uniform-struct-unused.html
@@ -0,0 +1,83 @@
+<!--
+Copyright (c) 2019 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL uniform struct Conformance Test</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<canvas id="example" width="2" height="2"> </canvas>
+
+<script id="vshader" type="x-shader/x-vertex">
+attribute vec4 vPosition;
+uniform vec4 u0;
+struct MyStruct {
+ vec4 var1;
+ vec4 var2;
+ vec4 var3;
+ vec4 var4;
+};
+uniform MyStruct u1;
+uniform vec4 u2;
+varying vec4 v_color;
+void main()
+{
+ gl_Position = vPosition;
+ v_color = (u0 + u2 + u1.var1) - vec4(2.0);
+}
+</script>
+
+<script id="fshader" type="x-shader/x-fragment">
+precision mediump float;
+varying vec4 v_color;
+void main()
+{
+ gl_FragColor = v_color;
+}
+</script>
+
+<script>
+"use strict";
+description("This test ensures WebGL implementations handle unused members at the end of structs correctly.");
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext();
+var c = document.getElementById("console");
+program = wtu.setupProgram(gl, ["vshader", "fshader"], [ "vPosition"]);
+
+wtu.setupUnitQuad(gl, [0, 1]);
+var white = [1.0, 1.0, 1.0, 1.0];
+var black = [0.0, 0.0, 0.0, 0.0];
+gl.uniform4fv(gl.getUniformLocation(program, "u0"), white);
+gl.uniform4fv(gl.getUniformLocation(program, "u1.var1"), white);
+gl.uniform4fv(gl.getUniformLocation(program, "u1.var2"), black);
+gl.uniform4fv(gl.getUniformLocation(program, "u1.var3"), black);
+gl.uniform4fv(gl.getUniformLocation(program, "u1.var4"), black);
+gl.uniform4fv(gl.getUniformLocation(program, "u2"), white);
+wtu.clearAndDrawUnitQuad(gl);
+wtu.checkCanvas(gl, [255, 255, 255, 255], "should be white", 0);
+gl.uniform4fv(gl.getUniformLocation(program, "u1.var2"), black);
+gl.uniform4fv(gl.getUniformLocation(program, "u1.var3"), black);
+gl.uniform4fv(gl.getUniformLocation(program, "u1.var4"), black);
+wtu.clearAndDrawUnitQuad(gl, [0, 0, 0, 0]);
+wtu.checkCanvas(gl, [255, 255, 255, 255], "should still be white", 0);
+
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be no GL errors");
+debug("");
+var successfullyParsed = true;
+
+</script>
+<script src="../../js/js-test-post.js"></script>
+
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/gl-uniform-unused-array-elements-get-truncated.html b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/gl-uniform-unused-array-elements-get-truncated.html
new file mode 100644
index 0000000000..f8322cca01
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/gl-uniform-unused-array-elements-get-truncated.html
@@ -0,0 +1,114 @@
+<!--
+Copyright (c) 2019 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL uniform unused array elements get truncated Conformance Test</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<canvas id="example" width="2" height="2"> </canvas>
+<script id="vshader" type="x-shader/x-vertex">
+ attribute vec4 a_position;
+ void main()
+ {
+ gl_Position = a_position;
+ }
+</script>
+<script id="fshader-max" type="x-shader/x-fragment">
+ precision mediump float;
+ uniform vec4 colora[$(numUniformVectors)];
+ void main()
+ {
+ gl_FragColor = vec4(colora[$(usedUniformVector)]);
+ }
+</script>
+<script>
+"use strict";
+description();
+debug("");
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+var vSrc = wtu.getScript("vshader");
+var uniforms;
+// This test is to test drivers the have bugs related to optimizing
+// an array of uniforms when only 1 of those uniforms is used.
+debug("");
+var maxUniformVectors = gl.getParameter(gl.MAX_FRAGMENT_UNIFORM_VECTORS);
+var tests = [
+ { desc: "using 5th element",
+ maxUniformVectors: maxUniformVectors,
+ numUniformVectors: maxUniformVectors * 2,
+ usedUniformVector: 5,
+ shader: "fshader-max",
+ color: [0, 1, 0, 1],
+ arrayName: "colora",
+ },
+];
+
+// According to the spec unused array elements must be truncated.
+var requiredUniformLocationsExist;
+function testUniformIssues(testIndex) {
+ var test = tests[testIndex];
+ debug("");
+ debug(test.desc);
+ var fSrc = test.source;
+ if (!fSrc) {
+ fSrc = wtu.replaceParams(wtu.getScript(test.shader), test);
+ }
+
+ var consoleElem = document.getElementById("console");
+ wtu.addShaderSource(
+ consoleElem, "vertex shader", vSrc);
+ wtu.addShaderSource(
+ consoleElem, "fragment shader", fSrc);
+
+ var program = wtu.loadProgram(gl, vSrc, fSrc);
+ gl.useProgram(program);
+ uniforms = wtu.getUniformMap(gl, program);
+ shouldBe('uniforms["' + test.arrayName + '[0]"].size', (test.usedUniformVector + 1).toString());
+
+ requiredUniformLocationsExist = true;
+ for (var ii = 0; ii <= test.usedUniformVector + 1; ++ii) {
+ var name = test.arrayName + "[" + ii + "]";
+ var colorLocation = gl.getUniformLocation(program, name);
+ if (ii <= test.usedUniformVector) {
+ if (!colorLocation) {
+ requiredUniformLocationsExist = false
+ }
+ } else {
+ if (colorLocation) {
+ testFailed("uniform array was not truncated as specified in OpenGL ES 2.0.25 section 2.10.4");
+ }
+ }
+ }
+ shouldBeTrue("requiredUniformLocationsExist");
+}
+
+var testIndex = 0;
+function runNextTest() {
+ testUniformIssues(testIndex++);
+ if (testIndex < tests.length) {
+ setTimeout(runNextTest, 0);
+ } else {
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors");
+ debug("");
+ finishTest();
+ }
+}
+runNextTest();
+
+var successfullyParsed = true;
+
+</script>
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/gl-uniformmatrix4fv.html b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/gl-uniformmatrix4fv.html
new file mode 100644
index 0000000000..eb4977a6fd
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/gl-uniformmatrix4fv.html
@@ -0,0 +1,149 @@
+<!--
+Copyright (c) 2019 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL uniformMatrix Conformance Tests</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<canvas id="example" width="2" height="2"> </canvas>
+
+<script id="vshader" type="x-shader/x-vertex">
+uniform mat2 world2x2;
+uniform mat3 world3x3;
+uniform mat4 world4x4;
+void main() {
+ gl_Position.x += world2x2[0][0];
+ gl_Position.x += world3x3[0][0];
+ gl_Position.x += world4x4[0][0];
+}
+</script>
+
+<script id="fshader" type="x-shader/x-fragment">
+void main() {}
+</script>
+
+<script id="vshader300" type="x-shader/x-vertex">
+#version 300 es
+uniform mat2 world2x2;
+uniform mat2x3 world2x3;
+uniform mat2x4 world2x4;
+uniform mat3x2 world3x2;
+uniform mat3 world3x3;
+uniform mat3x4 world3x4;
+uniform mat4x2 world4x2;
+uniform mat4x3 world4x3;
+uniform mat4 world4x4;
+void main() {
+ gl_Position.x += world2x2[0][0];
+ gl_Position.x += world2x3[0][0];
+ gl_Position.x += world2x4[0][0];
+ gl_Position.x += world3x2[0][0];
+ gl_Position.x += world3x3[0][0];
+ gl_Position.x += world3x4[0][0];
+ gl_Position.x += world4x2[0][0];
+ gl_Position.x += world4x3[0][0];
+ gl_Position.x += world4x4[0][0];
+}
+</script>
+
+<script id="fshader300" type="x-shader/x-fragment">
+#version 300 es
+void main() {}
+</script>
+
+<script>
+"use strict";
+description("This test ensures WebGL implementations handle uniformMatrix in a OpenGL ES 2.0 spec compliant way");
+
+debug("");
+debug("Checking gl.uniformMatrix.");
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+var contextVersion = wtu.getDefault3DContextVersion();
+
+let shaders = ["vshader", "fshader"];
+const dims = [
+ [2, 2, 'uniformMatrix2fv'],
+ [3, 3, 'uniformMatrix3fv'],
+ [4, 4, 'uniformMatrix4fv'],
+];
+
+if (contextVersion >= 2) {
+ shaders = ["vshader300", "fshader300"];
+ dims.push(
+ [2, 3, 'uniformMatrix2x3fv'],
+ [2, 4, 'uniformMatrix2x4fv'],
+ [3, 2, 'uniformMatrix3x2fv'],
+ [3, 4, 'uniformMatrix3x4fv'],
+ [4, 2, 'uniformMatrix4x2fv'],
+ [4, 3, 'uniformMatrix4x3fv']
+ );
+}
+
+const program = wtu.setupProgram(gl, shaders);
+let loc;
+
+for (const [A, B, name] of dims) {
+ loc = gl.getUniformLocation(program, `world${A}x${B}`);
+ if (!loc) throw 'missing loc';
+
+ const mat = [];
+ for (let a = 0; a < A; ++a) {
+ for (let b = 0; b < B; ++b) {
+ mat.push((a == b) ? 1 : 0);
+ }
+ }
+ const matLess = mat.slice(0, mat.length-2);
+ const matMore = mat.concat([1]);
+
+ gl[name](loc, false, matLess);
+ wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "should fail with insufficient array size for " + name);
+ gl[name](loc, false, mat);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should succeed with correct array size for " + name);
+ gl[name](loc, false, matMore);
+ wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "should fail with more than 1 array size for " + name);
+
+ const validDatas = [
+ `new Float32Array(${mat.length})`,
+ `new Float32Array(new ArrayBuffer(4*${mat.length}))`,
+ ];
+ if (window.SharedArrayBuffer) {
+ validDatas.push(
+ `new Float32Array(new SharedArrayBuffer(4*${mat.length}))`
+ );
+ }
+ for (const x of validDatas) {
+ shouldNotThrow(`gl.${name}(loc, false, ${x});`);
+ }
+
+ gl[name](loc, false, mat);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "can call " + name + "with transpose = false");
+ if (contextVersion <= 1) {
+ gl[name](loc, true, mat);
+ wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, name + " should return INVALID_VALUE with transpose = true");
+ } else {
+ gl[name](loc, true, mat);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "can call " + name + "with transpose = true");
+ }
+}
+
+debug("");
+var successfullyParsed = true;
+
+</script>
+<script src="../../js/js-test-post.js"></script>
+
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/gl-unknown-uniform.html b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/gl-unknown-uniform.html
new file mode 100644
index 0000000000..825fd23831
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/gl-unknown-uniform.html
@@ -0,0 +1,67 @@
+<!--
+Copyright (c) 2019 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL Unknown Uniform Conformance Test</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<canvas id="canvas" width="2" height="2"> </canvas>
+<script id="vshader" type="x-shader/x-vertex">
+attribute vec4 vPosition;
+void main()
+{
+ gl_Position = vPosition;
+}
+</script>
+
+<script id="fshader" type="x-shader/x-fragment">
+void main()
+{
+ gl_FragColor = vec4(1.0,0.0,0.0,1.0);
+}
+</script>
+<script>
+"use strict";
+description("Tests that unknown uniforms don't cause errors.");
+
+debug("");
+debug("Canvas.getContext");
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("canvas");
+if (!gl) {
+ testFailed("context does not exist");
+} else {
+ testPassed("context exists");
+
+ debug("");
+
+ var program = wtu.setupProgram(gl, ["vshader", "fshader"], ["vPosition"]);
+ // Get the location of an unknown uniform.
+ var loc = gl.getUniformLocation(program, "someUnknownUniform");
+ assertMsg(loc === null, "location of unknown uniform should be null");
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR,
+ "there should be no error from getting an unknown uniform");
+ gl.uniform1f(loc, 1);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR,
+ "there should be no error from trying to set an unknown uniform");
+}
+
+debug("");
+var successfullyParsed = true;
+</script>
+<script src="../../js/js-test-post.js"></script>
+
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-00.html b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-00.html
new file mode 100644
index 0000000000..d331fa9299
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-00.html
@@ -0,0 +1,39 @@
+<!--
+Copyright (c) 2019 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL uniform array Conformance Tests</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"></script>
+<script src="../../js/tests/no-over-optimizations-on-uniform-array.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<canvas id="example" width="2" height="2"> </canvas>
+<script>
+"use strict";
+description();
+debug("");
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+var testIndex = 0;
+var testSet = NoOverOptimizeOnUniformArrayTester.setupTests(gl);
+var testCases = [testSet[testIndex]];
+
+NoOverOptimizeOnUniformArrayTester.runTests(gl, testCases)
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors");
+
+var successfullyParsed = true;
+</script>
+<script src="../../js/js-test-post.js"></script>
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-01.html b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-01.html
new file mode 100644
index 0000000000..a60c1af473
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-01.html
@@ -0,0 +1,39 @@
+<!--
+Copyright (c) 2019 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL uniform array Conformance Tests</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"></script>
+<script src="../../js/tests/no-over-optimizations-on-uniform-array.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<canvas id="example" width="2" height="2"> </canvas>
+<script>
+"use strict";
+description();
+debug("");
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+var testIndex = 1;
+var testSet = NoOverOptimizeOnUniformArrayTester.setupTests(gl);
+var testCases = [testSet[testIndex]];
+
+NoOverOptimizeOnUniformArrayTester.runTests(gl, testCases)
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors");
+
+var successfullyParsed = true;
+</script>
+<script src="../../js/js-test-post.js"></script>
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-02.html b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-02.html
new file mode 100644
index 0000000000..670d553802
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-02.html
@@ -0,0 +1,39 @@
+<!--
+Copyright (c) 2019 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL uniform array Conformance Tests</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"></script>
+<script src="../../js/tests/no-over-optimizations-on-uniform-array.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<canvas id="example" width="2" height="2"> </canvas>
+<script>
+"use strict";
+description();
+debug("");
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+var testIndex = 2;
+var testSet = NoOverOptimizeOnUniformArrayTester.setupTests(gl);
+var testCases = [testSet[testIndex]];
+
+NoOverOptimizeOnUniformArrayTester.runTests(gl, testCases)
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors");
+
+var successfullyParsed = true;
+</script>
+<script src="../../js/js-test-post.js"></script>
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-03.html b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-03.html
new file mode 100644
index 0000000000..5702b78033
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-03.html
@@ -0,0 +1,39 @@
+<!--
+Copyright (c) 2019 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL uniform array Conformance Tests</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"></script>
+<script src="../../js/tests/no-over-optimizations-on-uniform-array.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<canvas id="example" width="2" height="2"> </canvas>
+<script>
+"use strict";
+description();
+debug("");
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+var testIndex = 3;
+var testSet = NoOverOptimizeOnUniformArrayTester.setupTests(gl);
+var testCases = [testSet[testIndex]];
+
+NoOverOptimizeOnUniformArrayTester.runTests(gl, testCases)
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors");
+
+var successfullyParsed = true;
+</script>
+<script src="../../js/js-test-post.js"></script>
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-04.html b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-04.html
new file mode 100644
index 0000000000..b46e8915e1
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-04.html
@@ -0,0 +1,39 @@
+<!--
+Copyright (c) 2019 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL uniform array Conformance Tests</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"></script>
+<script src="../../js/tests/no-over-optimizations-on-uniform-array.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<canvas id="example" width="2" height="2"> </canvas>
+<script>
+"use strict";
+description();
+debug("");
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+var testIndex = 4;
+var testSet = NoOverOptimizeOnUniformArrayTester.setupTests(gl);
+var testCases = [testSet[testIndex]];
+
+NoOverOptimizeOnUniformArrayTester.runTests(gl, testCases)
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors");
+
+var successfullyParsed = true;
+</script>
+<script src="../../js/js-test-post.js"></script>
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-05.html b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-05.html
new file mode 100644
index 0000000000..43caca6c9f
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-05.html
@@ -0,0 +1,39 @@
+<!--
+Copyright (c) 2019 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL uniform array Conformance Tests</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"></script>
+<script src="../../js/tests/no-over-optimizations-on-uniform-array.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<canvas id="example" width="2" height="2"> </canvas>
+<script>
+"use strict";
+description();
+debug("");
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+var testIndex = 5;
+var testSet = NoOverOptimizeOnUniformArrayTester.setupTests(gl);
+var testCases = [testSet[testIndex]];
+
+NoOverOptimizeOnUniformArrayTester.runTests(gl, testCases)
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors");
+
+var successfullyParsed = true;
+</script>
+<script src="../../js/js-test-post.js"></script>
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-06.html b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-06.html
new file mode 100644
index 0000000000..e18b69ea5e
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-06.html
@@ -0,0 +1,39 @@
+<!--
+Copyright (c) 2019 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL uniform array Conformance Tests</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"></script>
+<script src="../../js/tests/no-over-optimizations-on-uniform-array.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<canvas id="example" width="2" height="2"> </canvas>
+<script>
+"use strict";
+description();
+debug("");
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+var testIndex = 6;
+var testSet = NoOverOptimizeOnUniformArrayTester.setupTests(gl);
+var testCases = [testSet[testIndex]];
+
+NoOverOptimizeOnUniformArrayTester.runTests(gl, testCases)
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors");
+
+var successfullyParsed = true;
+</script>
+<script src="../../js/js-test-post.js"></script>
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-07.html b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-07.html
new file mode 100644
index 0000000000..365890dc90
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-07.html
@@ -0,0 +1,39 @@
+<!--
+Copyright (c) 2019 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL uniform array Conformance Tests</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"></script>
+<script src="../../js/tests/no-over-optimizations-on-uniform-array.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<canvas id="example" width="2" height="2"> </canvas>
+<script>
+"use strict";
+description();
+debug("");
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+var testIndex = 7;
+var testSet = NoOverOptimizeOnUniformArrayTester.setupTests(gl);
+var testCases = [testSet[testIndex]];
+
+NoOverOptimizeOnUniformArrayTester.runTests(gl, testCases)
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors");
+
+var successfullyParsed = true;
+</script>
+<script src="../../js/js-test-post.js"></script>
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-08.html b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-08.html
new file mode 100644
index 0000000000..442cea6bed
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-08.html
@@ -0,0 +1,39 @@
+<!--
+Copyright (c) 2019 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL uniform array Conformance Tests</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"></script>
+<script src="../../js/tests/no-over-optimizations-on-uniform-array.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<canvas id="example" width="2" height="2"> </canvas>
+<script>
+"use strict";
+description();
+debug("");
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+var testIndex = 8;
+var testSet = NoOverOptimizeOnUniformArrayTester.setupTests(gl);
+var testCases = [testSet[testIndex]];
+
+NoOverOptimizeOnUniformArrayTester.runTests(gl, testCases)
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors");
+
+var successfullyParsed = true;
+</script>
+<script src="../../js/js-test-post.js"></script>
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-09.html b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-09.html
new file mode 100644
index 0000000000..4543434e77
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-09.html
@@ -0,0 +1,39 @@
+<!--
+Copyright (c) 2019 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL uniform array Conformance Tests</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"></script>
+<script src="../../js/tests/no-over-optimizations-on-uniform-array.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<canvas id="example" width="2" height="2"> </canvas>
+<script>
+"use strict";
+description();
+debug("");
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+var testIndex = 9;
+var testSet = NoOverOptimizeOnUniformArrayTester.setupTests(gl);
+var testCases = [testSet[testIndex]];
+
+NoOverOptimizeOnUniformArrayTester.runTests(gl, testCases)
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors");
+
+var successfullyParsed = true;
+</script>
+<script src="../../js/js-test-post.js"></script>
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-10.html b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-10.html
new file mode 100644
index 0000000000..dd4827f5f9
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-10.html
@@ -0,0 +1,39 @@
+<!--
+Copyright (c) 2019 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL uniform array Conformance Tests</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"></script>
+<script src="../../js/tests/no-over-optimizations-on-uniform-array.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<canvas id="example" width="2" height="2"> </canvas>
+<script>
+"use strict";
+description();
+debug("");
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+var testIndex = 10;
+var testSet = NoOverOptimizeOnUniformArrayTester.setupTests(gl);
+var testCases = [testSet[testIndex]];
+
+NoOverOptimizeOnUniformArrayTester.runTests(gl, testCases)
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors");
+
+var successfullyParsed = true;
+</script>
+<script src="../../js/js-test-post.js"></script>
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-11.html b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-11.html
new file mode 100644
index 0000000000..93b34b906b
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-11.html
@@ -0,0 +1,39 @@
+<!--
+Copyright (c) 2019 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL uniform array Conformance Tests</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"></script>
+<script src="../../js/tests/no-over-optimizations-on-uniform-array.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<canvas id="example" width="2" height="2"> </canvas>
+<script>
+"use strict";
+description();
+debug("");
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+var testIndex = 11;
+var testSet = NoOverOptimizeOnUniformArrayTester.setupTests(gl);
+var testCases = [testSet[testIndex]];
+
+NoOverOptimizeOnUniformArrayTester.runTests(gl, testCases)
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors");
+
+var successfullyParsed = true;
+</script>
+<script src="../../js/js-test-post.js"></script>
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-12.html b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-12.html
new file mode 100644
index 0000000000..e802600741
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-12.html
@@ -0,0 +1,39 @@
+<!--
+Copyright (c) 2019 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL uniform array Conformance Tests</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"></script>
+<script src="../../js/tests/no-over-optimizations-on-uniform-array.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<canvas id="example" width="2" height="2"> </canvas>
+<script>
+"use strict";
+description();
+debug("");
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+var testIndex = 12;
+var testSet = NoOverOptimizeOnUniformArrayTester.setupTests(gl);
+var testCases = [testSet[testIndex]];
+
+NoOverOptimizeOnUniformArrayTester.runTests(gl, testCases)
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors");
+
+var successfullyParsed = true;
+</script>
+<script src="../../js/js-test-post.js"></script>
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-13.html b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-13.html
new file mode 100644
index 0000000000..0606ef5a28
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-13.html
@@ -0,0 +1,39 @@
+<!--
+Copyright (c) 2019 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL uniform array Conformance Tests</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"></script>
+<script src="../../js/tests/no-over-optimizations-on-uniform-array.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<canvas id="example" width="2" height="2"> </canvas>
+<script>
+"use strict";
+description();
+debug("");
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+var testIndex = 13;
+var testSet = NoOverOptimizeOnUniformArrayTester.setupTests(gl);
+var testCases = [testSet[testIndex]];
+
+NoOverOptimizeOnUniformArrayTester.runTests(gl, testCases)
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors");
+
+var successfullyParsed = true;
+</script>
+<script src="../../js/js-test-post.js"></script>
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-14.html b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-14.html
new file mode 100644
index 0000000000..7e33adce4f
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-14.html
@@ -0,0 +1,39 @@
+<!--
+Copyright (c) 2019 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL uniform array Conformance Tests</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"></script>
+<script src="../../js/tests/no-over-optimizations-on-uniform-array.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<canvas id="example" width="2" height="2"> </canvas>
+<script>
+"use strict";
+description();
+debug("");
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+var testIndex = 14;
+var testSet = NoOverOptimizeOnUniformArrayTester.setupTests(gl);
+var testCases = [testSet[testIndex]];
+
+NoOverOptimizeOnUniformArrayTester.runTests(gl, testCases)
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors");
+
+var successfullyParsed = true;
+</script>
+<script src="../../js/js-test-post.js"></script>
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-15.html b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-15.html
new file mode 100644
index 0000000000..46b50679b7
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-15.html
@@ -0,0 +1,39 @@
+<!--
+Copyright (c) 2019 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL uniform array Conformance Tests</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"></script>
+<script src="../../js/tests/no-over-optimizations-on-uniform-array.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<canvas id="example" width="2" height="2"> </canvas>
+<script>
+"use strict";
+description();
+debug("");
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+var testIndex = 15;
+var testSet = NoOverOptimizeOnUniformArrayTester.setupTests(gl);
+var testCases = [testSet[testIndex]];
+
+NoOverOptimizeOnUniformArrayTester.runTests(gl, testCases)
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors");
+
+var successfullyParsed = true;
+</script>
+<script src="../../js/js-test-post.js"></script>
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-16.html b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-16.html
new file mode 100644
index 0000000000..881b76b560
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-16.html
@@ -0,0 +1,39 @@
+<!--
+Copyright (c) 2019 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL uniform array Conformance Tests</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"></script>
+<script src="../../js/tests/no-over-optimizations-on-uniform-array.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<canvas id="example" width="2" height="2"> </canvas>
+<script>
+"use strict";
+description();
+debug("");
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+var testIndex = 16;
+var testSet = NoOverOptimizeOnUniformArrayTester.setupTests(gl);
+var testCases = [testSet[testIndex]];
+
+NoOverOptimizeOnUniformArrayTester.runTests(gl, testCases)
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors");
+
+var successfullyParsed = true;
+</script>
+<script src="../../js/js-test-post.js"></script>
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-17.html b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-17.html
new file mode 100644
index 0000000000..9dcb8ae9b8
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/no-over-optimization-on-uniform-array-17.html
@@ -0,0 +1,39 @@
+<!--
+Copyright (c) 2019 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL uniform array Conformance Tests</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"></script>
+<script src="../../js/tests/no-over-optimizations-on-uniform-array.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<canvas id="example" width="2" height="2"> </canvas>
+<script>
+"use strict";
+description();
+debug("");
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+var testIndex = 17;
+var testSet = NoOverOptimizeOnUniformArrayTester.setupTests(gl);
+var testCases = [testSet[testIndex]];
+
+NoOverOptimizeOnUniformArrayTester.runTests(gl, testCases)
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "there should be no errors");
+
+var successfullyParsed = true;
+</script>
+<script src="../../js/js-test-post.js"></script>
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/null-uniform-location.html b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/null-uniform-location.html
new file mode 100644
index 0000000000..0c49bdb2f0
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/null-uniform-location.html
@@ -0,0 +1,81 @@
+<!--
+Copyright (c) 2019 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+
+<script>
+"use strict";
+description("Tests calling the various uniform[Matrix]* APIs with a null uniform location");
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext();
+var program = wtu.loadStandardProgram(gl);
+
+wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+shouldBeUndefined("gl.useProgram(program)");
+var floatArray = new Float32Array([1, 2, 3, 4]);
+var intArray = new Int32Array([1, 2, 3, 4]);
+
+function callUniformFunction(name) {
+ var isArrayVariant = (name.charAt(name.length - 1) == 'v');
+ var isMatrix = (name.indexOf("Matrix") != -1);
+ var isFloat =
+ (name.charAt(name.length - 1) == 'f' ||
+ name.charAt(name.length - 2) == 'f');
+ var sizeIndex = (isArrayVariant ? name.length - 3 : name.length - 2);
+ var size = parseInt(name.substring(sizeIndex, sizeIndex + 1));
+ // Initialize argument list with null uniform location
+ var args = [ null ];
+ if (isArrayVariant) {
+ // Call variant which takes values as array
+ if (isMatrix) {
+ size = size * size;
+ args.push(false);
+ }
+ var array = (isFloat ? new Float32Array(size) : new Int32Array(size));
+ for (var i = 0; i < size; i++) {
+ array[i] = i;
+ }
+ args.push(array);
+ } else {
+ // Call variant which takes values as parameters
+ for (var i = 0; i < size; i++) {
+ args.push(i);
+ }
+ }
+ var func = gl[name];
+ return func.apply(gl, args);
+}
+
+var funcs = [ "uniform1f", "uniform1fv", "uniform1i", "uniform1iv",
+ "uniform2f", "uniform2fv", "uniform2i", "uniform2iv",
+ "uniform3f", "uniform3fv", "uniform3i", "uniform3iv",
+ "uniform4f", "uniform4fv", "uniform4i", "uniform4iv",
+ "uniformMatrix2fv", "uniformMatrix3fv", "uniformMatrix4fv" ];
+var callString;
+
+for (var i = 0; i < funcs.length; i++) {
+ callString = "callUniformFunction('" + funcs[i] + "')";
+ shouldBeUndefined(callString);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+}
+
+var successfullyParsed = true;
+</script>
+<script src="../../js/js-test-post.js"></script>
+
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/out-of-bounds-uniform-array-access.html b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/out-of-bounds-uniform-array-access.html
new file mode 100644
index 0000000000..1defc8ee0e
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/out-of-bounds-uniform-array-access.html
@@ -0,0 +1,168 @@
+<!--
+Copyright (c) 2019 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL out of bounds uniform array access.</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"> </script>
+</head>
+<body>
+<div id="description"></div>
+<canvas id="example" width="128" height="128" style="background: black;">
+</canvas>
+<div id="console"></div>
+<script id="vshader" type="x-shader/x-vertex">
+attribute vec4 vPosition;
+varying vec4 v_color;
+uniform float lineWidth;
+uniform int elemMult;
+uniform vec4 colorArray[6];
+void main()
+{
+ vec2 texcoord = vec2(vPosition.xy * 0.5 + vec2(0.5, 0.5));
+ int index = int(texcoord.x + texcoord.y * lineWidth) * elemMult;
+ v_color = colorArray[index];
+ gl_Position = vPosition;
+ gl_PointSize = 1.0;
+}
+</script>
+
+<script id="fshader" type="x-shader/x-fragment">
+precision mediump float;
+varying vec4 v_color;
+void main()
+{
+ gl_FragColor = v_color;
+}
+</script>
+<script>
+"use strict";
+debug("Tests a WebGL program that accesses out of bounds uniform array elements");
+
+var gl;
+var gridRes = 127;
+var lineWidthLoc;
+var elemMultLoc;
+var width = 128;
+var height = 128;
+var pixels = new Uint8Array(width * height * 4);
+
+var lineWidth = 0;
+var elemMult = 0;
+
+var knownColors = [
+ 1.0, 0.0, 0.0, 1.0, // Red
+ 0.0, 1.0, 0.0, 1.0, // Green
+ 0.0, 0.0, 1.0, 1.0, // Blue
+ 0.0, 1.0, 1.0, 1.0, // Cyan
+ 1.0, 0.0, 1.0, 1.0, // Magenta
+ 1.0, 1.0, 0.0, 1.0 // Yellow
+];
+
+function main() {
+ var wtu = WebGLTestUtils;
+ gl = wtu.create3DContext("example");
+ var program = wtu.setupProgram(
+ gl,
+ ['vshader', 'fshader'],
+ ['vPosition'], [0]);
+
+ // setupQuad produces the geometry we want for a gridRes x gridRes grid
+ // of points. No interpolation will be performed across the points, so
+ // according to the WebGL specification for out-of-bounds array accesses,
+ // we will get exactly the input colors from the uniform colorArray, or
+ // zero, for each pixel on the canvas.
+ wtu.setupIndexedQuad(gl, gridRes, 0);
+ var colorArrayLoc = gl.getUniformLocation(program, "colorArray[0]");
+ assertMsg(colorArrayLoc != null, "color array uniform should be found");
+ var colors = new Float32Array(knownColors);
+ gl.uniform4fv(colorArrayLoc, colors);
+ lineWidthLoc = gl.getUniformLocation(program, "lineWidth");
+ elemMultLoc = gl.getUniformLocation(program, "elemMult");
+ assertMsg(gl.getError() == gl.NO_ERROR, "Should be no errors from setup.");
+ runOneIteration();
+}
+
+function withinEpsilon(val1, val2) {
+ return Math.abs(val1 - val2) < 0.0001;
+}
+
+function isKnownColor(r, g, b) {
+ if (r == 0 && g == 0 && b == 0)
+ return true;
+ for (var ii = 0; ii < knownColors.length; ii += 4) {
+ if (withinEpsilon(r / 255.0, knownColors[ii + 0]) &&
+ withinEpsilon(g / 255.0, knownColors[ii + 1]) &&
+ withinEpsilon(b / 255.0, knownColors[ii + 2]))
+ return true;
+ }
+ return false;
+}
+
+function runOneIteration() {
+ if (elemMult < 2048) {
+ var ok = true;
+ var startingLineWidth = lineWidth;
+ var firstFailingPixel = null;
+ var firstFailingValue = null;
+ for (; lineWidth < 2540; lineWidth += 31) {
+ // Draw
+ gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
+ gl.uniform1f(lineWidthLoc, lineWidth);
+ gl.uniform1i(elemMultLoc, elemMult);
+ gl.drawArrays(gl.POINTS, 0, gridRes * gridRes);
+
+ // Read back
+ gl.readPixels(0, 0, width, height, gl.RGBA, gl.UNSIGNED_BYTE, pixels);
+
+ // Verify
+ for (var y = 0; y < height; ++y) {
+ for (var x = 0; x < width; ++x) {
+ if (!isKnownColor(pixels[4 * (width * y + x) + 0],
+ pixels[4 * (width * y + x) + 1],
+ pixels[4 * (width * y + x) + 2])) {
+ ok = false;
+ if (firstFailingPixel == null) {
+ firstFailingPixel = [x, y];
+ firstFailingValue = [pixels[4 * (width * y + x) + 0],
+ pixels[4 * (width * y + x) + 1],
+ pixels[4 * (width * y + x) + 2]];
+ }
+ }
+ }
+ }
+ }
+ var endingLineWidth = lineWidth - 31;
+ lineWidth -= 2540;
+ if (ok) {
+ testPassed("Good rendering results for lineWidths " +
+ startingLineWidth + "..." + endingLineWidth +
+ " at elemMult=" + elemMult);
+ } else {
+ testFailed("for lineWidth=" + lineWidth + ", elemMult=" + elemMult +
+ ": first failing pixel (" + firstFailingPixel[0] + ", " + firstFailingPixel[1] + ") was (" +
+ firstFailingValue[0] + ", " +
+ firstFailingValue[1] + ", " +
+ firstFailingValue[2] + "), should be (0, 0, 0) or one of known colors");
+ }
+ elemMult += 73;
+ setTimeout(runOneIteration, 0);
+ } else {
+ finishTest();
+ }
+}
+
+main();
+
+var successfullyParsed = true;
+
+</script>
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/uniform-default-values.html b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/uniform-default-values.html
new file mode 100644
index 0000000000..862182c272
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/uniform-default-values.html
@@ -0,0 +1,339 @@
+<!--
+Copyright (c) 2019 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL uniform default values</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"></script>
+<script src="../../js/test-eval.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+<canvas id="example" width="2" height="2"> </canvas>
+<script id="vshader0" type="x-shader/x-vertex">
+attribute vec4 vPosition;
+void main()
+{
+ gl_Position = vPosition;
+}
+</script>
+<script id="fshader0" type="x-shader/x-fragment">
+precision mediump float;
+uniform $(type) u_uniform;
+
+bool isZero($(type) value) {
+ $(check);
+}
+
+void main()
+{
+ gl_FragColor = isZero(u_uniform) ? vec4(0,1,0,1) : vec4(1,0,0,1);
+}
+</script>
+<script id="vshader1" type="x-shader/x-vertex">
+attribute vec4 vPosition;
+varying vec4 v_color;
+uniform $(type) u_uniform;
+
+bool isZero($(type) value) {
+ $(check);
+}
+
+void main()
+{
+ gl_Position = vPosition;
+ v_color = isZero(u_uniform) ? vec4(0,1,0,1) : vec4(1,0,0,1);
+}
+</script>
+<script id="fshader1" type="x-shader/x-fragment">
+precision mediump float;
+varying vec4 v_color;
+void main()
+{
+ gl_FragColor = v_color;
+}
+</script>
+<script id="vshader2" type="x-shader/x-vertex">
+attribute vec4 vPosition;
+void main()
+{
+ gl_Position = vPosition;
+}
+</script>
+<script id="fshader2" type="x-shader/x-fragment">
+precision mediump float;
+uniform $(type) u_uniform[2];
+
+bool isZero($(type) value) {
+ $(check);
+}
+
+void main()
+{
+ gl_FragColor = isZero(u_uniform[1]) ? vec4(0,1,0,1) : vec4(1,0,0,1);
+}
+</script>
+<script id="vshader3" type="x-shader/x-vertex">
+attribute vec4 vPosition;
+varying vec4 v_color;
+uniform $(type) u_uniform[2];
+
+bool isZero($(type) value) {
+ $(check);
+}
+
+void main()
+{
+ gl_Position = vPosition;
+ v_color = isZero(u_uniform[1]) ? vec4(0,1,0,1) : vec4(1,0,0,1);
+}
+</script>
+<script id="fshader3" type="x-shader/x-fragment">
+precision mediump float;
+varying vec4 v_color;
+void main()
+{
+ gl_FragColor = v_color;
+}
+</script>
+<script>
+"use strict";
+description();
+
+var tests = [
+{ type: 'float',
+ check: "return value == 0.0",
+ setFn: function(gl, loc) { gl.uniform1f(loc, 3.0); }
+},
+{ type: 'int',
+ check: "return value == 0",
+ setFn: function(gl, loc) { gl.uniform1i(loc, 3.0); }
+},
+{ type: 'bool',
+ check: "return value == false",
+ setFn: function(gl, loc) { gl.uniform1i(loc, 1); }
+},
+{ type: 'vec2',
+ check: "return value[0] == 0.0 && value[1] == 0.0",
+ setFn: function(gl, loc) { gl.uniform2f(loc, 3.0, 3.0); }
+},
+{ type: 'vec3',
+ check: "return value[0] == 0.0 && value[1] == 0.0 && value[2] == 0.0",
+ setFn: function(gl, loc) { gl.uniform3f(loc, 3.0, 3.0, 3.0); }
+},
+{ type: 'vec4',
+ check: "return value[0] == 0.0 && value[1] == 0.0 && value[2] == 0.0 && value[3] == 0.0",
+ setFn: function(gl, loc) { gl.uniform4f(loc, 3.0, 3.0, 3.0, 3.0); }
+},
+{ type: 'ivec2',
+ check: "return value[0] == 0 && value[1] == 0",
+ setFn: function(gl, loc) { gl.uniform2i(loc, 3, 3); }
+},
+{ type: 'ivec3',
+ check: "return value[0] == 0 && value[1] == 0 && value[2] == 0",
+ setFn: function(gl, loc) { gl.uniform3i(loc, 3, 3, 3); }
+},
+{ type: 'ivec4',
+ check: "return value[0] == 0 && value[1] == 0 && value[2] == 0 && value[3] == 0",
+ setFn: function(gl, loc) { gl.uniform4i(loc, 3, 3, 3, 3); }
+},
+{ type: 'bvec2',
+ check: "return value[0] == false && value[1] == false",
+ setFn: function(gl, loc) { gl.uniform2i(loc, 1, 1); }
+},
+{ type: 'bvec3',
+ check: "return value[0] == false && value[1] == false && value[2] == false",
+ setFn: function(gl, loc) { gl.uniform3i(loc, 1, 1, 1); }
+},
+{ type: 'bvec4',
+ check: "return value[0] == false && value[1] == false && value[2] == false && value[3] == false",
+ setFn: function(gl, loc) { gl.uniform4i(loc, 1, 1, 1, 1); }
+},
+{ type: 'mat2',
+ check:
+ "return " +
+ "value[0][0] == 0.0 && value[0][1] == 0.0 && " +
+ "value[1][0] == 0.0 && value[1][0] == 0.0",
+ valueCheck:
+ "return " +
+ "value[0] == 0.0 && value[1] == 0.0 && " +
+ "value[2] == 0.0 && value[3] == 0.0",
+ setFn: function(gl, loc) { gl.uniformMatrix2fv(loc, false, [1, 1, 1, 1]); }
+},
+{ type: 'mat3',
+ check:
+ "return " +
+ "value[0][0] == 0.0 && value[1][0] == 0.0 && value[2][0] == 0.0 && " +
+ "value[0][1] == 0.0 && value[1][1] == 0.0 && value[2][1] == 0.0 && " +
+ "value[0][2] == 0.0 && value[1][2] == 0.0 && value[2][2] == 0.0",
+ valueCheck:
+ "return " +
+ "value[0] == 0.0 && value[1] == 0.0 && value[2] == 0.0 && " +
+ "value[3] == 0.0 && value[4] == 0.0 && value[5] == 0.0 && " +
+ "value[6] == 0.0 && value[7] == 0.0 && value[8] == 0.0",
+ setFn: function(gl, loc) { gl.uniformMatrix3fv(loc, false, [1, 1, 1, 1, 1, 1, 1, 1, 1]); }
+},
+{ type: 'mat4',
+ check:
+ "return " +
+ "value[0][0] == 0.0 && value[1][0] == 0.0 && value[2][0] == 0.0 && value[3][0] == 0.0 && " +
+ "value[0][1] == 0.0 && value[1][1] == 0.0 && value[2][1] == 0.0 && value[3][1] == 0.0 && " +
+ "value[0][2] == 0.0 && value[1][2] == 0.0 && value[2][2] == 0.0 && value[3][2] == 0.0 && " +
+ "value[0][3] == 0.0 && value[1][3] == 0.0 && value[2][3] == 0.0 && value[3][3] == 0.0",
+ valueCheck:
+ "return " +
+ "value[ 0] == 0.0 && value[ 1] == 0.0 && value[ 2] == 0.0 && value[ 3] == 0.0 && " +
+ "value[ 4] == 0.0 && value[ 5] == 0.0 && value[ 6] == 0.0 && value[ 7] == 0.0 && " +
+ "value[ 8] == 0.0 && value[ 9] == 0.0 && value[10] == 0.0 && value[11] == 0.0 && " +
+ "value[12] == 0.0 && value[13] == 0.0 && value[14] == 0.0 && value[15] == 0.0",
+ setFn: function(gl, loc) { gl.uniformMatrix4fv(loc, false, [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]); }
+},
+{ type: 'sampler2D',
+ check:
+ "vec4 v = texture2D(value, vec2(0, 0));" +
+ "return v.x == 1.0 && v.y == 1.0 && v.z == 1.0 && v.w == 1.0",
+ valueCheck:
+ "return value == 0",
+ setFn: function(gl, loc) { gl.uniform1i(loc, 1); }
+},
+{ type: 'samplerCube',
+ check:
+ "vec4 v = textureCube(value, vec3(0, 0, 0));" +
+ "return v.x == 1.0 && v.y == 1.0 && v.z == 1.0 && v.w == 1.0",
+ valueCheck:
+ "return value == 0",
+ setFn: function(gl, loc) { gl.uniform1i(loc, 1); }
+},
+];
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext();
+var c = document.getElementById("console");
+var checkFn;
+
+wtu.setupUnitQuad(gl, [0, 1]);
+
+// Set unit 0 to a non-0 texture.
+var haveVertexTextureImageUnits =
+ gl.getParameter(gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS) >= 2;
+var tex2D = gl.createTexture();
+var texCube = gl.createTexture();
+gl.bindTexture(gl.TEXTURE_2D, tex2D);
+gl.bindTexture(gl.TEXTURE_CUBE_MAP, texCube);
+
+var pixel = new Uint8Array([255, 255, 255, 255]);
+var targets = [
+ gl.TEXTURE_2D,
+ gl.TEXTURE_CUBE_MAP_POSITIVE_X,
+ gl.TEXTURE_CUBE_MAP_NEGATIVE_X,
+ gl.TEXTURE_CUBE_MAP_POSITIVE_Y,
+ gl.TEXTURE_CUBE_MAP_NEGATIVE_Y,
+ gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
+ gl.TEXTURE_CUBE_MAP_NEGATIVE_Z
+];
+for (var ii = 0; ii < targets.length; ++ii) {
+ gl.texImage2D(
+ targets[ii], 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, pixel);
+}
+
+var shaderTemplates = [
+{ vs: "vshader0", fs: "fshader0", type: 'f' },
+{ vs: "vshader1", fs: "fshader1", type: 'v' },
+{ vs: "vshader2", fs: "fshader2", type: 'f' },
+{ vs: "vshader3", fs: "fshader3", type: 'v' },
+];
+
+// Get shader templates
+for (var ii = 0; ii < shaderTemplates.length; ++ii) {
+ var template = shaderTemplates[ii];
+ template.vs = wtu.getScript(template.vs);
+ template.fs = wtu.getScript(template.fs);
+}
+
+function testType(test) {
+ debug("");
+ debug("testing: " + test.type);
+
+ for (var ii = 0; ii < shaderTemplates.length; ++ii) {
+ var template = shaderTemplates[ii];
+
+ if (test.type.substring(0, 7) == "sampler" &&
+ template.type == 'v' &&
+ !haveVertexTextureImageUnits) {
+ continue;
+ }
+
+ var vs = wtu.replaceParams(template.vs, test);
+ var fs = wtu.replaceParams(template.fs, test);
+
+ wtu.addShaderSource(c, "vertex shader", vs);
+ wtu.addShaderSource(c, "fragment shader", fs);
+
+ var vs = wtu.loadShader(gl, vs, gl.VERTEX_SHADER);
+ var fs = wtu.loadShader(gl, fs, gl.FRAGMENT_SHADER);
+ var program = wtu.createProgram(gl, vs, fs);
+
+ gl.useProgram(program);
+
+ var loc = gl.getUniformLocation(program, "u_uniform[1]");
+ if (!loc) {
+ var loc = gl.getUniformLocation(program, "u_uniform");
+ }
+
+ var value = gl.getUniform(program, loc);
+ TestEval("checkFn = function(value) {" + (test.valueCheck ? test.valueCheck : test.check) + ";}");
+ if (checkFn(value)) {
+ testPassed("uniform is zero");
+ } else {
+ testFailed("uniform is not zero");
+ }
+
+ debug("default value should be zero");
+ wtu.clearAndDrawUnitQuad(gl);
+ wtu.checkCanvas(gl, [0, 255, 0, 255], "should be green", 0);
+
+ debug("test test by setting value");
+ test.setFn(gl, loc);
+
+ wtu.clearAndDrawUnitQuad(gl);
+ wtu.checkCanvas(gl, [255, 0, 0, 255], "should be red", 0);
+
+ debug("re-linking should reset to defaults");
+ gl.linkProgram(program);
+
+ wtu.clearAndDrawUnitQuad(gl);
+ wtu.checkCanvas(gl, [0, 255, 0, 255], "should be green", 0);
+
+ gl.deleteProgram(program);
+ gl.deleteShader(vs);
+ gl.deleteShader(fs);
+
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be no GL errors");
+ }
+}
+
+var testNdx = 0;
+function runNextTest() {
+ testType(tests[testNdx++]);
+ if (testNdx >= tests.length) {
+ finishTest();
+ } else {
+ setTimeout(runNextTest, 0);
+ }
+}
+
+runNextTest();
+
+var successfullyParsed = true;
+
+</script>
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/uniform-location.html b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/uniform-location.html
new file mode 100644
index 0000000000..3b1c185caf
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/uniform-location.html
@@ -0,0 +1,96 @@
+<!--
+Copyright (c) 2019 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"></script>
+</head>
+<body>
+<div id="description"></div>
+<div id="console"></div>
+
+<script>
+"use strict";
+description("Tests the WebGLUniformLocation API");
+
+var wtu = WebGLTestUtils;
+var contextA = wtu.create3DContext();
+var contextB = wtu.create3DContext();
+var programA1 = wtu.loadStandardProgram(contextA);
+var programA2 = wtu.loadStandardProgram(contextA);
+var programB = wtu.loadStandardProgram(contextB);
+var programS = wtu.loadProgramFromFile(contextA, "../../resources/structUniformShader.vert", "../../resources/fragmentShader.frag");
+var programV = wtu.loadProgramFromFile(contextA, "../../resources/floatUniformShader.vert", "../../resources/noopUniformShader.frag");
+var locationA = contextA.getUniformLocation(programA1, 'u_modelViewProjMatrix');
+var locationB = contextB.getUniformLocation(programB, 'u_modelViewProjMatrix');
+var locationSx = contextA.getUniformLocation(programS, "u_struct.x");
+var locationSx2;
+var locationArray0 = contextA.getUniformLocation(programS, "u_array[0]");
+var locationArray1 = contextA.getUniformLocation(programS, "u_array[1]");
+var locationVec4 = contextA.getUniformLocation(programV, "fval4");
+
+var vec = [1, 2, 3, 4];
+var mat = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16];
+
+wtu.shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.useProgram(programA2)");
+wtu.shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.uniformMatrix4fv(locationA, false, mat)");
+wtu.shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.useProgram(programA1)");
+wtu.shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniformMatrix4fv(locationA, false, mat)");
+wtu.shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniformMatrix4fv(null, false, mat)");
+
+wtu.shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.useProgram(programS)");
+wtu.shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniform1i(locationSx, 333)");
+wtu.shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniform1f(locationArray0, 4.0)");
+wtu.shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniform1f(locationArray1, 5.0)");
+
+shouldBe("contextA.getUniform(programS, locationSx)", "333");
+shouldBe("contextA.getUniform(programS, locationArray0)", "4.0");
+shouldBe("contextA.getUniform(programS, locationArray1)", "5.0");
+
+wtu.shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.useProgram(programV)");
+wtu.shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniform4fv(locationVec4, vec)");
+shouldBe("contextA.getUniform(programV, locationVec4)", "vec");
+
+shouldBeNull("contextA.getUniformLocation(programV, \"IDontExist\")");
+wtu.shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.linkProgram(programA1)");
+// After linking all boxes are bad.
+wtu.shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.uniformMatrix4fv(locationA, false, mat)");
+
+// after re-linking the same program, all uniform locations become invalid.
+wtu.shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.useProgram(programS)");
+contextA.stencilMask(1);
+wtu.shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.linkProgram(programS)");
+wtu.shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.uniform1i(locationSx, 3)");
+wtu.shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.getUniform(programS, locationSx)");
+
+// Retrieve the locations again, and they should be good.
+locationSx = contextA.getUniformLocation(programS, "u_struct.x");
+locationArray0 = contextA.getUniformLocation(programS, "u_array[0]");
+debug("here");
+contextA.stencilMask(0);
+wtu.shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniform1i(locationSx, 3)");
+wtu.shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniform1f(locationArray0, 123)");
+shouldBe("contextA.getUniform(programS, locationSx)", "3");
+shouldBe("contextA.getUniform(programS, locationArray0)", "123");
+
+// getUniformLocation should return a different object everytime, should not cache and return the same object
+debug("Testing that getUniformLocation returns a different object everytime");
+locationSx = contextA.getUniformLocation(programS, "u_struct.x");
+locationSx2 = contextA.getUniformLocation(programS, "u_struct.x");
+shouldBeFalse("locationSx === locationSx2");
+locationSx.foo = {};
+locationSx2.foo = {};
+shouldBeFalse("locationSx.foo === locationSx2.foo");
+
+var successfullyParsed = true;
+</script>
+
+<script src="../../js/js-test-post.js"></script>
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/uniform-samplers-test.html b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/uniform-samplers-test.html
new file mode 100644
index 0000000000..fc680c0eaa
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/uniform-samplers-test.html
@@ -0,0 +1,111 @@
+<!--
+Copyright (c) 2019 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL sampler uniforms conformance test.</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"></script>
+</head>
+<body>
+<canvas id="example" width="2" height="2" style="width: 40px; height: 40px;"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+
+<script>
+"use strict";
+function init()
+{
+ description(
+ "Tests that only Uniform1i and Uniform1iv can be used to set" +
+ "sampler uniforms.");
+
+ var canvas2d = document.getElementById("canvas2d");
+
+ var wtu = WebGLTestUtils;
+ var gl = wtu.create3DContext("example");
+ var program = wtu.setupTexturedQuad(gl);
+
+ var textureLoc = gl.getUniformLocation(program, "tex");
+
+ gl.uniform1i(textureLoc, 1);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR,
+ "uniform1i can set a sampler uniform");
+ gl.uniform1iv(textureLoc, [1]);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR,
+ "uniform1iv can set a sampler uniform");
+ gl.uniform1f(textureLoc, 1);
+ wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION,
+ "uniform1f returns INVALID_OPERATION if attempting to set a sampler uniform");
+ gl.uniform1fv(textureLoc, [1]);
+ wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION,
+ "uniform1fv returns INVALID_OPERATION if attempting to set a sampler uniform");
+
+ var maxTextureUnits = gl.getParameter(gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
+
+ var testUniformi = function() {
+ var success = true;
+ for (var ii = 0; ii < maxTextureUnits; ++ii) {
+ gl.uniform1i(textureLoc, ii);
+ success = success && (gl.getError() == gl.NO_ERROR);
+ }
+ expectTrue(success, "uniform1i works for any valid texture unit");
+ };
+
+ var testUniformiv = function() {
+ var success = true;
+ for (var ii = 0; ii < maxTextureUnits; ++ii) {
+ gl.uniform1iv(textureLoc, [ii]);
+ success = success && (gl.getError() == gl.NO_ERROR);
+ }
+ expectTrue(success, "uniform1iv works for any valid texture unit");
+ };
+
+ var steps = [
+ testUniformi,
+ testUniformiv,
+ ];
+
+ var generateInvalidUniformiTests = function(start, end) {
+ return function() {
+ var success = true;
+ for (var ii = start; ii < end; ++ii) {
+ gl.uniform1i(textureLoc, ii);
+ success = success && (gl.getError() == gl.INVALID_VALUE);
+ }
+ expectTrue(success, "uniform1i generates INVALID_VALUE for invalid texture units 0x" + start.toString(16) + " to 0x" + end.toString(16));
+ };
+ };
+
+ var generateInvalidUniformivTests = function(start, end) {
+ return function() {
+ var success = true;
+ for (var ii = start; ii < end; ++ii) {
+ gl.uniform1iv(textureLoc, [ii]);
+ success = success && (gl.getError() == gl.INVALID_VALUE);
+ }
+ expectTrue(success, "uniform1iv generates INVALID_VALUE for invalid texture units 0x" + start.toString(16) + " to 0x" + end.toString(16));
+ };
+ };
+
+ var step = 0x1000;
+ for (var ii = maxTextureUnits; ii < 0x10000; ii += step) {
+ steps.push(generateInvalidUniformiTests(ii, ii + step));
+ steps.push(generateInvalidUniformivTests(ii, ii + step));
+ }
+
+ steps.push(finishTest);
+ wtu.runSteps(steps);
+}
+
+init();
+var successfullyParsed = true;
+</script>
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/uniform-values-per-program.html b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/uniform-values-per-program.html
new file mode 100644
index 0000000000..6ff693f347
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/uniforms/uniform-values-per-program.html
@@ -0,0 +1,179 @@
+<!--
+Copyright (c) 2019 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
+-->
+
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>WebGL uniform values are per program conformance test.</title>
+<link rel="stylesheet" href="../../resources/js-test-style.css"/>
+<script src="../../js/js-test-pre.js"></script>
+<script src="../../js/webgl-test-utils.js"></script>
+</head>
+<body>
+<script id="vshader" type="x-shader/x-vertex">
+attribute vec4 a_position;
+void main() {
+ gl_Position = a_position;
+}
+</script>
+<script id="fshader" type="x-shader/x-fragment">
+precision mediump float;
+varying vec4 v_color;
+void main() {
+ gl_FragColor = v_color;
+}
+</script>
+<script id="vshaderTest" type="x-shader/x-vertex">
+attribute vec4 a_position;
+uniform $(type) $(name1);
+uniform $(type) $(name2);
+uniform bool u_select;
+varying vec4 v_color;
+void main() {
+ $(type) value = u_select ? $(name2) : $(name1);
+ v_color = $(conversion);
+ gl_Position = a_position;
+}
+</script>
+<script id="fshaderTest" type="x-shader/x-fragment">
+precision mediump float;
+uniform $(type) $(name1);
+uniform $(type) $(name2);
+uniform bool u_select;
+void main() {
+ $(type) value = u_select ? $(name2) : $(name1);
+ gl_FragColor = $(conversion);
+}
+</script>
+<canvas id="example" width="2" height="2" style="width: 40px; height: 40px;"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+"use strict";
+function init() {
+ description();
+
+ var console = document.getElementById("console");
+ var wtu = WebGLTestUtils;
+ var gl = wtu.create3DContext("example");
+ wtu.setupUnitQuad(gl);
+ var vtemplate = wtu.getScript("vshader");
+ var ftemplate = wtu.getScript("fshader");
+ var vtemplateTest = wtu.getScript("vshaderTest");
+ var ftemplateTest = wtu.getScript("fshaderTest");
+
+ var shaders = [
+ [vtemplate, ftemplateTest],
+ [vtemplateTest, ftemplate],
+ ];
+
+ var names = [
+ ["u_value1", "u_value2"],
+ ["a", "b"],
+ ["x", "y"],
+ ["y", "z"],
+ ["y", "u"],
+ ["a00000", "a00001"],
+ ];
+ var testList = [
+ { type: "float",
+ conversion: "vec4(value, 0, 0, 0)",
+ values: [[64], [128]],
+ func: 'uniform1fv',
+ },
+ { type: "vec2",
+ conversion: "vec4(value, 0, 0)",
+ values: [[64, 128], [128, 64]],
+ func: 'uniform2fv',
+ },
+ { type: "vec3",
+ conversion: "vec4(value, 0)",
+ values: [[64, 128, 192], [192, 128, 64]],
+ func: 'uniform3fv',
+ },
+ { type: "vec4",
+ conversion: "vec4(value)",
+ values: [[64, 128, 192, 255], [255, 192, 128, 64]],
+ func: 'uniform4fv',
+ },
+ ];
+
+ var clone = function(obj) {
+ var n = { };
+ for (var $key in obj) {
+ n[$key] = obj[$key];
+ }
+ return n;
+ };
+
+ var tests = [];
+ names.forEach(function(namePair) {
+ testList.forEach(function(test) {
+ var t = clone(test);
+ t.name1 = namePair[0];
+ t.name2 = namePair[1];
+ tests.push(t);
+ });
+ });
+
+ var runTest = function(test) {
+ debug("");
+ debug("testing: " + test.type);
+ shaders.forEach(function(shaderPair) {
+ var progs = [];
+ for (var ii = 0; ii < 2; ++ii) {
+ var vsource = wtu.replaceParams(shaderPair[0], test);
+ var fsource = wtu.replaceParams(shaderPair[1], test);
+ if (!ii) {
+ wtu.addShaderSource(console, "vertex shader: type = " + test.type + " with names " + test.name1 + ", " + test.name2, vsource);
+ wtu.addShaderSource(console, "fragment shader: type = " + test.type + " with names " + test.name1 + ", " + test.name2, fsource);
+ }
+ var program = wtu.setupProgram(gl, [vsource, fsource], ["a_position"]);
+ var info = {
+ program: program,
+ valueLocs: [gl.getUniformLocation(program, test.name1),
+ gl.getUniformLocation(program, test.name2)],
+ selectLoc: gl.getUniformLocation(program, "u_select"),
+ };
+ var v1 = test.values[0];
+ var v2 = test.values[1];
+ if (ii) {
+ var t = v1;
+ v1 = v2;
+ v2 = t;
+ }
+ info.expect = [v1, v2];
+ for (var jj = 0; jj < 2; ++jj) {
+ var input = info.expect[jj].map(function(v) { return v / 255; });
+ gl[test.func](info.valueLocs[jj], input);
+ }
+ progs.push(info);
+ }
+ for (var ii = 0; ii < 2; ++ii) {
+ progs.forEach(function(info) {
+ gl.useProgram(info.program);
+ gl.uniform1i(info.selectLoc, ii);
+ wtu.clearAndDrawUnitQuad(gl);
+ wtu.checkCanvas(gl, info.expect[ii], undefined, 1);
+ });
+ }
+ progs.forEach(function(info) {
+ gl.deleteProgram(info.program);
+ });
+ });
+ }
+ tests.forEach(function(test){
+ runTest(test);
+ });
+}
+init();
+var successfullyParsed = true;
+</script>
+<script src="../../js/js-test-post.js"></script>
+</body>
+</html>
+