Title: [201724] trunk
Revision
201724
Author
[email protected]
Date
2016-06-06 13:30:05 -0700 (Mon, 06 Jun 2016)

Log Message

Support createPattern(HTMLVideoElement, const String& repetitionType)
https://bugs.webkit.org/show_bug.cgi?id=149984
<rdar://problem/23058823>

Patch by George Ruan <[email protected]> on 2016-06-06
Reviewed by Dean Jackson.

Source/WebCore:

Support functionality for HTMLVideoElement argument for
CanvasRenderingContext2D::createPattern*()

Tests: fast/canvas/canvas-createPattern-video-invalid.html
       fast/canvas/canvas-createPattern-video-loading.html
       fast/canvas/canvas-createPattern-video-modify.html
       http/tests/security/canvas-remote-read-remote-video-allowed-anonymous.html
       http/tests/security/canvas-remote-read-remote-video-allowed-with-credentials.html
       http/tests/security/canvas-remote-read-remote-video-blocked-no-crossorigin.html
       http/tests/security/canvas-remote-read-remote-video-localhost.html
       http/tests/security/canvas-remote-read-remote-video-redirect.html
       media/video-canvas-createPattern.html

* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::createPattern): Implement
functionality of description
* html/canvas/CanvasRenderingContext2D.h:
* html/canvas/CanvasRenderingContext2D.idl:

LayoutTests:

* fast/canvas/canvas-createPattern-video-invalid-expected.txt: Added.
* fast/canvas/canvas-createPattern-video-invalid.html: Added. Test
behavior when given invalid arguments.
* fast/canvas/canvas-createPattern-video-loading-expected.txt: Added.
* fast/canvas/canvas-createPattern-video-loading.html: Added. Tests
behavior before video loaded, right after it's loaded, and after being
played.
* fast/canvas/canvas-createPattern-video-modify-expected.txt: Added.
* fast/canvas/canvas-createPattern-video-modify.html: Added. Tests
that modifying the video after calling the createPattern() function
does not affect the pattern rendered or to be rendered.
*
http/tests/security/canvas-remote-read-remote-image-allowed-expected.txt:
Fix typo.
*
http/tests/security/canvas-remote-read-remote-image-allowed-with-credentials-expected.txt:
Fix typo.
*
http/tests/security/canvas-remote-read-remote-image-allowed-with-credentials.html:
Fix typo.
* http/tests/security/canvas-remote-read-remote-image-allowed.html:
Fix typo.
*
http/tests/security/canvas-remote-read-remote-image-blocked-no-crossorigin-expected.txt:
Fix typo.
*
http/tests/security/canvas-remote-read-remote-image-blocked-no-crossorigin.html:
Fix typo.
* http/tests/security/canvas-remote-read-remote-video-allowed-anonymous-expected.txt: Added.
*
http/tests/security/canvas-remote-read-remote-video-allowed-anonymous.html:
Added. This test will fail as CORS is not implemented for media yet.
Tests that data can be retrieved from canvas even when tainted if CORS
is enabled with anonymous.
* http/tests/security/canvas-remote-read-remote-video-allowed-with-credentials-expected.txt: Added.
*
http/tests/security/canvas-remote-read-remote-video-allowed-with-credentials.html:
Added. This test will fail as CORS is not implemented for media yet.
Tests that data can be retrieved from canvas even when tainted if CORS
is enabled with credentials.
* http/tests/security/canvas-remote-read-remote-video-blocked-no-crossorigin-expected.txt: Added.
*
http/tests/security/canvas-remote-read-remote-video-blocked-no-crossorigin.html:
Added. Ensures that data cannot be retrieved from a tainted canvas if
no cross origin is enabled.
* http/tests/security/canvas-remote-read-remote-video-localhost-expected.txt: Added.
* http/tests/security/canvas-remote-read-remote-video-localhost.html:
Added. Ensures that localhost is blocked like http.
* http/tests/security/canvas-remote-read-remote-video-redirect-expected.txt: Added.
* http/tests/security/canvas-remote-read-remote-video-redirect.html:
Added. Ensures that redirects are blocked.
* http/tests/security/resources/canvas-video-crossorigin.js: Added.
Includes common functions used to test the CORS of canvas for video.
*
http/tests/security/resources/video-cross-origin-allow-credentials.php:
Added. Script that serves test video for
canvas-remote-read-remote-video-allowed-with-credentials.html.
* media/video-canvas-createPattern-expected.txt: Added.
* media/video-canvas-createPattern.html: Added. Naive test that
ensures functionality of createPattern() with HTMLVideoElement
argument.
* platform/ios-simulator-wk1/TestExpectations: Added
canvas-remote-read-remote-video-allowed-anonymous.html and
canvas-remote-read-remote-video-allowed-with-credentials.html.
* platform/ios-simulator-wk2/TestExpectations: Same as wk1.
* platform/mac/TestExpectations: Same as wk1.
* platform/mac/media/video-canvas-createPattern-expected.png: Added.
* platform/win/TestExpectations: Same as wk1.
* platform/wk2/TestExpectations: Same as wk1.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (201723 => 201724)


--- trunk/LayoutTests/ChangeLog	2016-06-06 20:19:35 UTC (rev 201723)
+++ trunk/LayoutTests/ChangeLog	2016-06-06 20:30:05 UTC (rev 201724)
@@ -1,3 +1,81 @@
+2016-06-06  George Ruan  <[email protected]>
+
+        Support createPattern(HTMLVideoElement, const String& repetitionType)
+        https://bugs.webkit.org/show_bug.cgi?id=149984
+        <rdar://problem/23058823>
+
+        Reviewed by Dean Jackson.
+
+        * fast/canvas/canvas-createPattern-video-invalid-expected.txt: Added.
+        * fast/canvas/canvas-createPattern-video-invalid.html: Added. Test
+        behavior when given invalid arguments.
+        * fast/canvas/canvas-createPattern-video-loading-expected.txt: Added.
+        * fast/canvas/canvas-createPattern-video-loading.html: Added. Tests
+        behavior before video loaded, right after it's loaded, and after being
+        played.
+        * fast/canvas/canvas-createPattern-video-modify-expected.txt: Added.
+        * fast/canvas/canvas-createPattern-video-modify.html: Added. Tests
+        that modifying the video after calling the createPattern() function
+        does not affect the pattern rendered or to be rendered.
+        *
+        http/tests/security/canvas-remote-read-remote-image-allowed-expected.txt:
+        Fix typo.
+        *
+        http/tests/security/canvas-remote-read-remote-image-allowed-with-credentials-expected.txt:
+        Fix typo.
+        *
+        http/tests/security/canvas-remote-read-remote-image-allowed-with-credentials.html:
+        Fix typo.
+        * http/tests/security/canvas-remote-read-remote-image-allowed.html:
+        Fix typo.
+        *
+        http/tests/security/canvas-remote-read-remote-image-blocked-no-crossorigin-expected.txt:
+        Fix typo.
+        *
+        http/tests/security/canvas-remote-read-remote-image-blocked-no-crossorigin.html:
+        Fix typo.
+        * http/tests/security/canvas-remote-read-remote-video-allowed-anonymous-expected.txt: Added.
+        *
+        http/tests/security/canvas-remote-read-remote-video-allowed-anonymous.html:
+        Added. This test will fail as CORS is not implemented for media yet.
+        Tests that data can be retrieved from canvas even when tainted if CORS
+        is enabled with anonymous.
+        * http/tests/security/canvas-remote-read-remote-video-allowed-with-credentials-expected.txt: Added.
+        *
+        http/tests/security/canvas-remote-read-remote-video-allowed-with-credentials.html:
+        Added. This test will fail as CORS is not implemented for media yet.
+        Tests that data can be retrieved from canvas even when tainted if CORS
+        is enabled with credentials.
+        * http/tests/security/canvas-remote-read-remote-video-blocked-no-crossorigin-expected.txt: Added.
+        *
+        http/tests/security/canvas-remote-read-remote-video-blocked-no-crossorigin.html:
+        Added. Ensures that data cannot be retrieved from a tainted canvas if
+        no cross origin is enabled.
+        * http/tests/security/canvas-remote-read-remote-video-localhost-expected.txt: Added.
+        * http/tests/security/canvas-remote-read-remote-video-localhost.html:
+        Added. Ensures that localhost is blocked like http.
+        * http/tests/security/canvas-remote-read-remote-video-redirect-expected.txt: Added.
+        * http/tests/security/canvas-remote-read-remote-video-redirect.html:
+        Added. Ensures that redirects are blocked.
+        * http/tests/security/resources/canvas-video-crossorigin.js: Added.
+        Includes common functions used to test the CORS of canvas for video.
+        *
+        http/tests/security/resources/video-cross-origin-allow-credentials.php:
+        Added. Script that serves test video for
+        canvas-remote-read-remote-video-allowed-with-credentials.html.
+        * media/video-canvas-createPattern-expected.txt: Added.
+        * media/video-canvas-createPattern.html: Added. Naive test that
+        ensures functionality of createPattern() with HTMLVideoElement
+        argument.
+        * platform/ios-simulator-wk1/TestExpectations: Added
+        canvas-remote-read-remote-video-allowed-anonymous.html and
+        canvas-remote-read-remote-video-allowed-with-credentials.html.
+        * platform/ios-simulator-wk2/TestExpectations: Same as wk1.
+        * platform/mac/TestExpectations: Same as wk1.
+        * platform/mac/media/video-canvas-createPattern-expected.png: Added.
+        * platform/win/TestExpectations: Same as wk1.
+        * platform/wk2/TestExpectations: Same as wk1.
+
 2016-06-06  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r201706.

Added: trunk/LayoutTests/fast/canvas/canvas-createPattern-video-invalid-expected.txt (0 => 201724)


--- trunk/LayoutTests/fast/canvas/canvas-createPattern-video-invalid-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/canvas-createPattern-video-invalid-expected.txt	2016-06-06 20:30:05 UTC (rev 201724)
@@ -0,0 +1,17 @@
+Test the handling of invalid arguments in canvas createPattern().
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS context.createPattern(undefined, undefined) threw exception TypeError: Type error.
+PASS context.createPattern(undefined, null) threw exception TypeError: Type error.
+PASS context.createPattern(undefined, '') threw exception TypeError: Type error.
+PASS context.createPattern(undefined, 'repeat') threw exception TypeError: Type error.
+PASS context.createPattern(null, undefined) threw exception TypeError: Type error.
+PASS context.createPattern(null, null) threw exception TypeError: Type error.
+PASS context.createPattern(null, '') threw exception TypeError: Type error.
+PASS context.createPattern(null, 'repeat') threw exception TypeError: Type error.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/canvas/canvas-createPattern-video-invalid.html (0 => 201724)


--- trunk/LayoutTests/fast/canvas/canvas-createPattern-video-invalid.html	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/canvas-createPattern-video-invalid.html	2016-06-06 20:30:05 UTC (rev 201724)
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src=""
+</head>
+<body>
+<script>
+    description("Test the handling of invalid arguments in canvas createPattern().")
+
+    var context = document.createElement('canvas').getContext('2d');
+
+    shouldThrow("context.createPattern(undefined, undefined)", "'TypeError: Type error'");
+    shouldThrow("context.createPattern(undefined, null)", "'TypeError: Type error'");
+    shouldThrow("context.createPattern(undefined, '')", "'TypeError: Type error'");
+    shouldThrow("context.createPattern(undefined, 'repeat')", "'TypeError: Type error'");
+
+    shouldThrow("context.createPattern(null, undefined)", "'TypeError: Type error'");
+    shouldThrow("context.createPattern(null, null)", "'TypeError: Type error'");
+    shouldThrow("context.createPattern(null, '')", "'TypeError: Type error'");
+    shouldThrow("context.createPattern(null, 'repeat')", "'TypeError: Type error'");
+</script>
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/fast/canvas/canvas-createPattern-video-loading-expected.txt (0 => 201724)


--- trunk/LayoutTests/fast/canvas/canvas-createPattern-video-loading-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/canvas-createPattern-video-loading-expected.txt	2016-06-06 20:30:05 UTC (rev 201724)
@@ -0,0 +1,82 @@
+Test the behavior of 2d canvas createPattern as a video is loaded
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS document.createElement('canvas').getContext('2d').createPattern(video, 'repeat') is null
+PASS buffer[0] is within 2 of 194
+PASS buffer[1] is within 2 of 193
+PASS buffer[2] is within 2 of 14
+PASS buffer[0] is within 2 of 194
+PASS buffer[1] is within 2 of 193
+PASS buffer[2] is within 2 of 14
+PASS buffer[0] is within 2 of 194
+PASS buffer[1] is within 2 of 193
+PASS buffer[2] is within 2 of 14
+PASS buffer[0] is within 2 of 194
+PASS buffer[1] is within 2 of 193
+PASS buffer[2] is within 2 of 14
+PASS buffer[0] is within 2 of 17
+PASS buffer[1] is within 2 of 197
+PASS buffer[2] is within 2 of 195
+PASS buffer[0] is within 2 of 17
+PASS buffer[1] is within 2 of 197
+PASS buffer[2] is within 2 of 195
+PASS buffer[0] is within 2 of 17
+PASS buffer[1] is within 2 of 197
+PASS buffer[2] is within 2 of 195
+PASS buffer[0] is within 2 of 17
+PASS buffer[1] is within 2 of 197
+PASS buffer[2] is within 2 of 195
+PASS buffer[0] is within 2 of 20
+PASS buffer[1] is within 2 of 200
+PASS buffer[2] is within 2 of 18
+PASS buffer[0] is within 2 of 20
+PASS buffer[1] is within 2 of 200
+PASS buffer[2] is within 2 of 18
+PASS buffer[0] is within 2 of 20
+PASS buffer[1] is within 2 of 200
+PASS buffer[2] is within 2 of 18
+PASS buffer[0] is within 2 of 20
+PASS buffer[1] is within 2 of 200
+PASS buffer[2] is within 2 of 18
+PASS buffer[0] is within 2 of 194
+PASS buffer[1] is within 2 of 193
+PASS buffer[2] is within 2 of 14
+PASS buffer[0] is within 2 of 194
+PASS buffer[1] is within 2 of 193
+PASS buffer[2] is within 2 of 14
+PASS buffer[0] is within 2 of 194
+PASS buffer[1] is within 2 of 193
+PASS buffer[2] is within 2 of 14
+PASS buffer[0] is within 2 of 194
+PASS buffer[1] is within 2 of 193
+PASS buffer[2] is within 2 of 14
+PASS buffer[0] is within 2 of 17
+PASS buffer[1] is within 2 of 197
+PASS buffer[2] is within 2 of 195
+PASS buffer[0] is within 2 of 17
+PASS buffer[1] is within 2 of 197
+PASS buffer[2] is within 2 of 195
+PASS buffer[0] is within 2 of 17
+PASS buffer[1] is within 2 of 197
+PASS buffer[2] is within 2 of 195
+PASS buffer[0] is within 2 of 17
+PASS buffer[1] is within 2 of 197
+PASS buffer[2] is within 2 of 195
+PASS buffer[0] is within 2 of 20
+PASS buffer[1] is within 2 of 200
+PASS buffer[2] is within 2 of 18
+PASS buffer[0] is within 2 of 20
+PASS buffer[1] is within 2 of 200
+PASS buffer[2] is within 2 of 18
+PASS buffer[0] is within 2 of 20
+PASS buffer[1] is within 2 of 200
+PASS buffer[2] is within 2 of 18
+PASS buffer[0] is within 2 of 20
+PASS buffer[1] is within 2 of 200
+PASS buffer[2] is within 2 of 18
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/canvas/canvas-createPattern-video-loading.html (0 => 201724)


--- trunk/LayoutTests/fast/canvas/canvas-createPattern-video-loading.html	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/canvas-createPattern-video-loading.html	2016-06-06 20:30:05 UTC (rev 201724)
@@ -0,0 +1,86 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src=""
+    <script src=""
+</head>
+<body>
+<script>
+    description("Test the behavior of 2d canvas createPattern as a video is loaded");
+
+    var buffer;
+    var expectedResults = [
+        // Each entry is formatted as [x, y, r, g, b].
+        [40, 165, 194, 193, 14], // Represents yellow north west tile.
+        [355, 165, 194, 193, 14], // Represents yellow north east tile.
+        [40, 403, 194, 193, 14], // Represents yellow south west tile.
+        [355, 403, 194, 193, 14], // Represents yellow south east tile.
+
+        [56, 165, 17, 197, 195], // Represents blue/cyan north west tile.
+        [371, 165, 17, 197, 195], // Represents blue/cyan north east tile.
+        [56, 403, 17, 197, 195], // Represents blue/cyan south west tile.
+        [371, 403, 17, 197, 195], // Represents blue/cyan south east tile.
+
+        [73, 165, 20, 200, 18], // Represents green north west tile.
+        [388, 165, 20, 200, 18], // Represents green north east tile.
+        [73, 403, 20, 200, 18], // Represents green south west tile.
+        [388, 403, 20, 200, 18], // Represents green south east tile.
+    ];
+
+    var canvases = document.createElement("div");
+    document.body.appendChild(canvases);
+
+    var video = document.createElement("video");
+    video.addEventListener("loadeddata", loadeddata);
+    video.addEventListener("playing", playing);
+
+    shouldBeNull("document.createElement('canvas').getContext('2d').createPattern(video, 'repeat')");
+
+    video.src = "" "../../media/content/test");
+
+    function checkPixels(context, x, y, r, g, b, tolerance)
+    {
+        buffer = context.getImageData(x, y, 1, 1).data;
+        shouldBeCloseTo("buffer[0]", r, tolerance);
+        shouldBeCloseTo("buffer[1]", g, tolerance);
+        shouldBeCloseTo("buffer[2]", b, tolerance);
+    }
+
+    function drawImageToCanvasAndCheckPixels()
+    {
+        var canvas = document.createElement("canvas");
+        canvas.width = 2.5 * video.videoWidth;
+        canvas.height = 2.5 * video.videoHeight;
+        var context = canvas.getContext("2d");
+        document.body.appendChild(canvas);
+
+        context.fillStyle = context.createPattern(video, "repeat");
+        context.fillRect(0, 0, canvas.width, canvas.height);
+
+        expectedResults.forEach(function(element) {
+            checkPixels(context, element[0], element[1], element[2], element[3], element[4], 2);
+        });
+    }
+
+    function loadeddata()
+    {
+        drawImageToCanvasAndCheckPixels();
+
+        video.currentTime = 1;
+        video.play();
+    }
+
+    function playing()
+    {
+        video.pause();
+
+        drawImageToCanvasAndCheckPixels();
+
+        finishJSTest();
+    }
+
+    window.jsTestIsAsync = true;
+</script>
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/fast/canvas/canvas-createPattern-video-modify-expected.txt (0 => 201724)


--- trunk/LayoutTests/fast/canvas/canvas-createPattern-video-modify-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/canvas-createPattern-video-modify-expected.txt	2016-06-06 20:30:05 UTC (rev 201724)
@@ -0,0 +1,21 @@
+Tests that modifying the video used in createPattern does not affect the pattern rendered.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS buffer[0] is within 2 of 194
+PASS buffer[1] is within 2 of 193
+PASS buffer[2] is within 2 of 14
+PASS buffer[0] is within 2 of 194
+PASS buffer[1] is within 2 of 193
+PASS buffer[2] is within 2 of 14
+PASS buffer[0] is within 2 of 194
+PASS buffer[1] is within 2 of 193
+PASS buffer[2] is within 2 of 14
+PASS buffer[0] is within 2 of 194
+PASS buffer[1] is within 2 of 193
+PASS buffer[2] is within 2 of 14
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/canvas/canvas-createPattern-video-modify.html (0 => 201724)


--- trunk/LayoutTests/fast/canvas/canvas-createPattern-video-modify.html	                        (rev 0)
+++ trunk/LayoutTests/fast/canvas/canvas-createPattern-video-modify.html	2016-06-06 20:30:05 UTC (rev 201724)
@@ -0,0 +1,62 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src=""
+    <script src=""
+</head>
+<body>
+<script>
+    description("Tests that modifying the video used in createPattern does not affect the pattern rendered.");
+
+    var buffer;
+    var canvas, context;
+    var modified = false;
+    var expectedResults = [
+        // Each entry is formatted as [x, y, r, g, b].
+        [40, 165, 194, 193, 14], // Represents yellow north west tile.
+        [355, 165, 194, 193, 14], // Represents yellow north east tile.
+        [40, 403, 194, 193, 14], // Represents yellow south west tile.
+        [355, 403, 194, 193, 14], // Represents yellow south east tile.
+    ];
+
+    var video = document.createElement("video");
+    video.addEventListener("loadeddata", loadeddata);
+    video.src = "" "../../media/content/test");
+
+    function loadeddata()
+    {
+        if (!modified) {
+            canvas = document.createElement("canvas");
+            canvas.width = 2.5 * video.videoWidth;
+            canvas.height = 2.5 * video.videoHeight;
+            document.body.appendChild(canvas);
+
+            context = canvas.getContext("2d");
+            context.fillStyle = context.createPattern(video, "repeat");
+
+            video.src = "" "../../media/content/counting");
+            modified = !modified;
+        } else {
+            context.fillRect(0, 0, canvas.width, canvas.height);
+
+            expectedResults.forEach(function(element) {
+                checkPixels(context, element[0], element[1], element[2], element[3], element[4], 2);
+            });
+
+            finishJSTest();
+        }
+    }
+
+    function checkPixels(context, x, y, r, g, b, tolerance)
+    {
+        buffer = context.getImageData(x, y, 1, 1).data;
+        shouldBeCloseTo("buffer[0]", r, tolerance);
+        shouldBeCloseTo("buffer[1]", g, tolerance);
+        shouldBeCloseTo("buffer[2]", b, tolerance);
+    }
+
+    window.jsTestIsAsync = true;
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-image-allowed-expected.txt (201723 => 201724)


--- trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-image-allowed-expected.txt	2016-06-06 20:19:35 UTC (rev 201723)
+++ trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-image-allowed-expected.txt	2016-06-06 20:30:05 UTC (rev 201724)
@@ -6,8 +6,8 @@
 Tainted canvas:
 PASS: Calling getImageData() from a canvas tainted by a remote image was allowed.
 PASS: Calling toDataURL() on a canvas CORS-untainted by a remote image was allowed.
-PASS: Calling getImageData() from a canvas tainted by a CORS-untained canvas was allowed.
-PASS: Calling toDataURL() on a canvas CORS-untainted by a CORS-untained canvas was allowed.
+PASS: Calling getImageData() from a canvas tainted by a CORS-untainted canvas was allowed.
+PASS: Calling toDataURL() on a canvas CORS-untainted by a CORS-untainted canvas was allowed.
 PASS: Calling getImageData() from a canvas tainted by a remote image tainted pattern was allowed.
 PASS: Calling toDataURL() on a canvas CORS-untainted by a remote image tainted pattern was allowed.
 PASS: Calling getImageData() from a canvas tainted by a CORS-untainted canvas pattern was allowed.

Modified: trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-image-allowed-with-credentials-expected.txt (201723 => 201724)


--- trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-image-allowed-with-credentials-expected.txt	2016-06-06 20:19:35 UTC (rev 201723)
+++ trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-image-allowed-with-credentials-expected.txt	2016-06-06 20:30:05 UTC (rev 201724)
@@ -6,8 +6,8 @@
 Tainted canvas:
 PASS: Calling getImageData() from a canvas tainted by a remote image was allowed.
 PASS: Calling toDataURL() on a canvas CORS-untainted by a remote image was allowed.
-PASS: Calling getImageData() from a canvas tainted by a CORS-untained canvas was allowed.
-PASS: Calling toDataURL() on a canvas CORS-untainted by a CORS-untained canvas was allowed.
+PASS: Calling getImageData() from a canvas tainted by a CORS-untainted canvas was allowed.
+PASS: Calling toDataURL() on a canvas CORS-untainted by a CORS-untainted canvas was allowed.
 PASS: Calling getImageData() from a canvas tainted by a remote image tainted pattern was allowed.
 PASS: Calling toDataURL() on a canvas CORS-untainted by a remote image tainted pattern was allowed.
 PASS: Calling getImageData() from a canvas tainted by a CORS-untainted canvas pattern was allowed.

Modified: trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-image-allowed-with-credentials.html (201723 => 201724)


--- trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-image-allowed-with-credentials.html	2016-06-06 20:19:35 UTC (rev 201723)
+++ trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-image-allowed-with-credentials.html	2016-06-06 20:30:05 UTC (rev 201724)
@@ -76,7 +76,7 @@
     var context = canvas.getContext("2d");
     context.drawImage(dirtyCanvas, 0, 0, 100, 100);
 
-    test(canvas, "CORS-untained canvas");
+    test(canvas, "CORS-untainted canvas");
 
     // Test reading after using a tainted pattern
     canvas = document.createElement("canvas");

Modified: trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-image-allowed.html (201723 => 201724)


--- trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-image-allowed.html	2016-06-06 20:19:35 UTC (rev 201723)
+++ trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-image-allowed.html	2016-06-06 20:30:05 UTC (rev 201724)
@@ -76,7 +76,7 @@
     var context = canvas.getContext("2d");
     context.drawImage(dirtyCanvas, 0, 0, 100, 100);
 
-    test(canvas, "CORS-untained canvas");
+    test(canvas, "CORS-untainted canvas");
 
     // Test reading after using a tainted pattern
     canvas = document.createElement("canvas");

Modified: trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-image-blocked-no-crossorigin-expected.txt (201723 => 201724)


--- trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-image-blocked-no-crossorigin-expected.txt	2016-06-06 20:19:35 UTC (rev 201723)
+++ trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-image-blocked-no-crossorigin-expected.txt	2016-06-06 20:30:05 UTC (rev 201724)
@@ -10,8 +10,8 @@
 Tainted canvas:
 PASS: Calling getImageData() from a canvas tainted by a remote image was not allowed - Threw error: Error: SecurityError: DOM Exception 18.
 PASS: Calling toDataURL() on a canvas tainted by a remote image was not allowed - Threw error: Error: SecurityError: DOM Exception 18.
-PASS: Calling getImageData() from a canvas tainted by a tained canvas was not allowed - Threw error: Error: SecurityError: DOM Exception 18.
-PASS: Calling toDataURL() on a canvas tainted by a tained canvas was not allowed - Threw error: Error: SecurityError: DOM Exception 18.
+PASS: Calling getImageData() from a canvas tainted by a tainted canvas was not allowed - Threw error: Error: SecurityError: DOM Exception 18.
+PASS: Calling toDataURL() on a canvas tainted by a tainted canvas was not allowed - Threw error: Error: SecurityError: DOM Exception 18.
 PASS: Calling getImageData() from a canvas tainted by a remote image tainted pattern was not allowed - Threw error: Error: SecurityError: DOM Exception 18.
 PASS: Calling toDataURL() on a canvas tainted by a remote image tainted pattern was not allowed - Threw error: Error: SecurityError: DOM Exception 18.
 PASS: Calling getImageData() from a canvas tainted by a tainted canvas pattern was not allowed - Threw error: Error: SecurityError: DOM Exception 18.

Modified: trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-image-blocked-no-crossorigin.html (201723 => 201724)


--- trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-image-blocked-no-crossorigin.html	2016-06-06 20:19:35 UTC (rev 201723)
+++ trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-image-blocked-no-crossorigin.html	2016-06-06 20:30:05 UTC (rev 201724)
@@ -76,7 +76,7 @@
     var context = canvas.getContext("2d");
     context.drawImage(dirtyCanvas, 0, 0, 100, 100);
 
-    test(canvas, "tained canvas");
+    test(canvas, "tainted canvas");
 
     // Test reading after using a tainted pattern
     canvas = document.createElement("canvas");

Added: trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-allowed-anonymous-expected.txt (0 => 201724)


--- trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-allowed-anonymous-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-allowed-anonymous-expected.txt	2016-06-06 20:30:05 UTC (rev 201724)
@@ -0,0 +1,16 @@
+Ensure that data can be retrieved from a canvas even when tainted by a remote video resource if CORS is enabled with anonymous.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Testing data retrieval on an untainted canvas:
+PASS canvas.getContext('2d').getImageData(0, 0, 100, 100) did not throw exception.
+PASS canvas.toDataURL() did not throw exception.
+
+Testing data retrieval on a canvas tainted by a remote video pattern:
+PASS context.getImageData(0, 0, 100, 100) did not throw exception.
+PASS canvas.toDataURL() did not throw exception.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-allowed-anonymous.html (0 => 201724)


--- trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-allowed-anonymous.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-allowed-anonymous.html	2016-06-06 20:30:05 UTC (rev 201724)
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src=""
+    <script src=""
+    <script src=""
+</head>
+<body>
+<pre id="console"></pre>
+<script>
+    description("Ensure that data can be retrieved from a canvas even when tainted by a remote video resource if CORS is enabled with anonymous.");
+
+    function test()
+    {
+        testDataRetrievalAllowed();
+        finishJSTest();
+    }
+
+    var video = document.createElement("video");
+    video.addEventListener("loadeddata", test);
+
+    video.crossOrigin = "anonymous";
+    var mediaFile = findMediaFile("video", "../../media/resources/test");
+    var type = mimeTypeForExtension(mediaFile.split('.').pop());
+    video.src = "" + mediaFile + "&type=" + type;
+
+    window.jsTestIsAsync = true;
+</script>
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-allowed-with-credentials-expected.txt (0 => 201724)


--- trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-allowed-with-credentials-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-allowed-with-credentials-expected.txt	2016-06-06 20:30:05 UTC (rev 201724)
@@ -0,0 +1,16 @@
+Ensure that data can be retrieved from a canvas even when tainted by a remote video resource if CORS is enabled with use-credentials.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Testing data retrieval on an untainted canvas:
+PASS canvas.getContext('2d').getImageData(0, 0, 100, 100) did not throw exception.
+PASS canvas.toDataURL() did not throw exception.
+
+Testing data retrieval on a canvas tainted by a remote video pattern:
+PASS context.getImageData(0, 0, 100, 100) did not throw exception.
+PASS canvas.toDataURL() did not throw exception.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-allowed-with-credentials.html (0 => 201724)


--- trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-allowed-with-credentials.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-allowed-with-credentials.html	2016-06-06 20:30:05 UTC (rev 201724)
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src=""
+    <script src=""
+    <script src=""
+</head>
+<body>
+<pre id="console"></pre>
+<script>
+    description("Ensure that data can be retrieved from a canvas even when tainted by a remote video resource if CORS is enabled with use-credentials.");
+
+    function test()
+    {
+        testDataRetrievalAllowed();
+        finishJSTest();
+    }
+
+    var video = document.createElement("video");
+    video.addEventListener("loadeddata", test);
+
+    video.crossOrigin = "use-credentials";
+    var mediaFile = findMediaFile("video", "../../media/resources/test");
+    var type = mimeTypeForExtension(mediaFile.split('.').pop());
+    video.src = "" + mediaFile + "&type=" + type;
+    
+    window.jsTestIsAsync = true;
+</script>
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-blocked-no-crossorigin-expected.txt (0 => 201724)


--- trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-blocked-no-crossorigin-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-blocked-no-crossorigin-expected.txt	2016-06-06 20:30:05 UTC (rev 201724)
@@ -0,0 +1,17 @@
+CONSOLE MESSAGE: line 1: Unable to get image data from canvas because the canvas has been tainted by cross-origin data.
+Ensure that data cannot be retrieved from a canvas tainted by a remote video resource when CORS is not enabled.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Testing data retrieval on an untainted canvas:
+PASS canvas.getContext('2d').getImageData(0, 0, 100, 100) did not throw exception.
+PASS canvas.toDataURL() did not throw exception.
+
+Testing data retrieval on a canvas tainted by a pattern generated by a remote video:
+PASS context.getImageData(0, 0, 100, 100) threw exception Error: SecurityError: DOM Exception 18.
+PASS canvas.toDataURL() threw exception Error: SecurityError: DOM Exception 18.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-blocked-no-crossorigin.html (0 => 201724)


--- trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-blocked-no-crossorigin.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-blocked-no-crossorigin.html	2016-06-06 20:30:05 UTC (rev 201724)
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src=""
+    <script src=""
+    <script src=""
+</head>
+<body>
+<pre id="console"></pre>
+<script>
+    description("Ensure that data cannot be retrieved from a canvas tainted by a remote video resource when CORS is not enabled.");
+
+    function test()
+    {
+        testDataRetrievalForbidden("remote video");
+        finishJSTest();
+    }
+
+    var video = document.createElement("video");
+    video.addEventListener("loadeddata", test);
+
+    var mediaFile = findMediaFile("video", "../../media/resources/test");
+    var type = mimeTypeForExtension(mediaFile.split('.').pop());
+    video.src = "" + mediaFile + "&type=" + type;
+    
+    window.jsTestIsAsync = true;
+</script>
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-localhost-expected.txt (0 => 201724)


--- trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-localhost-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-localhost-expected.txt	2016-06-06 20:30:05 UTC (rev 201724)
@@ -0,0 +1,17 @@
+CONSOLE MESSAGE: line 1: Unable to get image data from canvas because the canvas has been tainted by cross-origin data.
+Ensure that data cannot be retrieved from a canvas tainted by a localhost video resource when CORS is not enabled.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Testing data retrieval on an untainted canvas:
+PASS canvas.getContext('2d').getImageData(0, 0, 100, 100) did not throw exception.
+PASS canvas.toDataURL() did not throw exception.
+
+Testing data retrieval on a canvas tainted by a pattern generated by a localhost video resource:
+PASS context.getImageData(0, 0, 100, 100) threw exception Error: SecurityError: DOM Exception 18.
+PASS canvas.toDataURL() threw exception Error: SecurityError: DOM Exception 18.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-localhost.html (0 => 201724)


--- trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-localhost.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-localhost.html	2016-06-06 20:30:05 UTC (rev 201724)
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src=""
+    <script src=""
+    <script src=""
+</head>
+<body>
+<pre id="console"></pre>
+<script>
+    description("Ensure that data cannot be retrieved from a canvas tainted by a localhost video resource when CORS is not enabled.");
+
+    function test()
+    {
+        testDataRetrievalForbidden("localhost video resource");
+        finishJSTest();
+    }
+
+    var video = document.createElement("video");
+    video.addEventListener("loadeddata", test);
+    video.src = ""
+    
+    window.jsTestIsAsync = true;
+</script>
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-redirect-expected.txt (0 => 201724)


--- trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-redirect-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-redirect-expected.txt	2016-06-06 20:30:05 UTC (rev 201724)
@@ -0,0 +1,17 @@
+CONSOLE MESSAGE: line 1: Unable to get image data from canvas because the canvas has been tainted by cross-origin data.
+Ensure that data cannot be retrieved from a canvas tainted by a video resource obtained via redirection when CORS is not enabled.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Testing data retrieval on an untainted canvas:
+PASS canvas.getContext('2d').getImageData(0, 0, 100, 100) did not throw exception.
+PASS canvas.toDataURL() did not throw exception.
+
+Testing data retrieval on a canvas tainted by a pattern generated by a redirected video resource:
+PASS context.getImageData(0, 0, 100, 100) threw exception Error: SecurityError: DOM Exception 18.
+PASS canvas.toDataURL() threw exception Error: SecurityError: DOM Exception 18.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-redirect.html (0 => 201724)


--- trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-redirect.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-redirect.html	2016-06-06 20:30:05 UTC (rev 201724)
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <script src=""
+    <script src=""
+    <script src=""
+</head>
+<body>
+<pre id="console"></pre>
+<script>
+    description("Ensure that data cannot be retrieved from a canvas tainted by a video resource obtained via redirection when CORS is not enabled.");
+
+    function test()
+    {
+        testDataRetrievalForbidden("redirected video resource");
+        finishJSTest();
+    }
+
+    var video = document.createElement("video");
+    video.addEventListener("loadeddata", test);
+    video.src = "" "resources/test")}`;
+    
+    window.jsTestIsAsync = true;
+</script>
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/security/resources/canvas-video-crossorigin.js (0 => 201724)


--- trunk/LayoutTests/http/tests/security/resources/canvas-video-crossorigin.js	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/resources/canvas-video-crossorigin.js	2016-06-06 20:30:05 UTC (rev 201724)
@@ -0,0 +1,48 @@
+// The following functions depend on functions in js-test-pre.js.
+var canvas, context;
+
+function testDataRetrievalAllowed() {
+    // Control tests.
+    debug("Testing data retrieval on an untainted canvas:");
+    canvas = document.createElement("canvas");
+    canvas.width = 100;
+    canvas.height = 100;
+    
+    shouldNotThrow("canvas.getContext('2d').getImageData(0, 0, 100, 100)");
+    shouldNotThrow("canvas.toDataURL()");
+
+    // CORS tests.
+    debug("<br />Testing data retrieval on a canvas tainted by a remote video pattern:");
+    canvas = document.createElement("canvas");
+    canvas.width = 100;
+    canvas.height = 100;
+    context = canvas.getContext("2d");
+    context.fillStyle = context.createPattern(video, "repeat");
+    context.fillRect(0, 0, 100, 100);
+
+    shouldThrow("context.getImageData(0, 0, 100, 100)", "'Error: SecurityError: DOM Exception 18'");
+    shouldThrow("canvas.toDataURL()", "'Error: SecurityError: DOM Exception 18'");
+}
+
+function testDataRetrievalForbidden(description) {
+    // Control tests.
+    debug("Testing data retrieval on an untainted canvas:");
+    canvas = document.createElement("canvas");
+    canvas.width = 100;
+    canvas.height = 100;
+    
+    shouldNotThrow("canvas.getContext('2d').getImageData(0, 0, 100, 100)");
+    shouldNotThrow("canvas.toDataURL()");
+
+    // CORS tests.
+    debug("<br />Testing data retrieval on a canvas tainted by a pattern generated by a " + description + ":");
+    canvas = document.createElement("canvas");
+    canvas.width = 100;
+    canvas.height = 100;
+    context = canvas.getContext("2d");
+    context.fillStyle = context.createPattern(video, "repeat");
+    context.fillRect(0, 0, 100, 100);
+
+    shouldThrow("context.getImageData(0, 0, 100, 100)", "'Error: SecurityError: DOM Exception 18'");
+    shouldThrow("canvas.toDataURL()", "'Error: SecurityError: DOM Exception 18'");
+}
\ No newline at end of file

Added: trunk/LayoutTests/http/tests/security/resources/video-cross-origin-allow-credentials.php (0 => 201724)


--- trunk/LayoutTests/http/tests/security/resources/video-cross-origin-allow-credentials.php	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/resources/video-cross-origin-allow-credentials.php	2016-06-06 20:30:05 UTC (rev 201724)
@@ -0,0 +1,14 @@
+<?php
+
+header("Access-Control-Allow-Origin: http://127.0.0.1:8000");
+header("Access-Control-Allow-Credentials: true");
+
+if ($_SERVER['REQUEST_METHOD'] == "OPTIONS") {
+    header("Access-Control-Allow-Methods: GET");
+    header("Access-Control-Allow-Headers: origin, accept-encoding, referer, range");
+    exit;
+}
+
+@include("../../media/resources/serve-video.php");
+
+?>

Added: trunk/LayoutTests/media/video-canvas-createPattern-expected.txt (0 => 201724)


--- trunk/LayoutTests/media/video-canvas-createPattern-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/video-canvas-createPattern-expected.txt	2016-06-06 20:30:05 UTC (rev 201724)
@@ -0,0 +1,56 @@
+
+EVENT(canplaythrough)
+EVENT(seeked)
+Saw close enough to (194, 193, 14) at (40, 165) OK
+Saw close enough to (194, 193, 14) at (355, 165) OK
+Saw close enough to (194, 193, 14) at (40, 403) OK
+Saw close enough to (194, 193, 14) at (355, 403) OK
+Saw close enough to (17, 197, 195) at (56, 165) OK
+Saw close enough to (17, 197, 195) at (371, 165) OK
+Saw close enough to (17, 197, 195) at (56, 403) OK
+Saw close enough to (17, 197, 195) at (371, 403) OK
+Saw close enough to (20, 200, 18) at (73, 165) OK
+Saw close enough to (20, 200, 18) at (388, 165) OK
+Saw close enough to (20, 200, 18) at (73, 403) OK
+Saw close enough to (20, 200, 18) at (388, 403) OK
+EVENT(seeked)
+Saw close enough to (194, 193, 14) at (40, 165) OK
+Saw close enough to (194, 193, 14) at (355, 165) OK
+Saw close enough to (194, 193, 14) at (40, 403) OK
+Saw close enough to (194, 193, 14) at (355, 403) OK
+Saw close enough to (17, 197, 195) at (56, 165) OK
+Saw close enough to (17, 197, 195) at (371, 165) OK
+Saw close enough to (17, 197, 195) at (56, 403) OK
+Saw close enough to (17, 197, 195) at (371, 403) OK
+Saw close enough to (20, 200, 18) at (73, 165) OK
+Saw close enough to (20, 200, 18) at (388, 165) OK
+Saw close enough to (20, 200, 18) at (73, 403) OK
+Saw close enough to (20, 200, 18) at (388, 403) OK
+EVENT(seeked)
+Saw close enough to (194, 193, 14) at (40, 165) OK
+Saw close enough to (194, 193, 14) at (355, 165) OK
+Saw close enough to (194, 193, 14) at (40, 403) OK
+Saw close enough to (194, 193, 14) at (355, 403) OK
+Saw close enough to (17, 197, 195) at (56, 165) OK
+Saw close enough to (17, 197, 195) at (371, 165) OK
+Saw close enough to (17, 197, 195) at (56, 403) OK
+Saw close enough to (17, 197, 195) at (371, 403) OK
+Saw close enough to (20, 200, 18) at (73, 165) OK
+Saw close enough to (20, 200, 18) at (388, 165) OK
+Saw close enough to (20, 200, 18) at (73, 403) OK
+Saw close enough to (20, 200, 18) at (388, 403) OK
+EVENT(seeked)
+Saw close enough to (194, 193, 14) at (40, 165) OK
+Saw close enough to (194, 193, 14) at (355, 165) OK
+Saw close enough to (194, 193, 14) at (40, 403) OK
+Saw close enough to (194, 193, 14) at (355, 403) OK
+Saw close enough to (17, 197, 195) at (56, 165) OK
+Saw close enough to (17, 197, 195) at (371, 165) OK
+Saw close enough to (17, 197, 195) at (56, 403) OK
+Saw close enough to (17, 197, 195) at (371, 403) OK
+Saw close enough to (20, 200, 18) at (73, 165) OK
+Saw close enough to (20, 200, 18) at (388, 165) OK
+Saw close enough to (20, 200, 18) at (73, 403) OK
+Saw close enough to (20, 200, 18) at (388, 403) OK
+END OF TEST
+

Added: trunk/LayoutTests/media/video-canvas-createPattern.html (0 => 201724)


--- trunk/LayoutTests/media/video-canvas-createPattern.html	                        (rev 0)
+++ trunk/LayoutTests/media/video-canvas-createPattern.html	2016-06-06 20:30:05 UTC (rev 201724)
@@ -0,0 +1,86 @@
+<html>
+    <head>
+        <title>Create patterns on canvas using video</title>
+        <script src=""
+        <script src=""
+        <script>
+            var video;
+            var numberOfSeeks = 4;
+
+            var expectedResults = [
+                // Each entry is formatted as [x, y, r, g, b].
+                [40, 165, 194, 193, 14], // Represents yellow north west tile.
+                [355, 165, 194, 193, 14], // Represents yellow north east tile.
+                [40, 403, 194, 193, 14], // Represents yellow south west tile.
+                [355, 403, 194, 193, 14], // Represents yellow south east tile.
+
+                [56, 165, 17, 197, 195], // Represents blue/cyan north west tile.
+                [371, 165, 17, 197, 195], // Represents blue/cyan north east tile.
+                [56, 403, 17, 197, 195], // Represents blue/cyan south west tile.
+                [371, 403, 17, 197, 195], // Represents blue/cyan south east tile.
+
+                [73, 165, 20, 200, 18], // Represents green north west tile.
+                [388, 165, 20, 200, 18], // Represents green north east tile.
+                [73, 403, 20, 200, 18], // Represents green south west tile.
+                [388, 403, 20, 200, 18], // Represents green south east tile.
+            ]
+
+            if (window.testRunner) {
+                testRunner.dumpAsText(true);
+                testRunner.waitUntilDone();
+            }
+
+            function checkColorAtLocation(ctx, x, y, r, g, b, tolerance)
+            {
+                var buffer = ctx.getImageData(x, y, 1, 1).data;
+                if (Math.abs(buffer[0] - r) < tolerance
+                    && Math.abs(buffer[1] - g) < tolerance
+                    && Math.abs(buffer[2] - b) < tolerance)
+                    logResult(true, `Saw close enough to (${r}, ${g}, ${b}) at (${x}, ${y})`);
+                else
+                    logResult(false, `Expected (${r}, ${g}, ${b}) at (${x}, ${y}) but saw (${buffer[0]}, ${buffer[1]}, ${buffer[2]})`);
+            }
+
+            function drawAndInsertFrame()
+            {
+                var canvas = document.createElement('canvas');
+                canvas.width = 2 * video.videoWidth;
+                canvas.height = 2 * video.videoHeight;
+                var ctx = canvas.getContext('2d');
+                ctx.fillStyle = ctx.createPattern(video, 'repeat');
+                ctx.fillRect(0, 0, canvas.width, canvas.height);
+                document.getElementById('canvases').appendChild(canvas);
+
+                expectedResults.forEach(function(element) {
+                    checkColorAtLocation(ctx, element[0], element[1], element[2], element[3], element[4], 2);
+                });
+
+                // Ensure that the test seeks a couple of times.
+                if (--numberOfSeeks) {
+                    video.currentTime += 0.24;
+                    return;
+                }
+
+                endTest();
+            }
+
+            function canplaythrough()
+            {
+                video.currentTime = 1;
+            }
+
+            function start()
+            {
+                findMediaElement();
+                waitForEvent('canplaythrough', canplaythrough);
+                waitForEvent('seeked', drawAndInsertFrame);
+                video.src = "" 'content/test');
+            }
+        </script>
+    </head>
+
+    <body _onload_="start()">
+        <video id="video"></video>
+        <div id="canvases"></div>
+    </body>
+</html>

Modified: trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations (201723 => 201724)


--- trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations	2016-06-06 20:19:35 UTC (rev 201723)
+++ trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations	2016-06-06 20:30:05 UTC (rev 201724)
@@ -1097,6 +1097,8 @@
 http/tests/security/aboutBlank/xss-DENIED-navigate-opener-document-write.html [ Failure ]
 http/tests/security/aboutBlank/xss-DENIED-navigate-opener-_javascript_-url.html [ Failure ]
 http/tests/security/aboutBlank/xss-DENIED-set-opener.html [ Failure ]
+http/tests/security/canvas-remote-read-remote-video-allowed-anonymous.html [ Failure ]
+http/tests/security/canvas-remote-read-remote-video-allowed-with-credentials.html [ Failure ]
 http/tests/security/contentSecurityPolicy/object-src-url-allowed.html [ Failure ]
 http/tests/security/contentSecurityPolicy/object-src-url-blocked.html [ Failure ]
 http/tests/security/cross-origin-indexeddb-allowed.html [ Failure ]

Modified: trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations (201723 => 201724)


--- trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations	2016-06-06 20:19:35 UTC (rev 201723)
+++ trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations	2016-06-06 20:30:05 UTC (rev 201724)
@@ -500,6 +500,8 @@
 http/tests/security/aboutBlank/xss-DENIED-navigate-opener-document-write.html
 http/tests/security/aboutBlank/xss-DENIED-navigate-opener-_javascript_-url.html
 http/tests/security/aboutBlank/xss-DENIED-set-opener.html
+http/tests/security/canvas-remote-read-remote-video-allowed-anonymous.html [ Failure ]
+http/tests/security/canvas-remote-read-remote-video-allowed-with-credentials.html [ Failure ]
 http/tests/security/cookies/third-party-cookie-blocking-user-action.html
 http/tests/security/isolatedWorld/cross-origin-xhr.html
 http/tests/security/isolatedWorld/userGestureEvents.html

Modified: trunk/LayoutTests/platform/mac/TestExpectations (201723 => 201724)


--- trunk/LayoutTests/platform/mac/TestExpectations	2016-06-06 20:19:35 UTC (rev 201723)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2016-06-06 20:30:05 UTC (rev 201724)
@@ -353,6 +353,8 @@
 webkit.org/b/82979 canvas/philip/tests/2d.text.draw.align.center.html [ Pass Failure ]
 
 # No CORS support for media elements is implemented yet.
+http/tests/security/canvas-remote-read-remote-video-allowed-anonymous.html [ Failure ]
+http/tests/security/canvas-remote-read-remote-video-allowed-with-credentials.html [ Failure ]
 http/tests/security/video-cross-origin-readback.html
 http/tests/security/video-cross-origin-accessfailure.html
 

Added: trunk/LayoutTests/platform/mac/media/video-canvas-createPattern-expected.png


(Binary files differ)
Property changes on: trunk/LayoutTests/platform/mac/media/video-canvas-createPattern-expected.png ___________________________________________________________________

Added: svn:mime-type

Modified: trunk/LayoutTests/platform/win/TestExpectations (201723 => 201724)


--- trunk/LayoutTests/platform/win/TestExpectations	2016-06-06 20:19:35 UTC (rev 201723)
+++ trunk/LayoutTests/platform/win/TestExpectations	2016-06-06 20:30:05 UTC (rev 201724)
@@ -898,6 +898,8 @@
 webkit.org/b/103442 media/W3C/video/networkState/networkState_during_progress.html [ Skip ]
 
 # No CORS support for media elements is implemented yet.
+http/tests/security/canvas-remote-read-remote-video-allowed-anonymous.html [ Failure ]
+http/tests/security/canvas-remote-read-remote-video-allowed-with-credentials.html [ Failure ]
 http/tests/security/video-cross-origin-readback.html [ Skip ]
 
 # Requires ENABLE(MEDIA_CAPTURE)

Modified: trunk/LayoutTests/platform/wk2/TestExpectations (201723 => 201724)


--- trunk/LayoutTests/platform/wk2/TestExpectations	2016-06-06 20:19:35 UTC (rev 201723)
+++ trunk/LayoutTests/platform/wk2/TestExpectations	2016-06-06 20:30:05 UTC (rev 201724)
@@ -382,6 +382,8 @@
 editing/pasteboard/emacs-cntl-y-001.html
 
 # No CORS support for media elements is implemented yet.
+http/tests/security/canvas-remote-read-remote-video-allowed-anonymous.html [ Failure ]
+http/tests/security/canvas-remote-read-remote-video-allowed-with-credentials.html [ Failure ]
 http/tests/security/video-cross-origin-readback.html
 
 # X-Content-Type-Options (ENABLE_NOSNIFF) is not enabled.

Modified: trunk/Source/WebCore/ChangeLog (201723 => 201724)


--- trunk/Source/WebCore/ChangeLog	2016-06-06 20:19:35 UTC (rev 201723)
+++ trunk/Source/WebCore/ChangeLog	2016-06-06 20:30:05 UTC (rev 201724)
@@ -1,3 +1,30 @@
+2016-06-06  George Ruan  <[email protected]>
+
+        Support createPattern(HTMLVideoElement, const String& repetitionType)
+        https://bugs.webkit.org/show_bug.cgi?id=149984
+        <rdar://problem/23058823>
+
+        Reviewed by Dean Jackson.
+
+        Support functionality for HTMLVideoElement argument for
+        CanvasRenderingContext2D::createPattern*()
+
+        Tests: fast/canvas/canvas-createPattern-video-invalid.html
+               fast/canvas/canvas-createPattern-video-loading.html
+               fast/canvas/canvas-createPattern-video-modify.html
+               http/tests/security/canvas-remote-read-remote-video-allowed-anonymous.html
+               http/tests/security/canvas-remote-read-remote-video-allowed-with-credentials.html
+               http/tests/security/canvas-remote-read-remote-video-blocked-no-crossorigin.html
+               http/tests/security/canvas-remote-read-remote-video-localhost.html
+               http/tests/security/canvas-remote-read-remote-video-redirect.html
+               media/video-canvas-createPattern.html
+
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::CanvasRenderingContext2D::createPattern): Implement
+        functionality of description
+        * html/canvas/CanvasRenderingContext2D.h:
+        * html/canvas/CanvasRenderingContext2D.idl:
+
 2016-06-06  Csaba Osztrogonác  <[email protected]>
 
         Fix the !ENABLE(SHADOW_DOM) && !ENABLE(DETAILS_ELEMENT) build

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (201723 => 201724)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2016-06-06 20:19:35 UTC (rev 201723)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2016-06-06 20:30:05 UTC (rev 201724)
@@ -33,6 +33,7 @@
 #include "config.h"
 #include "CanvasRenderingContext2D.h"
 
+#include "BitmapImage.h"
 #include "CSSFontSelector.h"
 #include "CSSParser.h"
 #include "CSSPropertyNames.h"
@@ -46,6 +47,7 @@
 #include "FloatQuad.h"
 #include "HTMLImageElement.h"
 #include "HTMLVideoElement.h"
+#include "ImageBuffer.h"
 #include "ImageData.h"
 #include "RenderElement.h"
 #include "RenderImage.h"
@@ -1795,7 +1797,34 @@
         return nullptr;
     return CanvasPattern::create(canvas.copiedImage(), repeatX, repeatY, canvas.originClean());
 }
+    
+#if ENABLE(VIDEO)
+RefPtr<CanvasPattern> CanvasRenderingContext2D::createPattern(HTMLVideoElement& videoElement, const String& repetitionType, ExceptionCode& ec)
+{
+    if (videoElement.readyState() < HTMLMediaElement::HAVE_CURRENT_DATA)
+        return nullptr;
+    
+    bool repeatX, repeatY;
+    ec = 0;
+    CanvasPattern::parseRepetitionType(repetitionType, repeatX, repeatY, ec);
+    if (ec)
+        return nullptr;
+    
+    checkOrigin(&videoElement);
+    bool originClean = canvas()->originClean();
 
+#if USE(CG) || (ENABLE(ACCELERATED_2D_CANVAS) && USE(GSTREAMER_GL) && USE(CAIRO))
+    if (auto nativeImage = videoElement.nativeImageForCurrentTime())
+        return CanvasPattern::create(BitmapImage::create(WTFMove(nativeImage)), repeatX, repeatY, originClean);
+#endif
+
+    auto imageBuffer = ImageBuffer::create(size(videoElement), drawingContext() ? drawingContext()->renderingMode() : Accelerated);
+    videoElement.paintCurrentFrameInContext(imageBuffer->context(), FloatRect(FloatPoint(), size(videoElement)));
+    
+    return CanvasPattern::create(ImageBuffer::sinkIntoImage(WTFMove(imageBuffer), Unscaled), repeatX, repeatY, originClean);
+}
+#endif
+
 void CanvasRenderingContext2D::didDrawEntireCanvas()
 {
     didDraw(FloatRect(FloatPoint::zero(), canvas()->size()), CanvasDidDrawApplyClip);

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h (201723 => 201724)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h	2016-06-06 20:19:35 UTC (rev 201723)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h	2016-06-06 20:30:05 UTC (rev 201724)
@@ -182,6 +182,9 @@
     RefPtr<CanvasGradient> createRadialGradient(float x0, float y0, float r0, float x1, float y1, float r1, ExceptionCode&);
     RefPtr<CanvasPattern> createPattern(HTMLImageElement&, const String& repetitionType, ExceptionCode&);
     RefPtr<CanvasPattern> createPattern(HTMLCanvasElement&, const String& repetitionType, ExceptionCode&);
+#if ENABLE(VIDEO)
+    RefPtr<CanvasPattern> createPattern(HTMLVideoElement&, const String& repetitionType, ExceptionCode&);
+#endif
 
     RefPtr<ImageData> createImageData(RefPtr<ImageData>&&, ExceptionCode&) const;
     RefPtr<ImageData> createImageData(float width, float height, ExceptionCode&) const;

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl (201723 => 201724)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl	2016-06-06 20:19:35 UTC (rev 201723)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl	2016-06-06 20:30:05 UTC (rev 201724)
@@ -177,6 +177,7 @@
 
     [RaisesException] CanvasPattern createPattern(HTMLCanvasElement canvas, [TreatNullAs=EmptyString] DOMString repetitionType);
     [RaisesException] CanvasPattern createPattern(HTMLImageElement image, [TreatNullAs=EmptyString] DOMString repetitionType);
+    [Conditional=VIDEO, RaisesException] CanvasPattern? createPattern(HTMLVideoElement video, [TreatNullAs=EmptyString] DOMString repetitionType);
     [RaisesException] ImageData createImageData(ImageData? imagedata);
     [RaisesException] ImageData createImageData(float sw, float sh);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to