summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/2dcontext/imagebitmap/createImageBitmap-origin.sub.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/2dcontext/imagebitmap/createImageBitmap-origin.sub.html')
-rw-r--r--testing/web-platform/tests/2dcontext/imagebitmap/createImageBitmap-origin.sub.html81
1 files changed, 5 insertions, 76 deletions
diff --git a/testing/web-platform/tests/2dcontext/imagebitmap/createImageBitmap-origin.sub.html b/testing/web-platform/tests/2dcontext/imagebitmap/createImageBitmap-origin.sub.html
index 7f5588e..d5bbb28 100644
--- a/testing/web-platform/tests/2dcontext/imagebitmap/createImageBitmap-origin.sub.html
+++ b/testing/web-platform/tests/2dcontext/imagebitmap/createImageBitmap-origin.sub.html
@@ -5,9 +5,9 @@
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
<script src="/common/namespaces.js"></script>
+<script src="/common/canvas-tests.js"></script>
<div id=log></div>
<script>
-const crossOriginImageUrl = "http://{{domains[www1]}}:{{ports[http][0]}}/images/red.png";
function assert_origin_unclean(bitmap) {
const context = document.createElement("canvas").getContext("2d");
@@ -17,82 +17,11 @@ function assert_origin_unclean(bitmap) {
});
}
-function makeImage() {
- return new Promise((resolve, reject) => {
- const image = new Image();
- image.onload = () => resolve(image);
- image.onerror = reject;
- image.src = crossOriginImageUrl;
- });
-}
-
-const arguments = [
- {
- name: "cross-origin HTMLImageElement",
- factory: makeImage,
- },
-
- {
- name: "cross-origin SVGImageElement",
- factory: () => {
- return new Promise((resolve, reject) => {
- const image = document.createElementNS(NAMESPACES.svg, "image");
- image.onload = () => resolve(image);
- image.onerror = reject;
- image.setAttribute("externalResourcesRequired", "true");
- image.setAttributeNS(NAMESPACES.xlink, 'xlink:href', crossOriginImageUrl);
- document.body.appendChild(image);
- });
- },
- },
-
- {
- name: "cross-origin HTMLVideoElement",
- factory: () => {
- return new Promise((resolve, reject) => {
- const video = document.createElement("video");
- video.oncanplaythrough = () => resolve(video);
- video.onerror = reject;
- video.src = getVideoURI("http://{{domains[www1]}}:{{ports[http][0]}}/media/movie_300");
- });
- },
- },
-
- {
- name: "redirected to cross-origin HTMLVideoElement",
- factory: () => {
- return new Promise((resolve, reject) => {
- const video = document.createElement("video");
- video.oncanplaythrough = () => resolve(video);
- video.onerror = reject;
- video.src = "/common/redirect.py?location=" + getVideoURI("http://{{domains[www1]}}:{{ports[http][0]}}/media/movie_300");
- });
- },
- },
-
- {
- name: "unclean HTMLCanvasElement",
- factory: () => {
- return makeImage().then(image => {
- const canvas = document.createElement("canvas");
- const context = canvas.getContext("2d");
- context.drawImage(image, 0, 0);
- return canvas;
- });
- },
- },
-
- {
- name: "unclean ImageBitmap",
- factory: () => {
- return makeImage().then(createImageBitmap);
- },
- },
-];
-
-for (let { name, factory } of arguments) {
+forEachCanvasSource("http://{{domains[www1]}}:{{ports[http][0]}}",
+ "http://{{domains[]}}:{{ports[http][0]}}",
+ (name, factory) => {
promise_test(function() {
return factory().then(createImageBitmap).then(assert_origin_unclean);
}, name);
-}
+});
</script>