Bug 1277424 - Carry the changes from 1.0.3 conformance draft
authorpeter chang <pchang@mozilla.com>
Wed, 08 Jun 2016 09:58:43 +0800
changeset 376476 9532a25a0fbdae53468fbebd6dc0da05bc420b25
parent 376475 b69e16a990b9d7b4e96a1ccd7a731ab8cafed1e1
child 376484 c9ca66919e11b35793f568d90eda52c2ae87b8e7
push id20585
push userbmo:howareyou322@gmail.com
push dateWed, 08 Jun 2016 02:05:49 +0000
bugs1277424
milestone49.0a1
Bug 1277424 - Carry the changes from 1.0.3 conformance MozReview-Commit-ID: 9a8x2Y4fNh3
dom/canvas/test/webgl-conf/checkout/conformance/textures/misc/tex-image-canvas-corruption.html
dom/canvas/test/webgl-conf/checkout/js/tests/tex-image-and-sub-image-2d-with-image.js
dom/canvas/test/webgl-conf/checkout/js/tests/tex-image-and-sub-image-2d-with-video.js
dom/canvas/test/webgl-conf/checkout/js/webgl-test-utils.js
--- a/dom/canvas/test/webgl-conf/checkout/conformance/textures/misc/tex-image-canvas-corruption.html
+++ b/dom/canvas/test/webgl-conf/checkout/conformance/textures/misc/tex-image-canvas-corruption.html
@@ -51,16 +51,21 @@ var texture = gl.createTexture();
 
 var image = wtu.makeImage('../../../resources/blue-1x1.jpg', function() {
   renderToCanvas();
   renderToCanvas();
   wtu.checkCanvas(ctx, [0, 0, 255, 255], "All pixels should be blue", 2);
   finishTest();
 });
 
+image.onerror = function() {
+  testFailed("Loading image failed. src: " + image.src);
+  finishTest();
+};
+
 function renderToCanvas() {
   // Clear the 2d canvas then draw the image to it (a blue pixel)
   ctx.clearRect(0, 0, canvas.width, canvas.height);
   ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
 
   // Upload the results to a WebGL texture
   gl.bindTexture(gl.TEXTURE_2D, texture);
   gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, canvas);
--- a/dom/canvas/test/webgl-conf/checkout/js/tests/tex-image-and-sub-image-2d-with-image.js
+++ b/dom/canvas/test/webgl-conf/checkout/js/tests/tex-image-and-sub-image-2d-with-image.js
@@ -51,17 +51,25 @@ function generateTest(internalFormat, pi
 
         default:
           break;
         }
 
         gl.clearColor(0,0,0,1);
         gl.clearDepth(1);
 
-        wtu.loadTexture(gl, resourcePath + "red-green.png", runTest);
+        var image = new Image();
+        image.onload = function() {
+            runTest(image);
+        };
+        image.onerror = function() {
+            testFailed("Creating image from canvas failed. Image src: " + this.src);
+            finishTest();
+        };
+        image.src = resourcePath + "red-green.png";
     }
 
     function runOneIteration(image, useTexSubImage2D, flipY, topColor, bottomColor,
                              bindingTarget, program)
     {
         debug('Testing ' + (useTexSubImage2D ? 'texSubImage2D' : 'texImage2D') +
               ' with flipY=' + flipY + ' bindingTarget=' +
               (bindingTarget == gl.TEXTURE_2D ? 'TEXTURE_2D' : 'TEXTURE_CUBE_MAP'));
--- a/dom/canvas/test/webgl-conf/checkout/js/tests/tex-image-and-sub-image-2d-with-video.js
+++ b/dom/canvas/test/webgl-conf/checkout/js/tests/tex-image-and-sub-image-2d-with-video.js
@@ -200,16 +200,22 @@ function generateTest(internalFormat, pi
                       debug(info.type + " unsupported");
                       runNextVideo();
                       return;
                     };
 
                     document.body.appendChild(video);
                     video.type = info.type;
                     video.src = info.src;
+
+                    video.onerror = function(e) {
+                      testFailed("Loading video failed. src: " + video.src);
+                      finishTest();
+                    };
+
                     wtu.startPlayingAndWaitForVideo(video, runTest);
                 }
                 function runTest() {
                     for (var i in cases) {
                         // cube map texture must be square but video is not square.
                         if (bindingTarget == gl.TEXTURE_2D || cases[i].sub == true) {
                             runOneIteration(video, cases[i].sub, cases[i].flipY,
                                             cases[i].topColor, cases[i].bottomColor,
--- a/dom/canvas/test/webgl-conf/checkout/js/webgl-test-utils.js
+++ b/dom/canvas/test/webgl-conf/checkout/js/webgl-test-utils.js
@@ -1268,16 +1268,19 @@ var loadTexture = function(gl, url, call
     gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
     var image = new Image();
     image.onload = function() {
         gl.bindTexture(gl.TEXTURE_2D, texture);
         gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
         gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
         callback(image);
     };
+    image.onerror = function() {
+      throw new Error('Failed to load image at: ' + image.src);
+    };
     image.src = url;
     return texture;
 };
 
 /**
  * Checks whether the bound texture has expected dimensions. One corner pixel
  * of the texture will be changed as a side effect.
  * @param {!WebGLRenderingContext} gl The WebGLRenderingContext to use.