summaryrefslogtreecommitdiffstats
path: root/dom/canvas/test/webgl-conf/checkout/conformance/buffers
diff options
context:
space:
mode:
Diffstat (limited to 'dom/canvas/test/webgl-conf/checkout/conformance/buffers')
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/buffers/00_test_list.txt14
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/buffers/buffer-bind-test.html66
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/buffers/buffer-data-and-buffer-sub-data.html203
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/buffers/buffer-data-array-buffer-delete.html63
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/buffers/buffer-data-dynamic-delay.html114
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/buffers/buffer-uninitialized.html104
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/buffers/element-array-buffer-delete-recreate.html69
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/buffers/index-validation-copies-indices.html56
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/buffers/index-validation-crash-with-buffer-sub-data.html38
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/buffers/index-validation-large-buffer.html56
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/buffers/index-validation-verifies-too-many-indices.html50
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/buffers/index-validation-with-resized-buffer.html107
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/buffers/index-validation.html119
-rw-r--r--dom/canvas/test/webgl-conf/checkout/conformance/buffers/vertex-buffer-updated-after-draw.html94
14 files changed, 1153 insertions, 0 deletions
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/buffers/00_test_list.txt b/dom/canvas/test/webgl-conf/checkout/conformance/buffers/00_test_list.txt
new file mode 100644
index 0000000000..d6f6af332f
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/buffers/00_test_list.txt
@@ -0,0 +1,14 @@
+buffer-bind-test.html
+buffer-data-and-buffer-sub-data.html
+--min-version 1.0.3 buffer-data-array-buffer-delete.html
+--min-version 1.0.4 buffer-data-dynamic-delay.html
+--min-version 1.0.4 buffer-uninitialized.html
+--min-version 1.0.2 element-array-buffer-delete-recreate.html
+index-validation-copies-indices.html
+index-validation-crash-with-buffer-sub-data.html
+--min-version 1.0.2 index-validation-large-buffer.html
+index-validation-verifies-too-many-indices.html
+index-validation-with-resized-buffer.html
+index-validation.html
+--min-version 1.0.4 vertex-buffer-updated-after-draw.html
+
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/buffers/buffer-bind-test.html b/dom/canvas/test/webgl-conf/checkout/conformance/buffers/buffer-bind-test.html
new file mode 100644
index 0000000000..b0f1fd7a38
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/buffers/buffer-bind-test.html
@@ -0,0 +1,66 @@
+<!--
+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 BindBuffer 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="40" height="40" style="width: 40px; height: 40px;"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+"use strict";
+description("Checks a buffer can only be bound to 1 target.");
+
+debug("");
+debug("Canvas.getContext");
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+if (!gl) {
+ testFailed("context does not exist");
+} else {
+ testPassed("context exists");
+
+ debug("");
+
+ var buf = gl.createBuffer();
+ gl.bindBuffer(gl.ARRAY_BUFFER, buf);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR,
+ "should be able to bind array buffer.");
+ gl.bindBuffer(gl.ARRAY_BUFFER, null);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR,
+ "should be able to unbind array buffer.");
+ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, buf);
+ wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION,
+ "should get INVALID_OPERATION if attempting to bind array buffer to different target");
+
+ var buf = gl.createBuffer();
+ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, buf);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR,
+ "should be able to bind element array buffer.");
+ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR,
+ "should be able to unbind element array buffer.");
+ gl.bindBuffer(gl.ARRAY_BUFFER, buf);
+ wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION,
+ "should get INVALID_OPERATION if attempting to bind element array buffer to different target");
+}
+
+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/buffers/buffer-data-and-buffer-sub-data.html b/dom/canvas/test/webgl-conf/checkout/conformance/buffers/buffer-data-and-buffer-sub-data.html
new file mode 100644
index 0000000000..f3c2658a22
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/buffers/buffer-data-and-buffer-sub-data.html
@@ -0,0 +1,203 @@
+<!--
+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("Test bufferData/bufferSubData with or without ArrayBuffer input");
+
+debug('Regression test for <a href="https://bugs.webkit.org/show_bug.cgi?id=41884">https://bugs.webkit.org/show_bug.cgi?id=41884</a> : <code>Implement bufferData and bufferSubData with ArrayBuffer as input</code>');
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext();
+if (!gl) {
+ testFailed("WebGL context does not exist");
+} else {
+ testPassed("WebGL context exists");
+
+ bufferDataTest();
+ bufferDataSizesTest();
+
+ bufferSubDataTest();
+}
+
+function bufferDataTest() {
+ debug("");
+ debug("Test bufferData without ArrayBuffer input");
+
+ var buf = gl.createBuffer();
+ shouldBeNonNull(buf);
+
+ gl.bufferData(gl.ARRAY_BUFFER, 4, gl.STATIC_DRAW);
+ wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "no buffer bound");
+
+ gl.bindBuffer(gl.ARRAY_BUFFER, buf);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+
+ gl.bufferData(gl.ARRAY_BUFFER, -4, gl.STATIC_DRAW);
+ wtu.glErrorShouldBe(gl, gl.INVALID_VALUE,
+ "calling bufferData when buffer size is negative should generate INVALID_VALUE");
+
+ gl.bufferData(gl.ARRAY_BUFFER, null, gl.STATIC_DRAW);
+ wtu.glErrorShouldBe(gl, gl.INVALID_VALUE,
+ "calling bufferData when BufferDataSource is null should generate INVALID_VALUE");
+
+ gl.bufferData(gl.ARRAY_BUFFER, undefined, gl.STATIC_DRAW);
+ wtu.glErrorShouldBe(gl, gl.INVALID_VALUE,
+ "calling bufferData when BufferDataSource is undefined should generate INVALID_VALUE");
+
+ gl.bindBuffer(gl.ARRAY_BUFFER, null);
+}
+
+function bufferDataSizesTest() {
+ debug("");
+ debug("Test bufferData overloads");
+
+ // bufferData has an integer overload and an ArrayBuffer overload.
+ // Per the WebIDL spec, the overload resolution algorithm should resolve types as follows:
+ // - If the argument is null or undefined, pick the nullable type, which is ArrayBuffer.
+ // Per the WebGL spec, null should flag INVALID_VALUE.
+ // - If the argument is an ArrayBuffer, then pick the ArrayBuffer overload
+ // - Everything else should pick the numeric overload. This means things like objects, strings,
+ // floating point numbers, arrays of numbers and strings, etc should convert themselves to a number.
+ var bufferDataParams = [
+ { parameter: 0, expectedBufferSize: 0 },
+ { parameter: 4, expectedBufferSize: 4 },
+ { parameter: 5.1, expectedBufferSize: 5 },
+ { parameter: 5.8, expectedBufferSize: 5 },
+ { parameter: 5.5, expectedBufferSize: 5 },
+
+ { parameter: "4", expectedBufferSize: 4 },
+ { parameter: "5.1", expectedBufferSize: 5 },
+ { parameter: "5.8", expectedBufferSize: 5 },
+ { parameter: "5.5", expectedBufferSize: 5 },
+ { parameter: "0", expectedBufferSize: 0 },
+
+ { parameter: [42, 64], expectedBufferSize: 0 },
+ { parameter: [42], expectedBufferSize: 42 },
+ { parameter: ["42"], expectedBufferSize: 42 },
+ { parameter: ["42", "64"], expectedBufferSize: 0 },
+
+ { parameter: new ArrayBuffer(0), expectedBufferSize: 0 },
+ { parameter: new ArrayBuffer(4), expectedBufferSize: 4 },
+ { parameter: new Uint8Array(new ArrayBuffer(5)), expectedBufferSize: 5 },
+ { parameter: new DataView(new ArrayBuffer(7)), expectedBufferSize: 7 },
+
+ { parameter: "WebGL Rocks!", expectedBufferSize: 0 },
+ { parameter: { mystring: "WebGL Rocks!" }, expectedBufferSize: 0 },
+ ];
+
+ if (window.SharedArrayBuffer) {
+ bufferDataParams.push(
+ { parameter: new SharedArrayBuffer(3), expectedBufferSize: 3 },
+ { parameter: new Uint8Array(new SharedArrayBuffer(6)), expectedBufferSize: 6 },
+ { parameter: new DataView(new SharedArrayBuffer(8)), expectedBufferSize: 8 }
+ );
+ }
+
+ bufferDataParams.forEach(function (bufferDataParam) {
+ var buffer = gl.createBuffer();
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
+ gl.bufferData(gl.ARRAY_BUFFER, bufferDataParam.parameter, gl.STATIC_DRAW);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Passing " + bufferDataParam.parameter + " to bufferData");
+
+ shouldEvaluateTo("gl.getBufferParameter(gl.ARRAY_BUFFER, gl.BUFFER_SIZE)", bufferDataParam.expectedBufferSize);
+ });
+
+ gl.bindBuffer(gl.ARRAY_BUFFER, null);
+}
+
+function bufferSubDataTest() {
+ debug("");
+ debug("Test bufferSubData");
+
+ var buf = gl.createBuffer();
+ gl.bindBuffer(gl.ARRAY_BUFFER, buf);
+
+ gl.bufferSubData(gl.ARRAY_BUFFER, 0, new ArrayBuffer(1));
+ wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "Calling bufferSubData before bufferData should fail");
+
+ gl.bufferData(gl.ARRAY_BUFFER, 128, gl.STATIC_DRAW);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+
+ var array = new ArrayBuffer(64);
+
+ gl.bufferSubData(gl.ARRAY_BUFFER, -10, array);
+ wtu.glErrorShouldBe(gl, gl.INVALID_VALUE,
+ "calling bufferSubData with ArrayBuffer when offset is negative should INVALID_VALUE");
+
+ gl.bufferSubData(gl.ARRAY_BUFFER, 65, array);
+ wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "buffer overflow");
+
+ gl.bufferSubData(gl.ARRAY_BUFFER, -10, new Float32Array(8));
+ wtu.glErrorShouldBe(gl, gl.INVALID_VALUE,
+ "calling bufferSubData with ArrayBufferView when offset is negative should generate INVALID_VALUE");
+
+ gl.bufferSubData(gl.ARRAY_BUFFER, 10, array);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR,
+ "calling bufferSubData with ArrayBuffer should succeed");
+
+ gl.bufferSubData(gl.ARRAY_BUFFER, 10, new Float32Array(0));
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR,
+ "calling bufferSubData with zero-sized ArrayBufferView should succeed");
+
+ // Arguments that are not ArrayBuffers, null or undefined should throw a TypeError exception
+ shouldThrow("gl.bufferSubData(gl.ARRAY_BUFFER, 0, 42);");
+ shouldThrow("gl.bufferSubData(gl.ARRAY_BUFFER, 0, 5.5);");
+ shouldThrow("gl.bufferSubData(gl.ARRAY_BUFFER, 0, \"5.5\");");
+ shouldThrow("gl.bufferSubData(gl.ARRAY_BUFFER, 0, [4]);");
+ shouldThrow("gl.bufferSubData(gl.ARRAY_BUFFER, 0, { mynumber: 42});");
+ shouldThrow("gl.bufferSubData(gl.ARRAY_BUFFER, 10, null)");
+ shouldThrow("gl.bufferSubData(gl.ARRAY_BUFFER, 10, undefined)");
+
+ if (window.SharedArrayBuffer) {
+ const validDatas = [
+ 'new SharedArrayBuffer(3)',
+ 'new Uint8Array(new SharedArrayBuffer(3))',
+ 'new DataView(new SharedArrayBuffer(3))',
+ ];
+ for (const x of validDatas) {
+ shouldNotThrow(`gl.bufferSubData(gl.ARRAY_BUFFER, 0, ${x})`);
+ }
+ }
+
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should generate no GL error");
+
+ // -
+ // Firefox bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1611837
+
+ gl.bindBuffer(gl.ARRAY_BUFFER, null);
+ gl.bufferSubData(gl.ARRAY_BUFFER, 0, new ArrayBuffer(0));
+ wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION,
+ "Calling bufferSubData with empty ArrayBuffer and null WebGLBuffer should fail");
+
+ gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());
+ gl.bufferSubData(gl.ARRAY_BUFFER, 0, new ArrayBuffer(0));
+ wtu.glErrorShouldBe(gl, 0,
+ "Calling bufferSubData with empty ArrayBuffer and non-null WebGLBuffer should succeed");
+
+ // -
+
+ gl.bindBuffer(gl.ARRAY_BUFFER, 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/buffers/buffer-data-array-buffer-delete.html b/dom/canvas/test/webgl-conf/checkout/conformance/buffers/buffer-data-array-buffer-delete.html
new file mode 100644
index 0000000000..4a25426f0c
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/buffers/buffer-data-array-buffer-delete.html
@@ -0,0 +1,63 @@
+<!--
+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("Test ARRAY_BUFFER deletion when a vertex attrib array with location != 0 is pointing to it and preserveDrawingBuffer is true.");
+
+var canvas = document.createElement('canvas');
+document.body.appendChild(canvas);
+
+canvas.addEventListener(
+ "webglcontextlost",
+ function(event) {
+ testFailed("Context lost");
+ event.preventDefault();
+ },
+ false);
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext(canvas, {preserveDrawingBuffer: true});
+
+if (!gl) {
+ testFailed("context does not exist");
+ finishTest();
+} else {
+ var array = new Float32Array([0]);
+ var buf = gl.createBuffer();
+ gl.bindBuffer(gl.ARRAY_BUFFER, buf);
+ gl.bufferData(gl.ARRAY_BUFFER, array, gl.STATIC_DRAW);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+
+ var attribLocation = 1;
+ gl.enableVertexAttribArray(attribLocation);
+ gl.vertexAttribPointer(attribLocation, 1, gl.FLOAT, false, 0, 0);
+
+ gl.deleteBuffer(buf);
+
+ setTimeout(function() {
+ // Wait for possible context loss
+ finishTest();
+ }, 2000);
+}
+
+var successfullyParsed = true;
+</script>
+
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/buffers/buffer-data-dynamic-delay.html b/dom/canvas/test/webgl-conf/checkout/conformance/buffers/buffer-data-dynamic-delay.html
new file mode 100644
index 0000000000..8e41a687bb
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/buffers/buffer-data-dynamic-delay.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>bufferData with DYNAMIC_DRAW and delay between updating data</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="canvas" width="50" height="50"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+
+<script id="vshader" type="x-shader/x-vertex">
+ attribute vec2 a_position;
+ attribute vec2 a_color;
+ varying vec2 v_color;
+ void main()
+ {
+ gl_Position = vec4(a_position, 0.0, 1.0);
+ v_color = a_color;
+ }
+</script>
+<script id="fshader" type="x-shader/x-fragment">
+ precision mediump float;
+ varying vec2 v_color;
+ void main()
+ {
+ gl_FragColor = vec4(v_color, 0.0, 1.0);
+ }
+</script>
+
+<script>
+"use strict";
+description("Verifies that bufferData with DYNAMIC_DRAW updates the vertex attribute when there is a significant delay between updating the buffer.");
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("canvas");
+var program = wtu.setupProgram(gl, ["vshader", "fshader"], ["a_position", "a_color"]);
+
+// Initialize position vertex attribute to draw a square covering the entire canvas.
+var positionBuffer = gl.createBuffer();
+gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer);
+gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
+ -1.0, 1.0,
+ 1.0, 1.0,
+ -1.0, -1.0,
+ 1.0, -1.0
+ ]), gl.DYNAMIC_DRAW);
+gl.enableVertexAttribArray(0);
+gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);
+
+// Initialize color vertex attribute to red.
+var colorBuffer = gl.createBuffer();
+gl.bindBuffer(gl.ARRAY_BUFFER, colorBuffer);
+gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
+ 1.0, 0.0,
+ 1.0, 0.0,
+ 1.0, 0.0,
+ 1.0, 0.0,
+ ]), gl.DYNAMIC_DRAW);
+gl.enableVertexAttribArray(1);
+gl.vertexAttribPointer(1, 2, gl.FLOAT, false, 0, 0);
+
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "No error after setup");
+
+// Fill the canvas with red
+gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "No error after first drawArrays");
+
+wtu.checkCanvasRect(gl, 0, 0, 50, 50, [255, 0, 0, 255], "Canvas should be red after the first drawArrays");
+
+// With the buffer set to DYNAMIC_DRAW, Angle internally changes the storage type of the vertex attribute from DYNAMIC to DIRECT
+// if the buffer has not been updated after ~4-5 draw calls. When the buffer is eventually updated, the vertex attribute
+// is updated back to DYNAMIC, but there was a bug in Angle where the data is not marked as dirty. The result is that the
+// vertex data is not updated with the new buffer data. This test verifies that the vertex data is updated.
+var iteration = 0;
+function draw() {
+ // Draw 10 times to ensure that the vertex attribute storage type is changed.
+ if (iteration < 10) {
+ gl.drawArrays(gl.TRIANGLE_STRIP, 0, 2);
+ requestAnimationFrame(draw);
+ }
+ else {
+ // Update the buffer bound to the color vertex attribute to green and draw.
+ gl.bindBuffer(gl.ARRAY_BUFFER, colorBuffer);
+ gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
+ 0.0, 1.0,
+ 0.0, 1.0,
+ 0.0, 1.0,
+ 0.0, 1.0,
+ ]), gl.DYNAMIC_DRAW);
+ gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "No error after last drawArrays");
+
+ wtu.checkCanvasRect(gl, 0, 0, 50, 50, [0, 255, 0, 255], "Canvas should be green after 10 frames");
+
+ finishTest();
+ }
+
+ iteration++;
+}
+
+requestAnimationFrame(draw);
+
+</script>
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/buffers/buffer-uninitialized.html b/dom/canvas/test/webgl-conf/checkout/conformance/buffers/buffer-uninitialized.html
new file mode 100644
index 0000000000..75282f3674
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/buffers/buffer-uninitialized.html
@@ -0,0 +1,104 @@
+<!--
+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>
+
+<canvas id="canvas" width="1" height="1"></canvas>
+
+<script id="vshader" type="x-shader/x-vertex">
+attribute float a_vertex;
+void main()
+{
+ gl_Position = a_vertex == 0.0 ? vec4(9, 9, 9, 1) : vec4(0.5, 0.5, 0.5, 1);
+}
+</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 uninitialized WebGLBuffers are zeroed out");
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext(document.getElementById("canvas"));
+var program = wtu.setupProgram(gl, ["vshader", "fshader"], ["a_vertex"]);
+shouldBeTrue("program != null");
+
+var TEST_LENGTH = 1024;
+var TEST_BUFSIZE = TEST_LENGTH * 4;
+var data = new Float32Array(TEST_LENGTH / 4); // this array is zeroed
+
+var indices = new Uint16Array(TEST_LENGTH);
+for (var i = 0; i < TEST_LENGTH; i++) {
+ indices[i] = i;
+}
+
+gl.clearColor(0, 1, 0, 1);
+
+function test(initFunction) {
+ var uninitializedBuffer = gl.createBuffer();
+ gl.bindBuffer(gl.ARRAY_BUFFER, uninitializedBuffer);
+ initFunction();
+
+ var elements = gl.createBuffer();
+ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, elements);
+ gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW);
+
+ gl.useProgram(program);
+ var vertexLoc = gl.getAttribLocation(program, "a_vertex");
+ gl.vertexAttribPointer(vertexLoc, 1, gl.FLOAT, gl.FALSE, 0, 0);
+ gl.enableVertexAttribArray(vertexLoc);
+
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "no error should result from setup");
+
+ gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
+ gl.drawElements(gl.POINTS, TEST_LENGTH, gl.UNSIGNED_SHORT, 0);
+ wtu.checkCanvasRect(gl, 0, 0, 1, 1, [0, 255, 0, 255], "buffer should be initialized to zero");
+
+ gl.deleteBuffer(uninitializedBuffer);
+}
+
+var REPETITIONS = 50;
+
+var j;
+debug("");
+debug("testing bufferData(..., size, ...)");
+for (j = 0; j < REPETITIONS; j++) {
+ test(function() {
+ gl.bufferData(gl.ARRAY_BUFFER, TEST_BUFSIZE, gl.STATIC_DRAW);
+ });
+}
+
+debug("");
+debug("testing bufferSubData(..., offset, data) of uninitialized buffer");
+for (j = 0; j < REPETITIONS; j++) {
+ test(function() {
+ gl.bufferData(gl.ARRAY_BUFFER, TEST_BUFSIZE, gl.STATIC_DRAW);
+ // bufferSubData the second quarter of the buffer
+ gl.bufferSubData(gl.ARRAY_BUFFER, TEST_BUFSIZE / 4, data);
+ });
+}
+
+var successfullyParsed = true;
+</script>
+
+<script src="../../js/js-test-post.js"></script>
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/buffers/element-array-buffer-delete-recreate.html b/dom/canvas/test/webgl-conf/checkout/conformance/buffers/element-array-buffer-delete-recreate.html
new file mode 100644
index 0000000000..d4fb81af9b
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/buffers/element-array-buffer-delete-recreate.html
@@ -0,0 +1,69 @@
+<!--
+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>Element Array Buffer Deletion and Recreation 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="32" height="32"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+<script>
+"use strict";
+var wtu = WebGLTestUtils;
+function init()
+{
+ description();
+
+ // Clear the background with red.
+ var gl = wtu.create3DContext("example");
+ wtu.setupSimpleColorProgram(gl);
+ var color = [0, 255, 0, 255];
+ wtu.setUByteDrawColor(gl, color);
+
+ var vertexBuffer = gl.createBuffer();
+ gl.bindBuffer(gl.ARRAY_BUFFER, vertexBuffer);
+ gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
+ -1, -1,
+ 1, -1,
+ -1, 1,
+ 1, 1
+ ]), gl.STATIC_DRAW);
+ gl.enableVertexAttribArray(0);
+ gl.vertexAttribPointer(0, 2, gl.FLOAT, false, 0, 0);
+
+ // Create an element array buffer.
+ var indexBuffer = gl.createBuffer();
+ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
+ gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint8Array([0, 1, 2, 3]), gl.STATIC_DRAW);
+
+ // Delete the element array buffer.
+ gl.deleteBuffer(indexBuffer);
+
+ // Create a new element array buffer.
+ indexBuffer = gl.createBuffer();
+ gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexBuffer);
+ gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint8Array([0, 1, 2, 3]), gl.STATIC_DRAW);
+
+ // Draw with the new element array buffer.
+ // If the geometry is drawn successfully, the fragment shader will color it green.
+ gl.drawElements(gl.TRIANGLE_STRIP, 4, gl.UNSIGNED_BYTE, 0);
+
+ wtu.glErrorShouldBe(gl, gl.NO_ERROR, "no errors from draw");
+ wtu.checkCanvas(gl, color, "should be green")
+}
+
+init();
+var successfullyParsed = true;
+</script>
+<script src="../../js/js-test-post.js"></script>
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/buffers/index-validation-copies-indices.html b/dom/canvas/test/webgl-conf/checkout/conformance/buffers/index-validation-copies-indices.html
new file mode 100644
index 0000000000..e823f95f69
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/buffers/index-validation-copies-indices.html
@@ -0,0 +1,56 @@
+<!--
+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('Test that client data is always copied during bufferData and bufferSubData calls, because otherwise the data the GL uses to draw may differ from that checked by the index validation code.')
+
+var wtu = WebGLTestUtils;
+var context = wtu.create3DContext();
+var program = wtu.loadStandardProgram(context);
+
+context.useProgram(program);
+var vertexObject = context.createBuffer();
+context.enableVertexAttribArray(0);
+context.bindBuffer(context.ARRAY_BUFFER, vertexObject);
+// 4 vertices -> 2 triangles
+context.bufferData(context.ARRAY_BUFFER, new Float32Array([ 0,0,0, 0,1,0, 1,0,0, 1,1,0 ]), context.STATIC_DRAW);
+context.vertexAttribPointer(0, 3, context.FLOAT, false, 0, 0);
+
+var indexObject = context.createBuffer();
+
+context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, indexObject);
+var indices = new Uint16Array([ 10000, 0, 1, 2, 3, 10000 ]);
+context.bufferData(context.ELEMENT_ARRAY_BUFFER, indices, context.STATIC_DRAW);
+wtu.shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2)");
+var indexValidationError = wtu.shouldGenerateGLError(context,
+ [context.INVALID_OPERATION, context.NO_ERROR],
+ "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
+wtu.shouldGenerateGLError(context, indexValidationError, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
+indices[0] = 2;
+indices[5] = 1;
+wtu.shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2)");
+wtu.shouldGenerateGLError(context, indexValidationError, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
+wtu.shouldGenerateGLError(context, indexValidationError, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
+
+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/buffers/index-validation-crash-with-buffer-sub-data.html b/dom/canvas/test/webgl-conf/checkout/conformance/buffers/index-validation-crash-with-buffer-sub-data.html
new file mode 100644
index 0000000000..91873f740f
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/buffers/index-validation-crash-with-buffer-sub-data.html
@@ -0,0 +1,38 @@
+<!--
+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('Verifies that the index validation code which is within bufferSubData does not crash.')
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext();
+
+var elementBuffer = gl.createBuffer();
+gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, elementBuffer);
+gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, 256, gl.STATIC_DRAW);
+var data = new Uint8Array(127);
+gl.bufferSubData(gl.ELEMENT_ARRAY_BUFFER, 63, data);
+testPassed("bufferSubData, when buffer object was initialized with null, did not crash");
+
+var successfullyParsed = true;
+</script>
+
+<script src="../../js/js-test-post.js"></script>
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/buffers/index-validation-large-buffer.html b/dom/canvas/test/webgl-conf/checkout/conformance/buffers/index-validation-large-buffer.html
new file mode 100644
index 0000000000..a0427039a0
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/buffers/index-validation-large-buffer.html
@@ -0,0 +1,56 @@
+<!--
+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 that index validation for drawElements works with large attribute buffers');
+
+var wtu = WebGLTestUtils;
+var context = wtu.create3DContext();
+var program = wtu.loadStandardProgram(context);
+
+context.useProgram(program);
+
+// Create a small index buffer.
+var indexObject = context.createBuffer();
+context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, indexObject);
+var indexArray = new Uint16Array([0, 1, 2]);
+context.bufferData(context.ELEMENT_ARRAY_BUFFER, indexArray, context.STATIC_DRAW);
+
+// Create a large attribute buffer.
+var vertexObject = context.createBuffer();
+context.enableVertexAttribArray(0);
+context.bindBuffer(context.ARRAY_BUFFER, vertexObject);
+context.bufferData(context.ARRAY_BUFFER, new Float32Array(3 * 65536), context.STATIC_DRAW);
+context.vertexAttribPointer(0, 3, context.FLOAT, false, 0, 0);
+
+debug("Test large attribute buffer")
+wtu.shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLES, 3, context.UNSIGNED_SHORT, 0)");
+
+// Enlarge the attribute buffer slightly.
+debug("Test even larger attribute buffer")
+context.bufferData(context.ARRAY_BUFFER, new Float32Array(3 * 65536 + 3), context.STATIC_DRAW);
+wtu.shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLES, 3, context.UNSIGNED_SHORT, 0)");
+
+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/buffers/index-validation-verifies-too-many-indices.html b/dom/canvas/test/webgl-conf/checkout/conformance/buffers/index-validation-verifies-too-many-indices.html
new file mode 100644
index 0000000000..8ebbf4f32d
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/buffers/index-validation-verifies-too-many-indices.html
@@ -0,0 +1,50 @@
+<!--
+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 that index validation for drawElements does not examine too many indices');
+
+var wtu = WebGLTestUtils;
+var context = wtu.create3DContext();
+var program = wtu.loadStandardProgram(context);
+
+context.useProgram(program);
+var vertexObject = context.createBuffer();
+context.enableVertexAttribArray(0);
+context.bindBuffer(context.ARRAY_BUFFER, vertexObject);
+// 4 vertices -> 2 triangles
+context.bufferData(context.ARRAY_BUFFER, new Float32Array([ 0,0,0, 0,1,0, 1,0,0, 1,1,0 ]), context.STATIC_DRAW);
+context.vertexAttribPointer(0, 3, context.FLOAT, false, 0, 0);
+
+var indexObject = context.createBuffer();
+
+debug("Test out of range indices")
+context.bindBuffer(context.ELEMENT_ARRAY_BUFFER, indexObject);
+context.bufferData(context.ELEMENT_ARRAY_BUFFER, new Uint16Array([ 10000, 0, 1, 2, 3, 10000 ]), context.STATIC_DRAW);
+var indexValidationError = wtu.shouldGenerateGLError(context, [context.INVALID_OPERATION, context.NO_ERROR], "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 0)");
+wtu.shouldGenerateGLError(context, context.NO_ERROR, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 2)");
+wtu.shouldGenerateGLError(context, indexValidationError, "context.drawElements(context.TRIANGLE_STRIP, 4, context.UNSIGNED_SHORT, 4)");
+
+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/buffers/index-validation-with-resized-buffer.html b/dom/canvas/test/webgl-conf/checkout/conformance/buffers/index-validation-with-resized-buffer.html
new file mode 100644
index 0000000000..182768085f
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/buffers/index-validation-with-resized-buffer.html
@@ -0,0 +1,107 @@
+<!--
+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>
+<canvas id="example" width="1" height="1"></canvas>
+<div id="description"></div>
+<div id="console"></div>
+
+<script id="vs" type="x-shader/x-vertex">
+attribute vec4 vPosition;
+attribute vec4 vColor;
+varying vec4 color;
+void main() {
+ gl_Position = vPosition;
+ color = vColor;
+}
+</script>
+<script id="fs" type="x-shader/x-fragment">
+precision mediump float;
+varying vec4 color;
+void main() {
+ gl_FragColor = color;
+}
+</script>
+<script>
+"use strict";
+description('Test that updating the size of a vertex buffer is properly noticed by the WebGL implementation.')
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext("example");
+var program = wtu.setupProgram(gl, ["vs", "fs"], ["vPosition", "vColor"]);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after initialization");
+
+var vertexObject = gl.createBuffer();
+gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
+gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(
+ [-1,1,0, 1,1,0, -1,-1,0,
+ -1,-1,0, 1,1,0, 1,-1,0]), gl.STATIC_DRAW);
+gl.enableVertexAttribArray(0);
+gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after vertex setup");
+
+var texCoordObject = gl.createBuffer();
+gl.bindBuffer(gl.ARRAY_BUFFER, texCoordObject);
+gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(
+ [0,0, 1,0, 0,1,
+ 0,1, 1,0, 1,1]), gl.STATIC_DRAW);
+gl.enableVertexAttribArray(1);
+gl.vertexAttribPointer(1, 2, gl.FLOAT, false, 0, 0);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after texture coord setup");
+
+// Now resize these buffers because we want to change what we're drawing.
+gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
+gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
+ -1,1,0, 1,1,0, -1,-1,0, 1,-1,0,
+ -1,1,0, 1,1,0, -1,-1,0, 1,-1,0]), gl.STATIC_DRAW);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after vertex redefinition");
+gl.bindBuffer(gl.ARRAY_BUFFER, texCoordObject);
+gl.bufferData(gl.ARRAY_BUFFER, new Uint8Array([
+ 255, 0, 0, 255,
+ 255, 0, 0, 255,
+ 255, 0, 0, 255,
+ 255, 0, 0, 255,
+ 0, 255, 0, 255,
+ 0, 255, 0, 255,
+ 0, 255, 0, 255,
+ 0, 255, 0, 255]), gl.STATIC_DRAW);
+gl.vertexAttribPointer(1, 4, gl.UNSIGNED_BYTE, false, 0, 0);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after texture coordinate / color redefinition");
+
+var numQuads = 2;
+var indices = new Uint8Array(numQuads * 6);
+for (var ii = 0; ii < numQuads; ++ii) {
+ var offset = ii * 6;
+ var quad = (ii == (numQuads - 1)) ? 4 : 0;
+ indices[offset + 0] = quad + 0;
+ indices[offset + 1] = quad + 1;
+ indices[offset + 2] = quad + 2;
+ indices[offset + 3] = quad + 2;
+ indices[offset + 4] = quad + 1;
+ indices[offset + 5] = quad + 3;
+}
+var indexObject = gl.createBuffer();
+gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexObject);
+gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after setting up indices");
+gl.drawElements(gl.TRIANGLES, numQuads * 6, gl.UNSIGNED_BYTE, 0);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "after drawing");
+
+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/buffers/index-validation.html b/dom/canvas/test/webgl-conf/checkout/conformance/buffers/index-validation.html
new file mode 100644
index 0000000000..0aa7e78781
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/buffers/index-validation.html
@@ -0,0 +1,119 @@
+<!--
+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 that index validation verifies the correct number of indices");
+
+function sizeInBytes(type) {
+ switch (type) {
+ case gl.BYTE:
+ case gl.UNSIGNED_BYTE:
+ return 1;
+ case gl.SHORT:
+ case gl.UNSIGNED_SHORT:
+ return 2;
+ case gl.INT:
+ case gl.UNSIGNED_INT:
+ case gl.FLOAT:
+ return 4;
+ default:
+ throw "unknown type";
+ }
+}
+
+var wtu = WebGLTestUtils;
+var gl = wtu.create3DContext();
+var program = wtu.loadStandardProgram(gl);
+
+// 3 vertices => 1 triangle, interleaved data
+var dataComplete = new Float32Array([0, 0, 0, 1,
+ 0, 0, 1,
+ 1, 0, 0, 1,
+ 0, 0, 1,
+ 1, 1, 1, 1,
+ 0, 0, 1]);
+var dataIncomplete = new Float32Array([0, 0, 0, 1,
+ 0, 0, 1,
+ 1, 0, 0, 1,
+ 0, 0, 1,
+ 1, 1, 1, 1]);
+var indices = new Uint16Array([0, 1, 2]);
+
+debug("Testing with valid indices");
+
+var bufferComplete = gl.createBuffer();
+gl.bindBuffer(gl.ARRAY_BUFFER, bufferComplete);
+gl.bufferData(gl.ARRAY_BUFFER, dataComplete, gl.STATIC_DRAW);
+var elements = gl.createBuffer();
+gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, elements);
+gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW);
+gl.useProgram(program);
+var vertexLoc = gl.getAttribLocation(program, "a_vertex");
+var normalLoc = gl.getAttribLocation(program, "a_normal");
+gl.vertexAttribPointer(vertexLoc, 4, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT), 0);
+gl.enableVertexAttribArray(vertexLoc);
+gl.vertexAttribPointer(normalLoc, 3, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT), 4 * sizeInBytes(gl.FLOAT));
+gl.enableVertexAttribArray(normalLoc);
+shouldBe('gl.checkFramebufferStatus(gl.FRAMEBUFFER)', 'gl.FRAMEBUFFER_COMPLETE');
+wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)');
+wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+
+debug("Testing with out-of-range indices");
+
+var bufferIncomplete = gl.createBuffer();
+gl.bindBuffer(gl.ARRAY_BUFFER, bufferIncomplete);
+gl.bufferData(gl.ARRAY_BUFFER, dataIncomplete, gl.STATIC_DRAW);
+gl.vertexAttribPointer(vertexLoc, 4, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT), 0);
+gl.enableVertexAttribArray(vertexLoc);
+gl.disableVertexAttribArray(normalLoc);
+debug("Enable vertices, valid");
+wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)');
+wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+debug("Enable normals, out-of-range");
+gl.vertexAttribPointer(normalLoc, 3, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT), 4 * sizeInBytes(gl.FLOAT));
+gl.enableVertexAttribArray(normalLoc);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)');
+wtu.glErrorShouldBe(gl, [gl.INVALID_OPERATION, gl.NO_ERROR]);
+
+debug("Test with enabled attribute that does not belong to current program");
+
+gl.disableVertexAttribArray(normalLoc);
+var extraLoc = Math.max(vertexLoc, normalLoc) + 1;
+gl.enableVertexAttribArray(extraLoc);
+debug("Enable an extra attribute with null");
+wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)');
+wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION);
+debug("Enable an extra attribute with insufficient data buffer");
+gl.vertexAttribPointer(extraLoc, 3, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT), 4 * sizeInBytes(gl.FLOAT));
+wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)');
+debug("Pass large negative index to vertexAttribPointer");
+gl.vertexAttribPointer(normalLoc, 3, gl.FLOAT, false, 7 * sizeInBytes(gl.FLOAT), -2000000000 * sizeInBytes(gl.FLOAT));
+wtu.glErrorShouldBe(gl, gl.INVALID_VALUE);
+shouldBeUndefined('gl.drawElements(gl.TRIANGLES, 3, gl.UNSIGNED_SHORT, 0)');
+
+var successfullyParsed = true;
+</script>
+
+<script src="../../js/js-test-post.js"></script>
+</body>
+</html>
diff --git a/dom/canvas/test/webgl-conf/checkout/conformance/buffers/vertex-buffer-updated-after-draw.html b/dom/canvas/test/webgl-conf/checkout/conformance/buffers/vertex-buffer-updated-after-draw.html
new file mode 100644
index 0000000000..90436b64ef
--- /dev/null
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/buffers/vertex-buffer-updated-after-draw.html
@@ -0,0 +1,94 @@
+<!--
+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 Vertex Buffer Updated After Draw 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="50" height="50">
+</canvas>
+<div id="description"></div>
+<div id="console"></div>
+<script id="vshader" type="x-shader/x-vertex">
+attribute vec2 a_position;
+attribute vec4 a_color;
+varying vec4 v_outcolor;
+void main() {
+ gl_Position = vec4(a_position, 0, 1);
+ v_outcolor = a_color;
+}
+</script>
+
+<script id="fshader" type="x-shader/x-fragment">
+varying mediump vec4 v_outcolor;
+void main() {
+ gl_FragColor = v_outcolor;
+}
+</script>
+
+<script>
+// Tests that D3D11 dirty bit updates don't forget about BufferSubData attrib updates.
+// Based on ANGLE test (StateChangeTest, VertexBufferUpdatedAfterDraw) from https://github.com/google/angle/blob/f7f0b8c3ab21c52cc2915048959361cf628d95f0/src/tests/gl_tests/StateChangeTest.cpp
+"use strict";
+var wtu = WebGLTestUtils;
+description();
+
+var gl = wtu.create3DContext("example");
+
+var program = wtu.setupProgram(gl, ['vshader', 'fshader']);
+
+var colorLoc = gl.getAttribLocation(program, "a_color");
+var green = new Uint8Array(4 * 6);
+var red = new Uint8Array(4 * 6);
+
+for (var i = 0; i < 6; ++i) {
+ var ci = i * 4;
+
+ green[ci] = 0;
+ red[ci] = 255;
+
+ green[ci + 1] = 255;
+ red[ci + 1] = 0;
+
+ green[ci + 2] = red[ci + 2] = 0;
+
+ green[ci + 3] = red[ci + 3] = 255;
+}
+
+var positionLoc = gl.getAttribLocation(program, "a_position");
+
+var gridRes = 1;
+wtu.setupIndexedQuad(gl, gridRes, positionLoc);
+
+var colorBuf = gl.createBuffer();
+gl.bindBuffer(gl.ARRAY_BUFFER, colorBuf);
+gl.bufferData(gl.ARRAY_BUFFER, green, gl.STATIC_DRAW);
+gl.vertexAttribPointer(colorLoc, 4, gl.UNSIGNED_BYTE, true, 0, 0);
+gl.enableVertexAttribArray(colorLoc);
+
+wtu.clearAndDrawIndexedQuad(gl, gridRes);
+wtu.checkCanvas(gl, [0, 255, 0, 255], "should be green");
+
+gl.bufferSubData(gl.ARRAY_BUFFER, 0, red);
+
+wtu.clearAndDrawIndexedQuad(gl, gridRes);
+wtu.checkCanvas(gl, [255, 0, 0, 255], "should be red");
+
+wtu.glErrorShouldBe(gl, gl.NO_ERROR, "should be no errors");
+
+var successfullyParsed = true;
+</script>
+<script src="../../js/js-test-post.js"></script>
+
+</body>
+</html>
+