Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /html/canvas/element/manual/draw-element-image/privacy/svg-use-ignored-tentative.https.sub.html - WPT Dashboard Interop Dashboard
<!DOCTYPE HTML>
<html>
<head>
<title>drawElementImage does not use cross-origin SVG use content</title>
<link rel="author" href="mailto:schenney@chromium.org">
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
<script src='/html/canvas/resources/canvas-tests.js'></script>
<script src="/html/canvas/resources/wait-for-canvas-paint.js"></script>
</head>
<body>
<canvas id=canvas width="100" height="200" layoutsubtree>
<svg id="child-same" x=0 y=0 width=100 height=100>
</svg>
<svg id="child-cross" x=0 y=0 width=100 height=100>
</svg>
</canvas>
<script>
window.onload = () => {
promise_test(async function(t) {
await waitForCanvasPaint(canvas);
const context = canvas.getContext("2d");
context.drawElementImage(document.getElementById("child-same"), 0, 0);
context.drawElementImage(document.getElementById("child-cross"), 0, 100);
// Fetch all pixel data once to avoid multiple slow readbacks.
const imgData = context.getImageData(0, 0, canvas.width, canvas.height);
let pixel = _getPixelFromImageData(imgData, 50, 50);
assert_array_equals(pixel, [0, 255, 0, 255], "Same origin should draw");
// Cross-origin <use> is not rendered at all.
pixel = _getPixelFromImageData(imgData, 50, 150);
assert_array_equals(pixel, [0, 0, 0, 0], "Cross origin should not draw");
});
}
</script>
</body>
</html>