Fix LayoutTests/http/tests/canvas/canvas-tainted-after-draw-image.html on all bots
authorsaid@apple.com <said@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 13 Apr 2015 23:51:36 +0000 (23:51 +0000)
committersaid@apple.com <said@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 13 Apr 2015 23:51:36 +0000 (23:51 +0000)
following http://trac.webkit.org/changeset/182750.

Reviewed by Daniel Bates.

* http/tests/canvas/canvas-tainted-after-draw-image-expected.txt:
* http/tests/canvas/canvas-tainted-after-draw-image.html:
Set window.jsTestIsAsync true and call finishJSTest() to make the test
asynchronous, so the "TEST COMPLETE" message will be output after all the
test messages. Also delete the synchronous tests for data url image and
same-domain image since they can't be reliably tested.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@182767 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/http/tests/canvas/canvas-tainted-after-draw-image-expected.txt
LayoutTests/http/tests/canvas/canvas-tainted-after-draw-image.html

index a5779c6..6a4db04 100644 (file)
@@ -1,3 +1,17 @@
+2015-04-13  Said Abou-Hallawa  <sabouhallawa@apple.com>
+
+        Fix LayoutTests/http/tests/canvas/canvas-tainted-after-draw-image.html on all bots
+        following http://trac.webkit.org/changeset/182750.
+
+        Reviewed by Daniel Bates.
+
+        * http/tests/canvas/canvas-tainted-after-draw-image-expected.txt:
+        * http/tests/canvas/canvas-tainted-after-draw-image.html:
+        Set window.jsTestIsAsync true and call finishJSTest() to make the test 
+        asynchronous, so the "TEST COMPLETE" message will be output after all the
+        test messages. Also delete the synchronous tests for data url image and
+        same-domain image since they can't be reliably tested.
+
 2015-04-13  Simon Fraser  <simon.fraser@apple.com>
 
         Fix compositing/geometry/fixed-transformed.html on Mavericks.
index 551d843..1dc2f29 100644 (file)
@@ -1,6 +1,4 @@
-CONSOLE MESSAGE: line 60: Unable to get image data from canvas because the canvas has been tainted by cross-origin data.
-Tainting works correctly.
-Tainting works correctly.
+CONSOLE MESSAGE: line 58: Unable to get image data from canvas because the canvas has been tainted by cross-origin data.
 Tainting works correctly.
 Tainting works correctly.
 Tainting works correctly.
index c740b61..3c8df0e 100644 (file)
       if (typeof incrementLoadedImagesCount.counter == 'undefined')
         incrementLoadedImagesCount.counter = 0;
         
-      if (++incrementLoadedImagesCount.counter == 6) {
-        if (window.testRunner)
-          testRunner.notifyDone();
-      }
+      if (++incrementLoadedImagesCount.counter == 4)
+          finishJSTest();
     }
 
-    function drawAndGetImageDataSynchronous(id, color, imageSrc, shouldTaint) {
-      var context = drawCanvasBackground(id, color);
+    function drawAndGetImageDataSynchronous(id, imageSrc, shouldTaint) {
+      var context = drawCanvasBackground(id, '#f00'); // red
       var image =  new Image();
       image.src = imageSrc;
       context.drawImage(image, 0, 0);
@@ -51,7 +49,7 @@
     }
     
     function drawAndGetImageDataAsynchronous(canvasId, imageSrc, shouldTaint) {
-      var context = drawCanvasBackground(canvasId, '#f00');
+      var context = drawCanvasBackground(canvasId, '#f00'); // red
       var image =  new Image();
 
       image.onload = function() {
       image.src = imageSrc;
     }
 
-    if (window.testRunner) {
-      testRunner.dumpAsText();
-      testRunner.waitUntilDone();
-    }
-
-    drawCanvasBackground("sourceCanvas", '#0f0');
-        
-    drawAndGetImageDataSynchronous("dataURLSynchronousCanvas", sourceCanvas.toDataURL(), false);
-    drawAndGetImageDataAsynchronous("dataURLAsynchronousCanvas", sourceCanvas.toDataURL(), false);
+    window.jsTestIsAsync = true;
+    
+    drawCanvasBackground("sourceCanvas", '#0f0'); // green
     
-    drawAndGetImageDataSynchronous("sameDomainSynchronousCanvas", "http://127.0.0.1:8000/canvas/resources/100x100-lime-rect.svg", false);
+    // The dataURL and same-domain images should not be tainted. We should always be
+    // able to get the image data regardless whether it is drawn or not. But because
+    // we ask for the image data right after we load the image, we do not know the
+    // pixels values. So the synchronous case can't be tested.
+    drawAndGetImageDataAsynchronous("dataURLAsynchronousCanvas", sourceCanvas.toDataURL(), false);
     drawAndGetImageDataAsynchronous("sameDomainAsynchronousCanvas", "http://127.0.0.1:8000/canvas/resources/100x100-lime-rect.svg", false);
     
+    // Cross domain image load should taint the canvas. The image should not be drawn
+    // so the synchronous case can be tested since we know the canvas pixel value.
     drawAndGetImageDataSynchronous("crossDomainSynchronousCanvas", "http://localhost:8000/canvas/resources/100x100-lime-rect.svg", true);
     drawAndGetImageDataAsynchronous("crossDomainAsynchronousCanvas", "http://localhost:8000/canvas/resources/100x100-lime-rect.svg", true);
   </script>