Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /html/canvas/element/manual/fill-and-stroke-styles/pattern-from-video-cross-origin-taint.https.sub.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title>A pattern using cross-origin video should taint the canvas.</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<video id=video_source src="https://{{hosts[alt][www]}}:{{ports[https][0]}}/media/2x2-green.webm"></video>
<canvas id=canvas width=100 height=100></canvas>
<script>
promise_test(async function() {
await new Promise((resolve) => {
video_source.oncanplay = resolve;
if (video_source.readyState >= 3) resolve();
});
const context = canvas.getContext("2d");
const pattern = context.createPattern(video_source, "repeat");
context.fillStyle = pattern;
context.fillRect(0, 0, 100, 100);
// The canvas should be tainted, so the following should throw.
assert_throws_dom("SecurityError",
function () { canvas.toDataURL() },
'canvas.toDataURL should throw SecurityError for a pattern using cross origin content.'
);
}, "Tainting check for cross origin video in canvas pattern");
</script>