<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[201724] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/201724">201724</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-06-06 13:30:05 -0700 (Mon, 06 Jun 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Support createPattern(HTMLVideoElement, const String&amp; repetitionType)
https://bugs.webkit.org/show_bug.cgi?id=149984
&lt;rdar://problem/23058823&gt;

Patch by George Ruan &lt;gruan@apple.com&gt; 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.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycanvasremotereadremoteimageallowedexpectedtxt">trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-image-allowed-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycanvasremotereadremoteimageallowedwithcredentialsexpectedtxt">trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-image-allowed-with-credentials-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycanvasremotereadremoteimageallowedwithcredentialshtml">trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-image-allowed-with-credentials.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycanvasremotereadremoteimageallowedhtml">trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-image-allowed.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycanvasremotereadremoteimageblockednocrossoriginexpectedtxt">trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-image-blocked-no-crossorigin-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycanvasremotereadremoteimageblockednocrossoriginhtml">trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-image-blocked-no-crossorigin.html</a></li>
<li><a href="#trunkLayoutTestsplatformiossimulatorwk1TestExpectations">trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformiossimulatorwk2TestExpectations">trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformmacTestExpectations">trunk/LayoutTests/platform/mac/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformwinTestExpectations">trunk/LayoutTests/platform/win/TestExpectations</a></li>
<li><a href="#trunkLayoutTestsplatformwk2TestExpectations">trunk/LayoutTests/platform/wk2/TestExpectations</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlcanvasCanvasRenderingContext2Dcpp">trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlcanvasCanvasRenderingContext2Dh">trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h</a></li>
<li><a href="#trunkSourceWebCorehtmlcanvasCanvasRenderingContext2Didl">trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsfastcanvascanvascreatePatternvideoinvalidexpectedtxt">trunk/LayoutTests/fast/canvas/canvas-createPattern-video-invalid-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastcanvascanvascreatePatternvideoinvalidhtml">trunk/LayoutTests/fast/canvas/canvas-createPattern-video-invalid.html</a></li>
<li><a href="#trunkLayoutTestsfastcanvascanvascreatePatternvideoloadingexpectedtxt">trunk/LayoutTests/fast/canvas/canvas-createPattern-video-loading-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastcanvascanvascreatePatternvideoloadinghtml">trunk/LayoutTests/fast/canvas/canvas-createPattern-video-loading.html</a></li>
<li><a href="#trunkLayoutTestsfastcanvascanvascreatePatternvideomodifyexpectedtxt">trunk/LayoutTests/fast/canvas/canvas-createPattern-video-modify-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastcanvascanvascreatePatternvideomodifyhtml">trunk/LayoutTests/fast/canvas/canvas-createPattern-video-modify.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycanvasremotereadremotevideoallowedanonymousexpectedtxt">trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-allowed-anonymous-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycanvasremotereadremotevideoallowedanonymoushtml">trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-allowed-anonymous.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycanvasremotereadremotevideoallowedwithcredentialsexpectedtxt">trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-allowed-with-credentials-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycanvasremotereadremotevideoallowedwithcredentialshtml">trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-allowed-with-credentials.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycanvasremotereadremotevideoblockednocrossoriginexpectedtxt">trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-blocked-no-crossorigin-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycanvasremotereadremotevideoblockednocrossoriginhtml">trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-blocked-no-crossorigin.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycanvasremotereadremotevideolocalhostexpectedtxt">trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-localhost-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycanvasremotereadremotevideolocalhosthtml">trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-localhost.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycanvasremotereadremotevideoredirectexpectedtxt">trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-redirect-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycanvasremotereadremotevideoredirecthtml">trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-redirect.html</a></li>
<li><a href="#trunkLayoutTestshttptestssecurityresourcescanvasvideocrossoriginjs">trunk/LayoutTests/http/tests/security/resources/canvas-video-crossorigin.js</a></li>
<li><a href="#trunkLayoutTestshttptestssecurityresourcesvideocrossoriginallowcredentialsphp">trunk/LayoutTests/http/tests/security/resources/video-cross-origin-allow-credentials.php</a></li>
<li><a href="#trunkLayoutTestsmediavideocanvascreatePatternexpectedtxt">trunk/LayoutTests/media/video-canvas-createPattern-expected.txt</a></li>
<li><a href="#trunkLayoutTestsmediavideocanvascreatePatternhtml">trunk/LayoutTests/media/video-canvas-createPattern.html</a></li>
<li><a href="#trunkLayoutTestsplatformmacmediavideocanvascreatePatternexpectedpng">trunk/LayoutTests/platform/mac/media/video-canvas-createPattern-expected.png</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (201723 => 201724)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-06-06 20:19:35 UTC (rev 201723)
+++ trunk/LayoutTests/ChangeLog        2016-06-06 20:30:05 UTC (rev 201724)
</span><span class="lines">@@ -1,3 +1,81 @@
</span><ins>+2016-06-06  George Ruan  &lt;gruan@apple.com&gt;
+
+        Support createPattern(HTMLVideoElement, const String&amp; repetitionType)
+        https://bugs.webkit.org/show_bug.cgi?id=149984
+        &lt;rdar://problem/23058823&gt;
+
+        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.
+
</ins><span class="cx"> 2016-06-06  Commit Queue  &lt;commit-queue@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, rolling out r201706.
</span></span></pre></div>
<a id="trunkLayoutTestsfastcanvascanvascreatePatternvideoinvalidexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/canvas/canvas-createPattern-video-invalid-expected.txt (0 => 201724)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+Test the handling of invalid arguments in canvas createPattern().
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+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
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcanvascanvascreatePatternvideoinvalidhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/canvas/canvas-createPattern-video-invalid.html (0 => 201724)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,24 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;script&gt;
+    description(&quot;Test the handling of invalid arguments in canvas createPattern().&quot;)
+
+    var context = document.createElement('canvas').getContext('2d');
+
+    shouldThrow(&quot;context.createPattern(undefined, undefined)&quot;, &quot;'TypeError: Type error'&quot;);
+    shouldThrow(&quot;context.createPattern(undefined, null)&quot;, &quot;'TypeError: Type error'&quot;);
+    shouldThrow(&quot;context.createPattern(undefined, '')&quot;, &quot;'TypeError: Type error'&quot;);
+    shouldThrow(&quot;context.createPattern(undefined, 'repeat')&quot;, &quot;'TypeError: Type error'&quot;);
+
+    shouldThrow(&quot;context.createPattern(null, undefined)&quot;, &quot;'TypeError: Type error'&quot;);
+    shouldThrow(&quot;context.createPattern(null, null)&quot;, &quot;'TypeError: Type error'&quot;);
+    shouldThrow(&quot;context.createPattern(null, '')&quot;, &quot;'TypeError: Type error'&quot;);
+    shouldThrow(&quot;context.createPattern(null, 'repeat')&quot;, &quot;'TypeError: Type error'&quot;);
+&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcanvascanvascreatePatternvideoloadingexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/canvas/canvas-createPattern-video-loading-expected.txt (0 => 201724)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,82 @@
</span><ins>+Test the behavior of 2d canvas createPattern as a video is loaded
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+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
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcanvascanvascreatePatternvideoloadinghtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/canvas/canvas-createPattern-video-loading.html (0 => 201724)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,86 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+    &lt;script src=&quot;../../media/media-file.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;script&gt;
+    description(&quot;Test the behavior of 2d canvas createPattern as a video is loaded&quot;);
+
+    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(&quot;div&quot;);
+    document.body.appendChild(canvases);
+
+    var video = document.createElement(&quot;video&quot;);
+    video.addEventListener(&quot;loadeddata&quot;, loadeddata);
+    video.addEventListener(&quot;playing&quot;, playing);
+
+    shouldBeNull(&quot;document.createElement('canvas').getContext('2d').createPattern(video, 'repeat')&quot;);
+
+    video.src = findMediaFile(&quot;video&quot;, &quot;../../media/content/test&quot;);
+
+    function checkPixels(context, x, y, r, g, b, tolerance)
+    {
+        buffer = context.getImageData(x, y, 1, 1).data;
+        shouldBeCloseTo(&quot;buffer[0]&quot;, r, tolerance);
+        shouldBeCloseTo(&quot;buffer[1]&quot;, g, tolerance);
+        shouldBeCloseTo(&quot;buffer[2]&quot;, b, tolerance);
+    }
+
+    function drawImageToCanvasAndCheckPixels()
+    {
+        var canvas = document.createElement(&quot;canvas&quot;);
+        canvas.width = 2.5 * video.videoWidth;
+        canvas.height = 2.5 * video.videoHeight;
+        var context = canvas.getContext(&quot;2d&quot;);
+        document.body.appendChild(canvas);
+
+        context.fillStyle = context.createPattern(video, &quot;repeat&quot;);
+        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;
+&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcanvascanvascreatePatternvideomodifyexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/canvas/canvas-createPattern-video-modify-expected.txt (0 => 201724)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,21 @@
</span><ins>+Tests that modifying the video used in createPattern does not affect the pattern rendered.
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+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
+
</ins></span></pre></div>
<a id="trunkLayoutTestsfastcanvascanvascreatePatternvideomodifyhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/fast/canvas/canvas-createPattern-video-modify.html (0 => 201724)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,62 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;script src=&quot;../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+    &lt;script src=&quot;../../media/media-file.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;script&gt;
+    description(&quot;Tests that modifying the video used in createPattern does not affect the pattern rendered.&quot;);
+
+    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(&quot;video&quot;);
+    video.addEventListener(&quot;loadeddata&quot;, loadeddata);
+    video.src = findMediaFile(&quot;video&quot;, &quot;../../media/content/test&quot;);
+
+    function loadeddata()
+    {
+        if (!modified) {
+            canvas = document.createElement(&quot;canvas&quot;);
+            canvas.width = 2.5 * video.videoWidth;
+            canvas.height = 2.5 * video.videoHeight;
+            document.body.appendChild(canvas);
+
+            context = canvas.getContext(&quot;2d&quot;);
+            context.fillStyle = context.createPattern(video, &quot;repeat&quot;);
+
+            video.src = findMediaFile(&quot;video&quot;, &quot;../../media/content/counting&quot;);
+            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(&quot;buffer[0]&quot;, r, tolerance);
+        shouldBeCloseTo(&quot;buffer[1]&quot;, g, tolerance);
+        shouldBeCloseTo(&quot;buffer[2]&quot;, b, tolerance);
+    }
+
+    window.jsTestIsAsync = true;
+&lt;/script&gt;
+&lt;script src=&quot;../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycanvasremotereadremoteimageallowedexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-image-allowed-expected.txt (201723 => 201724)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -6,8 +6,8 @@
</span><span class="cx"> Tainted canvas:
</span><span class="cx"> PASS: Calling getImageData() from a canvas tainted by a remote image was allowed.
</span><span class="cx"> PASS: Calling toDataURL() on a canvas CORS-untainted by a remote image was allowed.
</span><del>-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.
</del><ins>+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.
</ins><span class="cx"> PASS: Calling getImageData() from a canvas tainted by a remote image tainted pattern was allowed.
</span><span class="cx"> PASS: Calling toDataURL() on a canvas CORS-untainted by a remote image tainted pattern was allowed.
</span><span class="cx"> PASS: Calling getImageData() from a canvas tainted by a CORS-untainted canvas pattern was allowed.
</span></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycanvasremotereadremoteimageallowedwithcredentialsexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-image-allowed-with-credentials-expected.txt (201723 => 201724)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -6,8 +6,8 @@
</span><span class="cx"> Tainted canvas:
</span><span class="cx"> PASS: Calling getImageData() from a canvas tainted by a remote image was allowed.
</span><span class="cx"> PASS: Calling toDataURL() on a canvas CORS-untainted by a remote image was allowed.
</span><del>-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.
</del><ins>+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.
</ins><span class="cx"> PASS: Calling getImageData() from a canvas tainted by a remote image tainted pattern was allowed.
</span><span class="cx"> PASS: Calling toDataURL() on a canvas CORS-untainted by a remote image tainted pattern was allowed.
</span><span class="cx"> PASS: Calling getImageData() from a canvas tainted by a CORS-untainted canvas pattern was allowed.
</span></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycanvasremotereadremoteimageallowedwithcredentialshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-image-allowed-with-credentials.html (201723 => 201724)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -76,7 +76,7 @@
</span><span class="cx">     var context = canvas.getContext(&quot;2d&quot;);
</span><span class="cx">     context.drawImage(dirtyCanvas, 0, 0, 100, 100);
</span><span class="cx"> 
</span><del>-    test(canvas, &quot;CORS-untained canvas&quot;);
</del><ins>+    test(canvas, &quot;CORS-untainted canvas&quot;);
</ins><span class="cx"> 
</span><span class="cx">     // Test reading after using a tainted pattern
</span><span class="cx">     canvas = document.createElement(&quot;canvas&quot;);
</span></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycanvasremotereadremoteimageallowedhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-image-allowed.html (201723 => 201724)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -76,7 +76,7 @@
</span><span class="cx">     var context = canvas.getContext(&quot;2d&quot;);
</span><span class="cx">     context.drawImage(dirtyCanvas, 0, 0, 100, 100);
</span><span class="cx"> 
</span><del>-    test(canvas, &quot;CORS-untained canvas&quot;);
</del><ins>+    test(canvas, &quot;CORS-untainted canvas&quot;);
</ins><span class="cx"> 
</span><span class="cx">     // Test reading after using a tainted pattern
</span><span class="cx">     canvas = document.createElement(&quot;canvas&quot;);
</span></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycanvasremotereadremoteimageblockednocrossoriginexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-image-blocked-no-crossorigin-expected.txt (201723 => 201724)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -10,8 +10,8 @@
</span><span class="cx"> Tainted canvas:
</span><span class="cx"> PASS: Calling getImageData() from a canvas tainted by a remote image was not allowed - Threw error: Error: SecurityError: DOM Exception 18.
</span><span class="cx"> PASS: Calling toDataURL() on a canvas tainted by a remote image was not allowed - Threw error: Error: SecurityError: DOM Exception 18.
</span><del>-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.
</del><ins>+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.
</ins><span class="cx"> PASS: Calling getImageData() from a canvas tainted by a remote image tainted pattern was not allowed - Threw error: Error: SecurityError: DOM Exception 18.
</span><span class="cx"> PASS: Calling toDataURL() on a canvas tainted by a remote image tainted pattern was not allowed - Threw error: Error: SecurityError: DOM Exception 18.
</span><span class="cx"> PASS: Calling getImageData() from a canvas tainted by a tainted canvas pattern was not allowed - Threw error: Error: SecurityError: DOM Exception 18.
</span></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycanvasremotereadremoteimageblockednocrossoriginhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-image-blocked-no-crossorigin.html (201723 => 201724)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -76,7 +76,7 @@
</span><span class="cx">     var context = canvas.getContext(&quot;2d&quot;);
</span><span class="cx">     context.drawImage(dirtyCanvas, 0, 0, 100, 100);
</span><span class="cx"> 
</span><del>-    test(canvas, &quot;tained canvas&quot;);
</del><ins>+    test(canvas, &quot;tainted canvas&quot;);
</ins><span class="cx"> 
</span><span class="cx">     // Test reading after using a tainted pattern
</span><span class="cx">     canvas = document.createElement(&quot;canvas&quot;);
</span></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycanvasremotereadremotevideoallowedanonymousexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-allowed-anonymous-expected.txt (0 => 201724)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+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 &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+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
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycanvasremotereadremotevideoallowedanonymoushtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-allowed-anonymous.html (0 => 201724)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,31 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;script src=&quot;../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+    &lt;script src=&quot;../../media-resources/media-file.js&quot;&gt;&lt;/script&gt;
+    &lt;script src=&quot;resources/canvas-video-crossorigin.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;pre id=&quot;console&quot;&gt;&lt;/pre&gt;
+&lt;script&gt;
+    description(&quot;Ensure that data can be retrieved from a canvas even when tainted by a remote video resource if CORS is enabled with anonymous.&quot;);
+
+    function test()
+    {
+        testDataRetrievalAllowed();
+        finishJSTest();
+    }
+
+    var video = document.createElement(&quot;video&quot;);
+    video.addEventListener(&quot;loadeddata&quot;, test);
+
+    video.crossOrigin = &quot;anonymous&quot;;
+    var mediaFile = findMediaFile(&quot;video&quot;, &quot;../../media/resources/test&quot;);
+    var type = mimeTypeForExtension(mediaFile.split('.').pop());
+    video.src = &quot;http://localhost:8080/security/resources/video-cross-origin-allow.php?name=&quot; + mediaFile + &quot;&amp;type=&quot; + type;
+
+    window.jsTestIsAsync = true;
+&lt;/script&gt;
+&lt;script src=&quot;../../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycanvasremotereadremotevideoallowedwithcredentialsexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-allowed-with-credentials-expected.txt (0 => 201724)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+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 &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+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
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycanvasremotereadremotevideoallowedwithcredentialshtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-allowed-with-credentials.html (0 => 201724)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,31 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;script src=&quot;../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+    &lt;script src=&quot;../../media-resources/media-file.js&quot;&gt;&lt;/script&gt;
+    &lt;script src=&quot;resources/canvas-video-crossorigin.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;pre id=&quot;console&quot;&gt;&lt;/pre&gt;
+&lt;script&gt;
+    description(&quot;Ensure that data can be retrieved from a canvas even when tainted by a remote video resource if CORS is enabled with use-credentials.&quot;);
+
+    function test()
+    {
+        testDataRetrievalAllowed();
+        finishJSTest();
+    }
+
+    var video = document.createElement(&quot;video&quot;);
+    video.addEventListener(&quot;loadeddata&quot;, test);
+
+    video.crossOrigin = &quot;use-credentials&quot;;
+    var mediaFile = findMediaFile(&quot;video&quot;, &quot;../../media/resources/test&quot;);
+    var type = mimeTypeForExtension(mediaFile.split('.').pop());
+    video.src = &quot;http://localhost:8080/security/resources/video-cross-origin-allow-credentials.php?name=&quot; + mediaFile + &quot;&amp;type=&quot; + type;
+    
+    window.jsTestIsAsync = true;
+&lt;/script&gt;
+&lt;script src=&quot;../../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycanvasremotereadremotevideoblockednocrossoriginexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-blocked-no-crossorigin-expected.txt (0 => 201724)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+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 &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+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
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycanvasremotereadremotevideoblockednocrossoriginhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-blocked-no-crossorigin.html (0 => 201724)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,30 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;script src=&quot;../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+    &lt;script src=&quot;../../media-resources/media-file.js&quot;&gt;&lt;/script&gt;
+    &lt;script src=&quot;resources/canvas-video-crossorigin.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;pre id=&quot;console&quot;&gt;&lt;/pre&gt;
+&lt;script&gt;
+    description(&quot;Ensure that data cannot be retrieved from a canvas tainted by a remote video resource when CORS is not enabled.&quot;);
+
+    function test()
+    {
+        testDataRetrievalForbidden(&quot;remote video&quot;);
+        finishJSTest();
+    }
+
+    var video = document.createElement(&quot;video&quot;);
+    video.addEventListener(&quot;loadeddata&quot;, test);
+
+    var mediaFile = findMediaFile(&quot;video&quot;, &quot;../../media/resources/test&quot;);
+    var type = mimeTypeForExtension(mediaFile.split('.').pop());
+    video.src = &quot;http://localhost:8080/security/resources/video-cross-origin-allow.php?name=&quot; + mediaFile + &quot;&amp;type=&quot; + type;
+    
+    window.jsTestIsAsync = true;
+&lt;/script&gt;
+&lt;script src=&quot;../../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycanvasremotereadremotevideolocalhostexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-localhost-expected.txt (0 => 201724)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+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 &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+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
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycanvasremotereadremotevideolocalhosthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-localhost.html (0 => 201724)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,27 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;script src=&quot;../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+    &lt;script src=&quot;../../media-resources/media-file.js&quot;&gt;&lt;/script&gt;
+    &lt;script src=&quot;resources/canvas-video-crossorigin.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;pre id=&quot;console&quot;&gt;&lt;/pre&gt;
+&lt;script&gt;
+    description(&quot;Ensure that data cannot be retrieved from a canvas tainted by a localhost video resource when CORS is not enabled.&quot;);
+
+    function test()
+    {
+        testDataRetrievalForbidden(&quot;localhost video resource&quot;);
+        finishJSTest();
+    }
+
+    var video = document.createElement(&quot;video&quot;);
+    video.addEventListener(&quot;loadeddata&quot;, test);
+    video.src = `http://localhost:8080/${findMediaFile(&quot;video&quot;,&quot;resources/test&quot;)}`;
+    
+    window.jsTestIsAsync = true;
+&lt;/script&gt;
+&lt;script src=&quot;../../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycanvasremotereadremotevideoredirectexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-redirect-expected.txt (0 => 201724)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,17 @@
</span><ins>+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 &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+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
+
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycanvasremotereadremotevideoredirecthtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/canvas-remote-read-remote-video-redirect.html (0 => 201724)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,27 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;html&gt;
+&lt;head&gt;
+    &lt;script src=&quot;../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+    &lt;script src=&quot;../../media-resources/media-file.js&quot;&gt;&lt;/script&gt;
+    &lt;script src=&quot;resources/canvas-video-crossorigin.js&quot;&gt;&lt;/script&gt;
+&lt;/head&gt;
+&lt;body&gt;
+&lt;pre id=&quot;console&quot;&gt;&lt;/pre&gt;
+&lt;script&gt;
+    description(&quot;Ensure that data cannot be retrieved from a canvas tainted by a video resource obtained via redirection when CORS is not enabled.&quot;);
+
+    function test()
+    {
+        testDataRetrievalForbidden(&quot;redirected video resource&quot;);
+        finishJSTest();
+    }
+
+    var video = document.createElement(&quot;video&quot;);
+    video.addEventListener(&quot;loadeddata&quot;, test);
+    video.src = `/resources/redirect.php?url=http://localhost:8000/${findMediaFile(&quot;video&quot;, &quot;resources/test&quot;)}`;
+    
+    window.jsTestIsAsync = true;
+&lt;/script&gt;
+&lt;script src=&quot;../../../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecurityresourcescanvasvideocrossoriginjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/resources/canvas-video-crossorigin.js (0 => 201724)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,48 @@
</span><ins>+// The following functions depend on functions in js-test-pre.js.
+var canvas, context;
+
+function testDataRetrievalAllowed() {
+    // Control tests.
+    debug(&quot;Testing data retrieval on an untainted canvas:&quot;);
+    canvas = document.createElement(&quot;canvas&quot;);
+    canvas.width = 100;
+    canvas.height = 100;
+    
+    shouldNotThrow(&quot;canvas.getContext('2d').getImageData(0, 0, 100, 100)&quot;);
+    shouldNotThrow(&quot;canvas.toDataURL()&quot;);
+
+    // CORS tests.
+    debug(&quot;&lt;br /&gt;Testing data retrieval on a canvas tainted by a remote video pattern:&quot;);
+    canvas = document.createElement(&quot;canvas&quot;);
+    canvas.width = 100;
+    canvas.height = 100;
+    context = canvas.getContext(&quot;2d&quot;);
+    context.fillStyle = context.createPattern(video, &quot;repeat&quot;);
+    context.fillRect(0, 0, 100, 100);
+
+    shouldThrow(&quot;context.getImageData(0, 0, 100, 100)&quot;, &quot;'Error: SecurityError: DOM Exception 18'&quot;);
+    shouldThrow(&quot;canvas.toDataURL()&quot;, &quot;'Error: SecurityError: DOM Exception 18'&quot;);
+}
+
+function testDataRetrievalForbidden(description) {
+    // Control tests.
+    debug(&quot;Testing data retrieval on an untainted canvas:&quot;);
+    canvas = document.createElement(&quot;canvas&quot;);
+    canvas.width = 100;
+    canvas.height = 100;
+    
+    shouldNotThrow(&quot;canvas.getContext('2d').getImageData(0, 0, 100, 100)&quot;);
+    shouldNotThrow(&quot;canvas.toDataURL()&quot;);
+
+    // CORS tests.
+    debug(&quot;&lt;br /&gt;Testing data retrieval on a canvas tainted by a pattern generated by a &quot; + description + &quot;:&quot;);
+    canvas = document.createElement(&quot;canvas&quot;);
+    canvas.width = 100;
+    canvas.height = 100;
+    context = canvas.getContext(&quot;2d&quot;);
+    context.fillStyle = context.createPattern(video, &quot;repeat&quot;);
+    context.fillRect(0, 0, 100, 100);
+
+    shouldThrow(&quot;context.getImageData(0, 0, 100, 100)&quot;, &quot;'Error: SecurityError: DOM Exception 18'&quot;);
+    shouldThrow(&quot;canvas.toDataURL()&quot;, &quot;'Error: SecurityError: DOM Exception 18'&quot;);
+}
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestshttptestssecurityresourcesvideocrossoriginallowcredentialsphp"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/security/resources/video-cross-origin-allow-credentials.php (0 => 201724)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,14 @@
</span><ins>+&lt;?php
+
+header(&quot;Access-Control-Allow-Origin: http://127.0.0.1:8000&quot;);
+header(&quot;Access-Control-Allow-Credentials: true&quot;);
+
+if ($_SERVER['REQUEST_METHOD'] == &quot;OPTIONS&quot;) {
+    header(&quot;Access-Control-Allow-Methods: GET&quot;);
+    header(&quot;Access-Control-Allow-Headers: origin, accept-encoding, referer, range&quot;);
+    exit;
+}
+
+@include(&quot;../../media/resources/serve-video.php&quot;);
+
+?&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsmediavideocanvascreatePatternexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/media/video-canvas-createPattern-expected.txt (0 => 201724)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,56 @@
</span><ins>+
+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
+
</ins></span></pre></div>
<a id="trunkLayoutTestsmediavideocanvascreatePatternhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/media/video-canvas-createPattern.html (0 => 201724)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,86 @@
</span><ins>+&lt;html&gt;
+    &lt;head&gt;
+        &lt;title&gt;Create patterns on canvas using video&lt;/title&gt;
+        &lt;script src=&quot;media-file.js&quot;&gt;&lt;/script&gt;
+        &lt;script src=&quot;video-test.js&quot;&gt;&lt;/script&gt;
+        &lt;script&gt;
+            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) &lt; tolerance
+                    &amp;&amp; Math.abs(buffer[1] - g) &lt; tolerance
+                    &amp;&amp; Math.abs(buffer[2] - b) &lt; 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 = findMediaFile('video', 'content/test');
+            }
+        &lt;/script&gt;
+    &lt;/head&gt;
+
+    &lt;body onload=&quot;start()&quot;&gt;
+        &lt;video id=&quot;video&quot;&gt;&lt;/video&gt;
+        &lt;div id=&quot;canvases&quot;&gt;&lt;/div&gt;
+    &lt;/body&gt;
+&lt;/html&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestsplatformiossimulatorwk1TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations (201723 => 201724)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1097,6 +1097,8 @@
</span><span class="cx"> http/tests/security/aboutBlank/xss-DENIED-navigate-opener-document-write.html [ Failure ]
</span><span class="cx"> http/tests/security/aboutBlank/xss-DENIED-navigate-opener-javascript-url.html [ Failure ]
</span><span class="cx"> http/tests/security/aboutBlank/xss-DENIED-set-opener.html [ Failure ]
</span><ins>+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 ]
</ins><span class="cx"> http/tests/security/contentSecurityPolicy/object-src-url-allowed.html [ Failure ]
</span><span class="cx"> http/tests/security/contentSecurityPolicy/object-src-url-blocked.html [ Failure ]
</span><span class="cx"> http/tests/security/cross-origin-indexeddb-allowed.html [ Failure ]
</span></span></pre></div>
<a id="trunkLayoutTestsplatformiossimulatorwk2TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations (201723 => 201724)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -500,6 +500,8 @@
</span><span class="cx"> http/tests/security/aboutBlank/xss-DENIED-navigate-opener-document-write.html
</span><span class="cx"> http/tests/security/aboutBlank/xss-DENIED-navigate-opener-javascript-url.html
</span><span class="cx"> http/tests/security/aboutBlank/xss-DENIED-set-opener.html
</span><ins>+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 ]
</ins><span class="cx"> http/tests/security/cookies/third-party-cookie-blocking-user-action.html
</span><span class="cx"> http/tests/security/isolatedWorld/cross-origin-xhr.html
</span><span class="cx"> http/tests/security/isolatedWorld/userGestureEvents.html
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac/TestExpectations (201723 => 201724)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -353,6 +353,8 @@
</span><span class="cx"> webkit.org/b/82979 canvas/philip/tests/2d.text.draw.align.center.html [ Pass Failure ]
</span><span class="cx"> 
</span><span class="cx"> # No CORS support for media elements is implemented yet.
</span><ins>+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 ]
</ins><span class="cx"> http/tests/security/video-cross-origin-readback.html
</span><span class="cx"> http/tests/security/video-cross-origin-accessfailure.html
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacmediavideocanvascreatePatternexpectedpng"></a>
<div class="binary"><h4>Added: trunk/LayoutTests/platform/mac/media/video-canvas-createPattern-expected.png</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<span class="cx">Property changes on: trunk/LayoutTests/platform/mac/media/video-canvas-createPattern-expected.png
</span><span class="cx">___________________________________________________________________
</span><a id="svnmimetype"></a>
<div class="addfile"><h4>Added: svn:mime-type</h4></div>
<a id="trunkLayoutTestsplatformwinTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/win/TestExpectations (201723 => 201724)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -898,6 +898,8 @@
</span><span class="cx"> webkit.org/b/103442 media/W3C/video/networkState/networkState_during_progress.html [ Skip ]
</span><span class="cx"> 
</span><span class="cx"> # No CORS support for media elements is implemented yet.
</span><ins>+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 ]
</ins><span class="cx"> http/tests/security/video-cross-origin-readback.html [ Skip ]
</span><span class="cx"> 
</span><span class="cx"> # Requires ENABLE(MEDIA_CAPTURE)
</span></span></pre></div>
<a id="trunkLayoutTestsplatformwk2TestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/wk2/TestExpectations (201723 => 201724)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -382,6 +382,8 @@
</span><span class="cx"> editing/pasteboard/emacs-cntl-y-001.html
</span><span class="cx"> 
</span><span class="cx"> # No CORS support for media elements is implemented yet.
</span><ins>+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 ]
</ins><span class="cx"> http/tests/security/video-cross-origin-readback.html
</span><span class="cx"> 
</span><span class="cx"> # X-Content-Type-Options (ENABLE_NOSNIFF) is not enabled.
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (201723 => 201724)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,30 @@
</span><ins>+2016-06-06  George Ruan  &lt;gruan@apple.com&gt;
+
+        Support createPattern(HTMLVideoElement, const String&amp; repetitionType)
+        https://bugs.webkit.org/show_bug.cgi?id=149984
+        &lt;rdar://problem/23058823&gt;
+
+        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:
+
</ins><span class="cx"> 2016-06-06  Csaba Osztrogonác  &lt;ossy@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix the !ENABLE(SHADOW_DOM) &amp;&amp; !ENABLE(DETAILS_ELEMENT) build
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasCanvasRenderingContext2Dcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (201723 => 201724)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #include &quot;CanvasRenderingContext2D.h&quot;
</span><span class="cx"> 
</span><ins>+#include &quot;BitmapImage.h&quot;
</ins><span class="cx"> #include &quot;CSSFontSelector.h&quot;
</span><span class="cx"> #include &quot;CSSParser.h&quot;
</span><span class="cx"> #include &quot;CSSPropertyNames.h&quot;
</span><span class="lines">@@ -46,6 +47,7 @@
</span><span class="cx"> #include &quot;FloatQuad.h&quot;
</span><span class="cx"> #include &quot;HTMLImageElement.h&quot;
</span><span class="cx"> #include &quot;HTMLVideoElement.h&quot;
</span><ins>+#include &quot;ImageBuffer.h&quot;
</ins><span class="cx"> #include &quot;ImageData.h&quot;
</span><span class="cx"> #include &quot;RenderElement.h&quot;
</span><span class="cx"> #include &quot;RenderImage.h&quot;
</span><span class="lines">@@ -1795,7 +1797,34 @@
</span><span class="cx">         return nullptr;
</span><span class="cx">     return CanvasPattern::create(canvas.copiedImage(), repeatX, repeatY, canvas.originClean());
</span><span class="cx"> }
</span><ins>+    
+#if ENABLE(VIDEO)
+RefPtr&lt;CanvasPattern&gt; CanvasRenderingContext2D::createPattern(HTMLVideoElement&amp; videoElement, const String&amp; repetitionType, ExceptionCode&amp; ec)
+{
+    if (videoElement.readyState() &lt; HTMLMediaElement::HAVE_CURRENT_DATA)
+        return nullptr;
+    
+    bool repeatX, repeatY;
+    ec = 0;
+    CanvasPattern::parseRepetitionType(repetitionType, repeatX, repeatY, ec);
+    if (ec)
+        return nullptr;
+    
+    checkOrigin(&amp;videoElement);
+    bool originClean = canvas()-&gt;originClean();
</ins><span class="cx"> 
</span><ins>+#if USE(CG) || (ENABLE(ACCELERATED_2D_CANVAS) &amp;&amp; USE(GSTREAMER_GL) &amp;&amp; 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()-&gt;renderingMode() : Accelerated);
+    videoElement.paintCurrentFrameInContext(imageBuffer-&gt;context(), FloatRect(FloatPoint(), size(videoElement)));
+    
+    return CanvasPattern::create(ImageBuffer::sinkIntoImage(WTFMove(imageBuffer), Unscaled), repeatX, repeatY, originClean);
+}
+#endif
+
</ins><span class="cx"> void CanvasRenderingContext2D::didDrawEntireCanvas()
</span><span class="cx"> {
</span><span class="cx">     didDraw(FloatRect(FloatPoint::zero(), canvas()-&gt;size()), CanvasDidDrawApplyClip);
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasCanvasRenderingContext2Dh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h (201723 => 201724)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -182,6 +182,9 @@
</span><span class="cx">     RefPtr&lt;CanvasGradient&gt; createRadialGradient(float x0, float y0, float r0, float x1, float y1, float r1, ExceptionCode&amp;);
</span><span class="cx">     RefPtr&lt;CanvasPattern&gt; createPattern(HTMLImageElement&amp;, const String&amp; repetitionType, ExceptionCode&amp;);
</span><span class="cx">     RefPtr&lt;CanvasPattern&gt; createPattern(HTMLCanvasElement&amp;, const String&amp; repetitionType, ExceptionCode&amp;);
</span><ins>+#if ENABLE(VIDEO)
+    RefPtr&lt;CanvasPattern&gt; createPattern(HTMLVideoElement&amp;, const String&amp; repetitionType, ExceptionCode&amp;);
+#endif
</ins><span class="cx"> 
</span><span class="cx">     RefPtr&lt;ImageData&gt; createImageData(RefPtr&lt;ImageData&gt;&amp;&amp;, ExceptionCode&amp;) const;
</span><span class="cx">     RefPtr&lt;ImageData&gt; createImageData(float width, float height, ExceptionCode&amp;) const;
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlcanvasCanvasRenderingContext2Didl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.idl (201723 => 201724)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -177,6 +177,7 @@
</span><span class="cx"> 
</span><span class="cx">     [RaisesException] CanvasPattern createPattern(HTMLCanvasElement canvas, [TreatNullAs=EmptyString] DOMString repetitionType);
</span><span class="cx">     [RaisesException] CanvasPattern createPattern(HTMLImageElement image, [TreatNullAs=EmptyString] DOMString repetitionType);
</span><ins>+    [Conditional=VIDEO, RaisesException] CanvasPattern? createPattern(HTMLVideoElement video, [TreatNullAs=EmptyString] DOMString repetitionType);
</ins><span class="cx">     [RaisesException] ImageData createImageData(ImageData? imagedata);
</span><span class="cx">     [RaisesException] ImageData createImageData(float sw, float sh);
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>