Bug 1293845 - Update tests to handle new webidl.
☠☠ backed out by 0afcc7ac9440 ☠ ☠
authorJeff Gilbert <jgilbert@mozilla.com>
Wed, 10 Aug 2016 15:16:18 -0700
changeset 309351 2b9a31603e348c8edac61f74627674f5a9284976
parent 309350 b2cad6d22d757c3b4763687275541fcd114ecefa
child 309352 8fd07f16556c8ca5305cb629ec90dce75c77c798
push id30561
push userkwierso@gmail.com
push dateMon, 15 Aug 2016 21:20:49 +0000
treeherdermozilla-central@91a319101587 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1293845
milestone51.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1293845 - Update tests to handle new webidl. MozReview-Commit-ID: 7hcluLAw7gx
dom/canvas/test/webgl-conf/checkout/conformance/textures/misc/tex-sub-image-2d-bad-args.html
dom/canvas/test/webgl-conf/checkout/conformance2/buffers/buffer-copying-contents.html
dom/canvas/test/webgl-conf/checkout/conformance2/buffers/getBufferSubData.html
dom/canvas/test/webgl-conf/checkout/js/webgl-test-utils.js
dom/canvas/test/webgl-mochitest/test_pixel_pack_buffer.html
--- a/dom/canvas/test/webgl-conf/checkout/conformance/textures/misc/tex-sub-image-2d-bad-args.html
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/textures/misc/tex-sub-image-2d-bad-args.html
@@ -61,20 +61,36 @@ wtu.glErrorShouldBe(gl, gl.INVALID_VALUE
 gl.texSubImage2D(gl.TEXTURE_2D, 0, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, c);
 wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "x + width > texture width");
 gl.texSubImage2D(gl.TEXTURE_2D, 0, -1, 0, gl.RGBA, gl.UNSIGNED_BYTE, c);
 wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "negative x");
 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, -1, gl.RGBA, gl.UNSIGNED_BYTE, c);
 wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "negative y");
 gl.texSubImage2D(gl.TEXTURE_2D, -1, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, c);
 wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "negative level");
-gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
-wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "no image data");
-gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
-wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "null pixels");
+
+if (contextVersion >= 2) {
+    var text = "Should throw with no image data.";
+    try {
+        gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
+        testFailed(text);
+    } catch(e) {
+        testPassed(text);
+    }
+    wtu.glErrorShouldBe(gl, gl.NO_ERROR, "no image data");
+} else {
+    gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
+    wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "no image data");
+}
+
+if (contextVersion < 2) {
+    // In WebGL2, null coerces to 0 for the PBO entrypoint.
+    gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
+    wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "null pixels");
+}
 
 // GL_INVALID_VALUE may be generated if level is greater than log 2 max, where max is the returned value of GL_MAX_TEXTURE_SIZE.
 // GL_INVALID_OPERATION is generated if the texture array has not been defined by a previous  glTexImage2D or glCopyTexImage2D operation whose internalformat matches the format of glTexSubImage2D.
 gl.texSubImage2D(gl.TEXTURE_2D, maxTextureLevel + 1, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, c);
 wtu.glErrorShouldBe(gl, [gl.INVALID_VALUE, gl.INVALID_OPERATION], "too high level");
 
 gl.texSubImage2D(gl.FLOAT, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, c);
 wtu.glErrorShouldBe(gl, gl.INVALID_ENUM, "bad target");
--- a/dom/canvas/test/webgl-conf/checkout/conformance2/buffers/buffer-copying-contents.html
+++ b/dom/canvas/test/webgl-conf/checkout/conformance2/buffers/buffer-copying-contents.html
@@ -103,24 +103,24 @@ function testCopyBuffers(srcTarget, dstT
   }
 
   gl.copyBufferSubData(copyRead ? gl.COPY_READ_BUFFER : srcTarget,
                        copyWrite ? gl.COPY_WRITE_BUFFER : dstTarget,
                        0, 0, length);
   if (expectedGLError == gl.NO_ERROR) {
     wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Copying should work");
 
-    var retBuffer = new ArrayBuffer(length);
+    var retBuffer = new Uint8Array(length);
     gl.getBufferSubData(dstTarget, 0, retBuffer);
     wtu.glErrorShouldBe(gl, gl.NO_ERROR,
         "gl.getBufferSubData(" + targetToString(gl, dstTarget) +
         ", 0, retBuffer) should work");
 
     var failed = false;
-    var retArray = new Float32Array(retBuffer);
+    var retArray = new Float32Array(retBuffer.buffer);
     for (var i = 0; i < vertices.length; i++) {
       if (originalData[i] != retArray[i]) {
         failed = true;
         break;
       }
     }
     if (failed)
       testFailed("The returned array buffer fails to match original data");
--- a/dom/canvas/test/webgl-conf/checkout/conformance2/buffers/getBufferSubData.html
+++ b/dom/canvas/test/webgl-conf/checkout/conformance2/buffers/getBufferSubData.html
@@ -55,56 +55,51 @@ var floatArray = new Float32Array(vertic
 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "Should be no errors from setup.");
 
 var buffer = gl.createBuffer();
 gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
 gl.bufferData(gl.ARRAY_BUFFER, floatArray, gl.STATIC_DRAW);
 
 debug("");
 debug("Test that getBufferSubData successfully works reading buffer data from gl.ARRAY_BUFFER");
-var arrBuffer = new ArrayBuffer(vertices.length * Float32Array.BYTES_PER_ELEMENT);
-gl.getBufferSubData(gl.ARRAY_BUFFER, 0, arrBuffer);
+var retArray = new Float32Array(vertices.length);
+gl.getBufferSubData(gl.ARRAY_BUFFER, 0, retArray);
 wtu.glErrorShouldBe(gl, gl.NO_ERROR, "gl.getBufferSubData(gl.ARRAY_BUFFER, 0, arrBuffer) should WORK");
 
 debug("Check array data to match original data set by the buffer");
 var failed = false;
-var retArray = new Float32Array(arrBuffer);
 for (var i = 0; i < vertices.length; i++) {
   if (floatArray[i] != retArray[i]) {
     failed = true;
     break;
   }
 }
 if (failed)
   testFailed("The returned array buffer fails to match original data");
 else
   testPassed("The returned array buffer matches original data");
 
 debug("Test that getBufferSubData fails when given a buffer with its size larger than the original data");
-var extraLargeBuffer = new ArrayBuffer(vertices.length * Float32Array.BYTES_PER_ELEMENT + 1);
+var extraLargeBuffer = new Uint8Array(vertices.length * Float32Array.BYTES_PER_ELEMENT + 1);
 gl.getBufferSubData(gl.ARRAY_BUFFER, 0, extraLargeBuffer);
 wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "gl.getBufferSubData(gl.ARRAY_BUFFER, 0, extraLargeBuffer) with extra length should generate INVALID_VALUE");
 
 debug("Test that getBufferSubData fails when offset summed with buffer length is larger than the size of the original data size");
-gl.getBufferSubData(gl.ARRAY_BUFFER, vertices.length * Float32Array.BYTES_PER_ELEMENT + 1, arrBuffer);
+gl.getBufferSubData(gl.ARRAY_BUFFER, vertices.length * Float32Array.BYTES_PER_ELEMENT + 1, retArray);
 wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "gl.getBufferSubData(gl.ARRAY_BUFFER, vertices.length * Float32Array.BYTES_PER_ELEMENT + 1, arrBuffer) with offset larger than original data size should generate INVALID_VALUE");
-gl.getBufferSubData(gl.ARRAY_BUFFER, 1, arrBuffer);
+gl.getBufferSubData(gl.ARRAY_BUFFER, 1, retArray);
 wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "gl.getBufferSubData(gl.ARRAY_BUFFER, 1, arrBuffer) with offset and length larger than buffer size should generate INVALID_VALUE");
 
 debug("Test that getBufferSubData fails when 0 is bound to the target");
 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
-gl.getBufferSubData(gl.ELEMENT_ARRAY_BUFFER, 0, arrBuffer);
+gl.getBufferSubData(gl.ELEMENT_ARRAY_BUFFER, 0, retArray);
 wtu.glErrorShouldBe(gl, gl.INVALID_OPERATION, "gl.getBufferSubData(gl.ELEMENT_ARRAY_BUFFER, 0, arrBuffer) should generate INVALID_OPERATION");
 
 debug("Test that getBufferSubData fails when offset is less than 0");
-gl.getBufferSubData(gl.ARRAY_BUFFER, -1, arrBuffer);
+gl.getBufferSubData(gl.ARRAY_BUFFER, -1, retArray);
 wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "gl.getBufferSubData(gl.ARRAY_BUFFER, -1, arrBuffer) should generate INVALID_VALUE");
 
-debug("Test that getBufferSubData fails when given a null buffer");
-gl.getBufferSubData(gl.ARRAY_BUFFER, 0, null);
-wtu.glErrorShouldBe(gl, gl.INVALID_VALUE, "gl.getBufferSubData(gl.ARRAY_BUFFER, 0, null) should generate INVALID_VALUE");
-
 finishTest();
 
 var successfullyParsed = true;
 </script>
 </body>
 </html>
--- a/dom/canvas/test/webgl-conf/checkout/js/webgl-test-utils.js
+++ b/dom/canvas/test/webgl-conf/checkout/js/webgl-test-utils.js
@@ -1234,20 +1234,19 @@ var checkAreaInAndOut = function(gl, x, 
  */
 var checkFloatBuffer = function(gl, target, expected, opt_msg, opt_errorRange) {
   if (opt_msg === undefined)
     opt_msg = "buffer should match expected values";
 
   if (opt_errorRange === undefined)
     opt_errorRange = 0.001;
 
-  var outData = new ArrayBuffer(Float32Array.BYTES_PER_ELEMENT * expected.length);
-  gl.getBufferSubData(target, 0, outData);
+  var floatArray = new Float32Array(expected.length);
+  gl.getBufferSubData(target, 0, floatArray);
 
-  var floatArray = new Float32Array(outData);
   for (var i = 0; i < expected.length; i++) {
     if (Math.abs(floatArray[i] - expected[i]) > opt_errorRange) {
       testFailed(opt_msg);
       debug('at [' + i + '] expected: ' + expected[i] + ' was ' + floatArray[i]);
       return;
     }
   }
   testPassed(opt_msg);
--- a/dom/canvas/test/webgl-mochitest/test_pixel_pack_buffer.html
+++ b/dom/canvas/test/webgl-mochitest/test_pixel_pack_buffer.html
@@ -182,65 +182,65 @@ function Test() {
   ////////
 
   // Basic
   section('Basic readback');
   data = ClearBufferPair(gl, 16);
   EnsureNoError(gl);
   gl.readPixels(0, 0, 2, 2, gl.RGBA, gl.UNSIGNED_BYTE, 0);
   EnsureNoError(gl);
-  gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 0, data.buffer);
+  gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 0, data);
   EnsureNoError(gl);
   TestIsUNormColor(RED, data, 0);
   TestIsUNormColor(BLUE, data, 4);
   TestIsUNormColor(GREEN, data, 8);
   TestIsUNormColor(WHITE, data, 12);
 
   section('Subrect readback');
   data = ClearBufferPair(gl, 8);
   gl.readPixels(1, 1, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, 0);
-  gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 0, data.buffer);
+  gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 0, data);
   EnsureNoError(gl);
   TestIsUNormColor(WHITE, data, 0);
   TestIsUNormColor(ZERO, data, 4);
 
   section('ReadPixels offset:4');
   data = ClearBufferPair(gl, 16);
   gl.readPixels(1, 1, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, 4);
-  gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 0, data.buffer);
+  gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 0, data);
   EnsureNoError(gl);
   TestIsUNormColor(ZERO, data, 0);
   TestIsUNormColor(WHITE, data, 4);
   TestIsUNormColor(ZERO, data, 8);
   TestIsUNormColor(ZERO, data, 12);
 
   section('ReadPixels offset:5');
   gl.readPixels(1, 1, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, 5);
-  gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 0, data.buffer);
+  gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 0, data);
   EnsureNoError(gl);
   TestIsUNormColor(ZERO, data, 0);
   TestIsUNormColor(WHITE, data, 4); // Should remain from previous read.
   TestIsUNormColor(WHITE, data, 5);
   TestIsUNormColor(ZERO, data, 9);
   TestIsUNormColor(ZERO, data, 12);
 
   section('GetBufferSubData src too small');
   data = ClearBufferPair(gl, 16);
   EnsureNoError(gl);
-  gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 1, data.buffer);
+  gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 1, data);
   TestError(gl, gl.INVALID_VALUE);
   TestIsUNormColor(ZERO, data, 0);
   TestIsUNormColor(ZERO, data, 4);
   TestIsUNormColor(ZERO, data, 8);
   TestIsUNormColor(ZERO, data, 12);
 
   section('GetBufferSubData offset:1');
   data = new Uint8Array(15);
   gl.readPixels(1, 1, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, 8);
-  gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 1, data.buffer);
+  gl.getBufferSubData(gl.PIXEL_PACK_BUFFER, 1, data);
   EnsureNoError(gl);
   TestIsUNormColor(ZERO, data, 0);
   TestIsUNormColor(ZERO, data, 3);
   TestIsUNormColor(WHITE, data, 7);
   TestIsUNormColor(ZERO, data, 11);
 
   //////////////////////////////////////