Title: [264459] trunk/LayoutTests/imported/w3c
Revision
264459
Author
[email protected]
Date
2020-07-16 09:26:57 -0700 (Thu, 16 Jul 2020)

Log Message

Resync web-platform-tests/imagebitmap-renderingcontext from upstream
https://bugs.webkit.org/show_bug.cgi?id=214376

Reviewed by Carlos Alberto Lopez Perez.

Resync web-platform-tests/imagebitmap-renderingcontext from upstream b2a666d93581a71e9338b2.

* web-platform-tests/imagebitmap-renderingcontext/META.yml: Added.
* web-platform-tests/imagebitmap-renderingcontext/context-creation-offscreen-expected.txt: Added.
* web-platform-tests/imagebitmap-renderingcontext/context-creation-offscreen-with-alpha-expected.txt: Added.
* web-platform-tests/imagebitmap-renderingcontext/context-creation-offscreen-with-alpha.html: Copied from LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/context-creation-with-alpha.html.
* web-platform-tests/imagebitmap-renderingcontext/context-creation-offscreen.html: Added.
* web-platform-tests/imagebitmap-renderingcontext/context-creation-with-alpha-expected.txt:
* web-platform-tests/imagebitmap-renderingcontext/context-creation-with-alpha.html:
* web-platform-tests/imagebitmap-renderingcontext/context-preserves-canvas.html:
* web-platform-tests/imagebitmap-renderingcontext/toBlob-origin-clean-offscreen.sub-expected.txt: Added.
* web-platform-tests/imagebitmap-renderingcontext/toBlob-origin-clean-offscreen.sub.html: Added.
* web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-ToBlob-offscreen-expected.txt: Added.
* web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-ToBlob-offscreen.html: Added.
* web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-TransferToImageBitmap-offscreen-expected.txt: Added.
* web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-TransferToImageBitmap-offscreen.html: Added.
* web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-null-offscreen-expected.txt: Added.
* web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-null-offscreen.html: Copied from LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-null.html.
* web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-null.html:
* web-platform-tests/imagebitmap-renderingcontext/transferFromImageBitmap-detached.html:
* web-platform-tests/imagebitmap-renderingcontext/w3c-import.log:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (264458 => 264459)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-07-16 16:15:17 UTC (rev 264458)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-07-16 16:26:57 UTC (rev 264459)
@@ -1,5 +1,34 @@
 2020-07-16  Chris Dumez  <[email protected]>
 
+        Resync web-platform-tests/imagebitmap-renderingcontext from upstream
+        https://bugs.webkit.org/show_bug.cgi?id=214376
+
+        Reviewed by Carlos Alberto Lopez Perez.
+
+        Resync web-platform-tests/imagebitmap-renderingcontext from upstream b2a666d93581a71e9338b2.
+
+        * web-platform-tests/imagebitmap-renderingcontext/META.yml: Added.
+        * web-platform-tests/imagebitmap-renderingcontext/context-creation-offscreen-expected.txt: Added.
+        * web-platform-tests/imagebitmap-renderingcontext/context-creation-offscreen-with-alpha-expected.txt: Added.
+        * web-platform-tests/imagebitmap-renderingcontext/context-creation-offscreen-with-alpha.html: Copied from LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/context-creation-with-alpha.html.
+        * web-platform-tests/imagebitmap-renderingcontext/context-creation-offscreen.html: Added.
+        * web-platform-tests/imagebitmap-renderingcontext/context-creation-with-alpha-expected.txt:
+        * web-platform-tests/imagebitmap-renderingcontext/context-creation-with-alpha.html:
+        * web-platform-tests/imagebitmap-renderingcontext/context-preserves-canvas.html:
+        * web-platform-tests/imagebitmap-renderingcontext/toBlob-origin-clean-offscreen.sub-expected.txt: Added.
+        * web-platform-tests/imagebitmap-renderingcontext/toBlob-origin-clean-offscreen.sub.html: Added.
+        * web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-ToBlob-offscreen-expected.txt: Added.
+        * web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-ToBlob-offscreen.html: Added.
+        * web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-TransferToImageBitmap-offscreen-expected.txt: Added.
+        * web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-TransferToImageBitmap-offscreen.html: Added.
+        * web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-null-offscreen-expected.txt: Added.
+        * web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-null-offscreen.html: Copied from LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-null.html.
+        * web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-null.html:
+        * web-platform-tests/imagebitmap-renderingcontext/transferFromImageBitmap-detached.html:
+        * web-platform-tests/imagebitmap-renderingcontext/w3c-import.log:
+
+2020-07-16  Chris Dumez  <[email protected]>
+
         Resync web-platform-tests/resource-timing from upstream
         https://bugs.webkit.org/show_bug.cgi?id=214377
 

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/META.yml (0 => 264459)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/META.yml	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/META.yml	2020-07-16 16:26:57 UTC (rev 264459)
@@ -0,0 +1,6 @@
+spec: https://html.spec.whatwg.org/multipage/canvas.html#the-imagebitmap-rendering-context
+suggested_reviewers:
+  - AmeliaBR
+  - annevk
+  - kenrussell
+  - fserb

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/context-creation-offscreen-expected.txt (0 => 264459)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/context-creation-offscreen-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/context-creation-offscreen-expected.txt	2020-07-16 16:26:57 UTC (rev 264459)
@@ -0,0 +1,3 @@
+
+FAIL Test that canvas.getContext('bitmaprenderer') returns an instance of ImageBitmapRenderingContext and ctx.canvas on a ImageBitmapRenderingContext returns the original OffscreenCanvas Can't find variable: OffscreenCanvas
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/context-creation-offscreen-with-alpha-expected.txt (0 => 264459)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/context-creation-offscreen-with-alpha-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/context-creation-offscreen-with-alpha-expected.txt	2020-07-16 16:26:57 UTC (rev 264459)
@@ -0,0 +1,5 @@
+
+FAIL Test that an ImageBitmapRenderingContext with alpha disabled makes the canvas opaque promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: OffscreenCanvas"
+FAIL Test that an ImageBitmapRenderingContext with alpha enabled preserves the alpha promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: OffscreenCanvas"
+FAIL Test that the 'alpha' context creation attribute is true by default promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: OffscreenCanvas"
+

Copied: trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/context-creation-offscreen-with-alpha.html (from rev 264458, trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/context-creation-with-alpha.html) (0 => 264459)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/context-creation-offscreen-with-alpha.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/context-creation-offscreen-with-alpha.html	2020-07-16 16:26:57 UTC (rev 264459)
@@ -0,0 +1,62 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Canvas's ImageBitmapRenderingContext test</title>
+<script src=""
+<script src=""
+<link rel="help" href=""
+<script>
+var width = 10;
+var height = 10;
+
+function testImageBitmap(image, opts, expectedR, expectedG, expectedB, expectedA)
+{
+    var dstCanvas = new OffscreenCanvas(width,height);
+    var dstCtx = dstCanvas.getContext('bitmaprenderer', opts);
+    dstCtx.transferFromImageBitmap(image);
+
+    var myCanvas = document.createElement('canvas');
+    myCanvas.width = width;
+    myCanvas.height = height;
+    var myCtx = myCanvas.getContext('2d');
+    myCtx.drawImage(dstCanvas, 0, 0);
+    var color = myCtx.getImageData(5, 5, 1, 1).data;
+    assert_array_approx_equals(color, [expectedR, expectedG, expectedB, expectedA],1);
+}
+
+promise_test(function() {
+    var srcCanvas = document.createElement('canvas');
+    srcCanvas.width = width;
+    srcCanvas.height = height;
+    var ctx = srcCanvas.getContext('2d');
+    ctx.fillStyle = 'rgba(0, 255, 0, 0.5)';
+    ctx.fillRect(0, 0, width, height);
+    return createImageBitmap(srcCanvas).then(function(image) {
+        testImageBitmap(image, {alpha: false}, 0, 255, 0, 128);
+    });
+}, "Test that an ImageBitmapRenderingContext with alpha disabled makes the canvas opaque");
+
+promise_test(function() {
+    var srcCanvas = document.createElement('canvas');
+    srcCanvas.width = width;
+    srcCanvas.height = height;
+    var ctx = srcCanvas.getContext('2d');
+    ctx.fillStyle = 'rgba(0, 255, 0, 0.5)';
+    ctx.fillRect(0, 0, width, height);
+    return createImageBitmap(srcCanvas).then(function(image) {
+        testImageBitmap(image, {alpha: true}, 0, 255, 0, 128);
+    });
+}, "Test that an ImageBitmapRenderingContext with alpha enabled preserves the alpha");
+
+promise_test(function() {
+    var srcCanvas = document.createElement('canvas');
+    srcCanvas.width = width;
+    srcCanvas.height = height;
+    var ctx = srcCanvas.getContext('2d');
+    ctx.fillStyle = 'rgba(0, 255, 0, 0.5)';
+    ctx.fillRect(0, 0, width, height);
+    return createImageBitmap(srcCanvas).then(function(image) {
+        testImageBitmap(image, {}, 0, 255, 0, 128);
+    });
+}, "Test that the 'alpha' context creation attribute is true by default");
+
+</script>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/context-creation-offscreen.html (0 => 264459)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/context-creation-offscreen.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/context-creation-offscreen.html	2020-07-16 16:26:57 UTC (rev 264459)
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Canvas's ImageBitmapRenderingContext test</title>
+<script src=""
+<script src=""
+ <link rel="help" href=""
+<script>
+test(function() {
+    var width = 10;
+    var height = 10;
+    var canvas = new OffscreenCanvas(width, height);
+    var ctx = canvas.getContext('bitmaprenderer');
+    assert_true(ctx instanceof ImageBitmapRenderingContext);
+    assert_true("canvas" in ctx);
+    assert_equals(canvas, ctx.canvas);
+}, "Test that canvas.getContext('bitmaprenderer') returns an instance of ImageBitmapRenderingContext and ctx.canvas on a ImageBitmapRenderingContext returns the original OffscreenCanvas");
+
+</script>

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/context-creation-with-alpha-expected.txt (264458 => 264459)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/context-creation-with-alpha-expected.txt	2020-07-16 16:15:17 UTC (rev 264458)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/context-creation-with-alpha-expected.txt	2020-07-16 16:26:57 UTC (rev 264459)
@@ -1,5 +1,5 @@
 
-FAIL Test that an ImageBitmapRenderingContext with alpha disabled makes the canvas opaque assert_array_equals: expected property 1 to be 127 but got 255 (expected array [0, 127, 0, 255] got object "0,255,0,128")
-FAIL Test that an ImageBitmapRenderingContext with alpha enabled preserves the alpha assert_array_equals: expected property 3 to be 127 but got 128 (expected array [0, 255, 0, 127] got object "0,255,0,128")
-FAIL Test that the 'alpha' context creation attribute is true by default assert_array_equals: expected property 3 to be 127 but got 128 (expected array [0, 255, 0, 127] got object "0,255,0,128")
+PASS Test that an ImageBitmapRenderingContext with alpha disabled makes the canvas opaque 
+PASS Test that an ImageBitmapRenderingContext with alpha enabled preserves the alpha 
+PASS Test that the 'alpha' context creation attribute is true by default 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/context-creation-with-alpha.html (264458 => 264459)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/context-creation-with-alpha.html	2020-07-16 16:15:17 UTC (rev 264458)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/context-creation-with-alpha.html	2020-07-16 16:26:57 UTC (rev 264459)
@@ -8,24 +8,12 @@
 var width = 10;
 var height = 10;
 
-function testCanvas(ctx, r, g, b, a)
+function testImageBitmap(image, opts, expectedR, expectedG, expectedB, expectedA)
 {
-    var color = ctx.getImageData(5, 5, 1, 1).data;
-    assert_array_equals(color, [r, g, b, a]);
-}
-
-function consumeImageBitmap(image, alphaVal, expectedR, expectedG, expectedB, expectedA)
-{
     var dstCanvas = document.createElement('canvas');
     dstCanvas.width = width;
     dstCanvas.height = height;
-    var dstCtx;
-    if (alphaVal == 'true')
-        dstCtx = dstCanvas.getContext('bitmaprenderer', { alpha: true });
-    else if (alphaVal == 'false')
-        dstCtx = dstCanvas.getContext('bitmaprenderer', { alpha: false });
-    else
-        dstCtx = dstCanvas.getContext('bitmaprenderer');
+    var dstCtx = dstCanvas.getContext('bitmaprenderer', opts);
     dstCtx.transferFromImageBitmap(image);
 
     var myCanvas = document.createElement('canvas');
@@ -33,7 +21,8 @@
     myCanvas.height = height;
     var myCtx = myCanvas.getContext('2d');
     myCtx.drawImage(dstCanvas, 0, 0);
-    testCanvas(myCtx, expectedR, expectedG, expectedB, expectedA);
+    var color = myCtx.getImageData(5, 5, 1, 1).data;
+    assert_array_approx_equals(color, [expectedR, expectedG, expectedB, expectedA],1);
 }
 
 promise_test(function() {
@@ -44,7 +33,7 @@
     ctx.fillStyle = 'rgba(0, 255, 0, 0.5)';
     ctx.fillRect(0, 0, width, height);
     return createImageBitmap(srcCanvas).then(function(image) {
-        consumeImageBitmap(image, 'false', 0, 127, 0, 255);
+        testImageBitmap(image, {alpha: false}, 0, 255, 0, 128);
     });
 }, "Test that an ImageBitmapRenderingContext with alpha disabled makes the canvas opaque");
 
@@ -56,7 +45,7 @@
     ctx.fillStyle = 'rgba(0, 255, 0, 0.5)';
     ctx.fillRect(0, 0, width, height);
     return createImageBitmap(srcCanvas).then(function(image) {
-        consumeImageBitmap(image, 'true', 0, 255, 0, 127);
+        testImageBitmap(image, {alpha: true}, 0, 255, 0, 128);
     });
 }, "Test that an ImageBitmapRenderingContext with alpha enabled preserves the alpha");
 
@@ -68,7 +57,7 @@
     ctx.fillStyle = 'rgba(0, 255, 0, 0.5)';
     ctx.fillRect(0, 0, width, height);
     return createImageBitmap(srcCanvas).then(function(image) {
-        consumeImageBitmap(image, '', 0, 255, 0, 127);
+        testImageBitmap(image, {}, 0, 255, 0, 128);
     });
 }, "Test that the 'alpha' context creation attribute is true by default");
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/context-preserves-canvas.html (264458 => 264459)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/context-preserves-canvas.html	2020-07-16 16:15:17 UTC (rev 264458)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/context-preserves-canvas.html	2020-07-16 16:26:57 UTC (rev 264459)
@@ -3,19 +3,20 @@
 <title>Canvas's ImageBitmapRenderingContext test</title>
 <script src=""
 <script src=""
-<link rel="help" href=""
+<link rel="help" href=""
 <script>
-var width = 10;
-var height = 10;
-
 test(function() {
+    var width = 10;
+    var height = 10;
     var canvas = document.createElement("canvas");
     canvas.width = width;
     canvas.height = height;
     var ctx = canvas.getContext('bitmaprenderer');
     var dstCanvas = ctx.canvas;
+    assert_true("canvas" in ctx);
+    assert_equals(dstCanvas, ctx.canvas);
+    assert_equals(canvas, ctx.canvas);
     assert_equals(dstCanvas.width, width);
     assert_equals(dstCanvas.height, height);
 }, "Test that ctx.canvas on a ImageBitmapRenderingContext returns the original canvas");
-
 </script>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/toBlob-origin-clean-offscreen.sub-expected.txt (0 => 264459)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/toBlob-origin-clean-offscreen.sub-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/toBlob-origin-clean-offscreen.sub-expected.txt	2020-07-16 16:26:57 UTC (rev 264459)
@@ -0,0 +1,6 @@
+Blocked access to external URL http://www1.localhost:8800/images/red.png
+
+Harness Error (TIMEOUT), message = null
+
+TIMEOUT Test that call convertToBlob on a tainted OffscreenCanvas throws exception Test timed out
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/toBlob-origin-clean-offscreen.sub.html (0 => 264459)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/toBlob-origin-clean-offscreen.sub.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/toBlob-origin-clean-offscreen.sub.html	2020-07-16 16:26:57 UTC (rev 264459)
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>convertToBlob, OffscreenCanvas: origin-clean flag</title>
+<script src=""
+<script src=""
+<link rel="help" href=""
+<script>
+const crossOriginImageUrl = "http://{{domains[www1]}}:{{ports[http][0]}}/images/red.png";
+
+async_test(t => {
+  var img = new Image();
+  // Use a cross-origin URL.
+  img.src = ""
+
+  img._onload_ = t.step_func(e => {
+    createImageBitmap(img, 0, 0, img.width, img.height)
+    .then(t.step_func(bitmap => {
+      var canvasBitmap = new OffscreenCanvas(img.width,img.height);
+      var contextBitmap = canvasBitmap.getContext("bitmaprenderer");
+      contextBitmap.transferFromImageBitmap(bitmap);
+      promise_rejects_dom(t, 'SecurityError',
+        canvasBitmap.convertToBlob(),
+        "convertToBlob on a tainted OffscreenCanvas has to throw").then(t.step_func_done());
+    }));
+  });
+}, "Test that call convertToBlob on a tainted OffscreenCanvas throws exception");
+</script>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-ToBlob-offscreen-expected.txt (0 => 264459)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-ToBlob-offscreen-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-ToBlob-offscreen-expected.txt	2020-07-16 16:26:57 UTC (rev 264459)
@@ -0,0 +1,3 @@
+
+FAIL Test that convertToBlob works and produce the expected image promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: OffscreenCanvas"
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-ToBlob-offscreen.html (0 => 264459)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-ToBlob-offscreen.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-ToBlob-offscreen.html	2020-07-16 16:26:57 UTC (rev 264459)
@@ -0,0 +1,60 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Canvas's ImageBitmapRenderingContext test</title>
+<script src=""
+<script src=""
+<link rel="help" href=""
+<script>
+var width = 10;
+var height = 10;
+
+function testCanvas(ctx, r, g, b, a)
+{
+    var color = ctx.getImageData(5, 5, 1, 1).data;
+    assert_array_equals(color, [r, g, b, a]);
+}
+
+promise_test(function() {
+    function transferFromImageBitmapToBlobOffscreen(greenImage) {
+        var bitmapCanvas = new OffscreenCanvas(width,height);
+        var bitmapCtx = bitmapCanvas.getContext('bitmaprenderer');
+        bitmapCtx.transferFromImageBitmap(greenImage);
+
+        return bitmapCanvas.convertToBlob();
+    }
+
+    function drawBlobToCanvas(blob) {
+        // Make sure the bitmap renderer canvas is filled correctly.
+        var pngImage = new Image();
+        var myCanvasToTest = document.createElement('canvas');
+        myCanvasToTest.width = width;
+        myCanvasToTest.height = height;
+
+        // Wait for the blob img to load.
+        return new Promise(function(resolve) {
+            pngImage.src = ""
+            pngImage._onload_ = function() {
+                var myCtxToTest = myCanvasToTest.getContext('2d');
+                myCtxToTest.drawImage(pngImage, 0, 0);
+                resolve(myCtxToTest);
+            };
+        });
+    }
+
+    var greenCanvas = document.createElement('canvas');
+    greenCanvas.width = width;
+    greenCanvas.height = height;
+    var greenCtx = greenCanvas.getContext('2d');
+    greenCtx.fillStyle = '#0f0';
+    greenCtx.fillRect(0, 0, width, height);
+
+    return createImageBitmap(greenCanvas).then(
+        greenImage => transferFromImageBitmapToBlobOffscreen(greenImage)
+    ).then(
+        blob => drawBlobToCanvas(blob)
+    ).then(
+        ctx => testCanvas(ctx, 0, 255, 0, 255)
+    );
+},'Test that convertToBlob works and produce the expected image');
+
+</script>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-TransferToImageBitmap-offscreen-expected.txt (0 => 264459)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-TransferToImageBitmap-offscreen-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-TransferToImageBitmap-offscreen-expected.txt	2020-07-16 16:26:57 UTC (rev 264459)
@@ -0,0 +1,3 @@
+
+FAIL Test that transferToImageBitmap works and that resets the imagebitmap to black promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: OffscreenCanvas"
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-TransferToImageBitmap-offscreen.html (0 => 264459)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-TransferToImageBitmap-offscreen.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-TransferToImageBitmap-offscreen.html	2020-07-16 16:26:57 UTC (rev 264459)
@@ -0,0 +1,56 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Canvas's ImageBitmapRenderingContext test</title>
+<script src=""
+<script src=""
+<link rel="help" href=""
+<script>
+var width = 10;
+var height = 10;
+
+function testCanvas(bitmapCanvas, r, g, b, a)
+{
+    var myCanvas = document.createElement('canvas');
+    myCanvas.width = width;
+    myCanvas.height = height;
+    var myCtx = myCanvas.getContext('2d');
+    myCtx.drawImage(bitmapCanvas, 0, 0);
+    var color = myCtx.getImageData(5, 5, 1, 1).data;
+    assert_array_equals(color, [r, g, b, a]);
+}
+
+promise_test(function() {
+    function testTransferFromImageBitmapNullability(greenImage) {
+        var bitmapCanvas = new OffscreenCanvas(width,height);
+        var bitmapCtx = bitmapCanvas.getContext('bitmaprenderer');
+        bitmapCtx.transferFromImageBitmap(greenImage);
+
+        // Make sure the bitmap renderer canvas is filled correctly.
+        var myCanvas = document.createElement('canvas');
+        var myCtx = myCanvas.getContext('bitmaprenderer');
+        myCtx.transferFromImageBitmap(bitmapCanvas.transferToImageBitmap());
+        testCanvas(myCanvas, 0, 255, 0, 255);
+
+        // Test that after transfering for second time to ImageBitmap produces
+        // a black bitmap of the same size
+        var myCanvas2 = document.createElement('canvas');
+        var myCtx2 = myCanvas2.getContext('bitmaprenderer');
+        myCtx2.transferFromImageBitmap(bitmapCanvas.transferToImageBitmap());
+        testCanvas(myCanvas2, 0, 0, 0, 0);
+    }
+
+    var greenCanvas = document.createElement('canvas');
+    greenCanvas.width = width;
+    greenCanvas.height = height;
+    var greenCtx = greenCanvas.getContext('2d');
+    greenCtx.fillStyle = '#0f0';
+    greenCtx.fillRect(0, 0, width, height);
+
+    return Promise.all([
+        createImageBitmap(greenCanvas),
+    ]).then(([greenImage]) => {
+        testTransferFromImageBitmapNullability(greenImage);
+    });
+},'Test that transferToImageBitmap works and that resets the imagebitmap to black');
+
+</script>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-null-offscreen-expected.txt (0 => 264459)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-null-offscreen-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-null-offscreen-expected.txt	2020-07-16 16:26:57 UTC (rev 264459)
@@ -0,0 +1,3 @@
+
+FAIL Test that transferFromImageBitmap(null) discards the previously transferred image promise_test: Unhandled rejection with value: object "ReferenceError: Can't find variable: OffscreenCanvas"
+

Copied: trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-null-offscreen.html (from rev 264458, trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-null.html) (0 => 264459)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-null-offscreen.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-null-offscreen.html	2020-07-16 16:26:57 UTC (rev 264459)
@@ -0,0 +1,63 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Canvas's ImageBitmapRenderingContext test</title>
+<script src=""
+<script src=""
+<link rel="help" href=""
+<script>
+var width = 10;
+var height = 10;
+
+function testCanvas(bitmapCanvas, r, g, b, a)
+{
+    var myCanvas = document.createElement('canvas');
+    myCanvas.width = width;
+    myCanvas.height = height;
+    var myCtx = myCanvas.getContext('2d');
+    myCtx.drawImage(bitmapCanvas, 0, 0);
+    var color = myCtx.getImageData(5, 5, 1, 1).data;
+    assert_array_equals(color, [r, g, b, a]);
+}
+
+promise_test(function() {
+    function testTransferFromImageBitmapNullability(greenImage, redImage) {
+        var bitmapCanvas = new OffscreenCanvas(width,height);
+        var bitmapCtx = bitmapCanvas.getContext('bitmaprenderer');
+        bitmapCtx.transferFromImageBitmap(greenImage);
+
+        // Make sure the bitmap renderer canvas is filled correctly.
+        testCanvas(bitmapCanvas, 0, 255, 0, 255);
+
+        // Test if passing null resets the bitmap renderer canvas.
+        // Drawing the resetted canvas cannot change the destination canvas.
+        bitmapCtx.transferFromImageBitmap(null);
+        testCanvas(bitmapCanvas, 0, 0, 0, 0);
+
+        // Test if we can redraw the bitmap canvas correctly after reset.
+        bitmapCtx.transferFromImageBitmap(redImage);
+        testCanvas(bitmapCanvas, 255, 0, 0, 255);
+    }
+
+    var greenCanvas = document.createElement('canvas');
+    greenCanvas.width = width;
+    greenCanvas.height = height;
+    var greenCtx = greenCanvas.getContext('2d');
+    greenCtx.fillStyle = '#0f0';
+    greenCtx.fillRect(0, 0, width, height);
+
+    var redCanvas = document.createElement('canvas');
+    redCanvas.width = width;
+    redCanvas.height = height;
+    var redCtx = redCanvas.getContext('2d');
+    redCtx.fillStyle = '#f00';
+    redCtx.fillRect(0, 0, width, height);
+
+    return Promise.all([
+        createImageBitmap(greenCanvas),
+        createImageBitmap(redCanvas),
+    ]).then(([greenImage, redImage]) => {
+        testTransferFromImageBitmapNullability(greenImage, redImage);
+    });
+},'Test that transferFromImageBitmap(null) discards the previously transferred image');
+
+</script>

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-null.html (264458 => 264459)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-null.html	2020-07-16 16:15:17 UTC (rev 264458)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-null.html	2020-07-16 16:26:57 UTC (rev 264459)
@@ -8,9 +8,14 @@
 var width = 10;
 var height = 10;
 
-function testCanvas(ctx, r, g, b, a)
+function testCanvas(bitmapCanvas, r, g, b, a)
 {
-    var color = ctx.getImageData(5, 5, 1, 1).data;
+    var myCanvas = document.createElement('canvas');
+    myCanvas.width = width;
+    myCanvas.height = height;
+    var myCtx = myCanvas.getContext('2d');
+    myCtx.drawImage(bitmapCanvas, 0, 0);
+    var color = myCtx.getImageData(5, 5, 1, 1).data;
     assert_array_equals(color, [r, g, b, a]);
 }
 
@@ -23,31 +28,16 @@
         bitmapCtx.transferFromImageBitmap(greenImage);
 
         // Make sure the bitmap renderer canvas is filled correctly.
-        var myCanvas = document.createElement('canvas');
-        myCanvas.width = width;
-        myCanvas.height = height;
-        var myCtx = myCanvas.getContext('2d');
-        myCtx.drawImage(bitmapCanvas, 0, 0);
-        testCanvas(myCtx, 0, 255, 0, 255);
+        testCanvas(bitmapCanvas, 0, 255, 0, 255);
 
         // Test if passing null resets the bitmap renderer canvas.
         // Drawing the resetted canvas cannot change the destination canvas.
         bitmapCtx.transferFromImageBitmap(null);
-        var myCanvas2 = document.createElement('canvas');
-        myCanvas2.width = width;
-        myCanvas2.height = height;
-        var myCtx2 = myCanvas2.getContext('2d');
-        myCtx2.drawImage(bitmapCanvas, 0, 0);
-        testCanvas(myCtx2, 0, 0, 0, 0);
+        testCanvas(bitmapCanvas, 0, 0, 0, 0);
 
         // Test if we can redraw the bitmap canvas correctly after reset.
         bitmapCtx.transferFromImageBitmap(redImage);
-        var myCanvas3 = document.createElement('canvas');
-        myCanvas3.width = width;
-        myCanvas3.height = height;
-        var myCtx3 = myCanvas3.getContext('2d');
-        myCtx3.drawImage(bitmapCanvas, 0, 0);
-        testCanvas(myCtx3, 255, 0, 0, 255);
+        testCanvas(bitmapCanvas, 255, 0, 0, 255);
     }
 
     var greenCanvas = document.createElement('canvas');

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/transferFromImageBitmap-detached.html (264458 => 264459)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/transferFromImageBitmap-detached.html	2020-07-16 16:15:17 UTC (rev 264458)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/transferFromImageBitmap-detached.html	2020-07-16 16:26:57 UTC (rev 264459)
@@ -19,7 +19,7 @@
         // The image should be detached after transferFromImageBitmap.
         assert_equals(image.width, 0);
         assert_equals(image.height, 0);
-        assert_throws("InvalidStateError", function() { dstCtx.transferFromImageBitmap(image); });
+        assert_throws_dom("InvalidStateError", function() { dstCtx.transferFromImageBitmap(image); });
     }
 
     var srcCanvas = document.createElement('canvas');

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/w3c-import.log (264458 => 264459)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/w3c-import.log	2020-07-16 16:15:17 UTC (rev 264458)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/w3c-import.log	2020-07-16 16:26:57 UTC (rev 264459)
@@ -1,7 +1,7 @@
 The tests in this directory were imported from the W3C repository.
 Do NOT modify these tests directly in WebKit.
 Instead, create a pull request on the WPT github:
-	https://github.com/w3c/web-platform-tests
+	https://github.com/web-platform-tests/wpt
 
 Then run the Tools/Scripts/import-w3c-tests in WebKit to reimport
 
@@ -14,9 +14,16 @@
 None
 ------------------------------------------------------------------------
 List of files:
+/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/META.yml
 /LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/bitmaprenderer-as-imagesource.html
+/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/context-creation-offscreen-with-alpha.html
+/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/context-creation-offscreen.html
 /LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/context-creation-with-alpha.html
 /LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/context-creation.html
 /LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/context-preserves-canvas.html
+/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/toBlob-origin-clean-offscreen.sub.html
+/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-ToBlob-offscreen.html
+/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-TransferToImageBitmap-offscreen.html
+/LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-null-offscreen.html
 /LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/tranferFromImageBitmap-null.html
 /LayoutTests/imported/w3c/web-platform-tests/imagebitmap-renderingcontext/transferFromImageBitmap-detached.html
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to