Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 13 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /html/canvas/element/manual/imagebitmap/createImageBitmap-origin.sub.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset=utf-8>
<title>createImageBitmap: origin-clean flag</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="/common/media.js"></script>
<script src="/html/canvas/resources/canvas-tests.js"></script>
<div id=log></div>
<script>
function assert_origin_unclean_getImageData(bitmap) {
const context = document.createElement("canvas").getContext("2d");
context.drawImage(bitmap, 0, 0);
assert_throws_dom("SecurityError", () => {
context.getImageData(0, 0, 1, 1);
});
}
function assert_origin_unclean_drawImage(bitmap) {
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
ctx.drawImage(bitmap, 0, 0);
assert_throws_dom('SecurityError', () => canvas.toDataURL());
}
function assert_origin_unclean_transferFromImageBitmap(bitmap) {
var canvas = document.createElement('canvas');
var ctx = canvas.getContext('bitmaprenderer');
ctx.transferFromImageBitmap(bitmap);
assert_throws_dom('SecurityError', () => canvas.toDataURL());
}
forEachCanvasSource(get_host_info().HTTP_REMOTE_ORIGIN,
get_host_info().HTTP_ORIGIN,
(name, factory) => {
promise_test(function() {
return factory().then(createImageBitmap).then(assert_origin_unclean_getImageData);
}, `${name}: origin unclear getImageData`);
promise_test(function() {
return factory().then(createImageBitmap).then(assert_origin_unclean_drawImage);
}, `${name}: origin unclear 2dContext.drawImage`);
promise_test(function() {
return factory().then(createImageBitmap).then(assert_origin_unclean_transferFromImageBitmap);
}, `${name}: origin unclear bitmaprenderer.transferFromImageBitmap`);
});
</script>