summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webcodecs/videoFrame-construction.crossOriginSource.sub.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/webcodecs/videoFrame-construction.crossOriginSource.sub.html
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/webcodecs/videoFrame-construction.crossOriginSource.sub.html')
-rw-r--r--testing/web-platform/tests/webcodecs/videoFrame-construction.crossOriginSource.sub.html187
1 files changed, 187 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webcodecs/videoFrame-construction.crossOriginSource.sub.html b/testing/web-platform/tests/webcodecs/videoFrame-construction.crossOriginSource.sub.html
new file mode 100644
index 0000000000..21860b2e31
--- /dev/null
+++ b/testing/web-platform/tests/webcodecs/videoFrame-construction.crossOriginSource.sub.html
@@ -0,0 +1,187 @@
+
+<!DOCTYPE html>
+<html>
+<head>
+ <script src='/resources/testharness.js'></script>
+ <script src='/resources/testharnessreport.js'></script>
+ <script src="/common/get-host-info.sub.js"></script>
+</head>
+<body>
+<script>
+const SAMEORIGIN_BASE = get_host_info().HTTP_ORIGIN;
+const CROSSORIGIN_BASE = get_host_info().HTTP_NOTSAMESITE_ORIGIN;
+
+const TESTS = [
+ // HTMLImageElement
+ {
+ title: 'Test creating a VideoFrame with a same-origin HTMLImageElement',
+ factory: () => {
+ return new Promise((resolve, reject) => {
+ const image = new Image();
+ image.onload = () => resolve(image);
+ image.onerror = reject;
+ image.src = SAMEORIGIN_BASE + '/webcodecs/four-colors.jpg';
+ });
+ },
+ should_throw: false,
+ },
+ {
+ title: 'Test creating a VideoFrame with a cross-origin HTMLImageElement',
+ factory: () => {
+ return new Promise((resolve, reject) => {
+ const image = new Image();
+ image.onload = () => resolve(image);
+ image.onerror = reject;
+ image.src = CROSSORIGIN_BASE + '/webcodecs/four-colors.jpg';
+ });
+ },
+ should_throw: true,
+ },
+ {
+ title: 'Test creating a VideoFrame with a CORS enabled cross-origin HTMLImageElement without setting crossorigin',
+ factory: () => {
+ return new Promise((resolve, reject) => {
+ const image = new Image();
+ image.onload = () => resolve(image);
+ image.onerror = reject;
+ image.src = CROSSORIGIN_BASE + '/webcodecs/four-colors.jpg?pipe=header(Access-Control-Allow-Origin,*)';
+ });
+ },
+ should_throw: true,
+ },
+ {
+ title: 'Test creating a VideoFrame with a CORS enabled cross-origin HTMLImageElement with crossorigin="anonymous"',
+ factory: () => {
+ return new Promise((resolve, reject) => {
+ const image = new Image();
+ image.onload = () => resolve(image);
+ image.onerror = reject;
+ image.crossOrigin = 'anonymous';
+ image.src = CROSSORIGIN_BASE + '/webcodecs/four-colors.jpg?pipe=header(Access-Control-Allow-Origin,*)';
+ });
+ },
+ should_throw: false,
+ },
+ // SVGImageElement
+ {
+ title: 'Test creating a VideoFrame with a same-origin SVGImageElement',
+ factory: () => {
+ return new Promise((resolve, reject) => {
+ const image = document.createElementNS('http://www.w3.org/2000/svg','image');
+ image.onload = () => resolve(image);
+ image.onerror = reject;
+ image.setAttribute('href', SAMEORIGIN_BASE + '/webcodecs/four-colors.jpg');
+ });
+ },
+ should_throw: false,
+ },
+ {
+ title: 'Test creating a VideoFrame with a cross-origin SVGImageElement',
+ factory: () => {
+ return new Promise((resolve, reject) => {
+ const image = document.createElementNS('http://www.w3.org/2000/svg','image');
+ image.onload = () => resolve(image);
+ image.onerror = reject;
+ image.setAttribute('href', CROSSORIGIN_BASE + '/webcodecs/four-colors.jpg');
+ });
+ },
+ should_throw: true,
+ },
+ {
+ title: 'Test creating a VideoFrame with a CORS enabled cross-origin SVGImageElement without setting crossorigin',
+ factory: () => {
+ return new Promise((resolve, reject) => {
+ const image = document.createElementNS('http://www.w3.org/2000/svg','image');
+ image.onload = () => resolve(image);
+ image.onerror = reject;
+ image.setAttribute('href', CROSSORIGIN_BASE + '/webcodecs/four-colors.jpg?pipe=header(Access-Control-Allow-Origin,*)');
+ });
+ },
+ should_throw: true,
+ },
+ {
+ title: 'Test creating a VideoFrame with a CORS enabled cross-origin SVGImageElement with crossorigin="anonymous"',
+ factory: () => {
+ return new Promise((resolve, reject) => {
+ const image = document.createElementNS('http://www.w3.org/2000/svg','image');
+ image.onload = () => resolve(image);
+ image.onerror = reject;
+ image.crossOrigin = 'anonymous';
+ image.setAttribute('href', CROSSORIGIN_BASE + '/webcodecs/four-colors.jpg?pipe=header(Access-Control-Allow-Origin,*)');
+ });
+ },
+ should_throw: false,
+ },
+ // HTMLVideoElement
+ {
+ title: 'Test creating a VideoFrame with a same-origin HTMLVideoElement',
+ factory: () => {
+ return new Promise((resolve, reject) => {
+ const video = document.createElement('video');
+ video.onloadeddata = () => resolve(video);
+ video.onerror = reject;
+ video.src = SAMEORIGIN_BASE + '/webcodecs/av1.mp4';
+ });
+ },
+ should_throw: false,
+ },
+ {
+ title: 'Test creating a VideoFrame with a cross-origin HTMLVideoElement',
+ factory: () => {
+ return new Promise((resolve, reject) => {
+ const video = document.createElement('video');
+ video.onloadeddata = () => resolve(video);
+ video.onerror = reject;
+ video.src = CROSSORIGIN_BASE + '/webcodecs/av1.mp4';
+ });
+ },
+ should_throw: true,
+ },
+ {
+ title: 'Test creating a VideoFrame with a CORS enabled cross-origin HTMLVideoElement without setting crossorigin',
+ factory: () => {
+ return new Promise((resolve, reject) => {
+ const video = document.createElement('video');
+ video.onloadeddata = () => resolve(video);
+ video.onerror = reject;
+ video.src = CROSSORIGIN_BASE + '/webcodecs/av1.mp4?pipe=header(Access-Control-Allow-Origin,*)';
+ });
+ },
+ should_throw: true,
+ },
+ {
+ title: 'Test creating a VideoFrame with a CORS enabled cross-origin HTMLVideoElement with crossorigin="anonymous"',
+ factory: () => {
+ return new Promise((resolve, reject) => {
+ const video = document.createElement('video');
+ video.onloadeddata = () => resolve(video);
+ video.onerror = reject;
+ video.crossOrigin = 'anonymous';
+ video.src = CROSSORIGIN_BASE + '/webcodecs/av1.mp4?pipe=header(Access-Control-Allow-Origin,*)';
+ });
+ },
+ should_throw: false,
+ },
+];
+
+TESTS.forEach(test => run_test(test));
+
+function run_test(test) {
+ promise_test(async t => {
+ const source = await test.factory();
+ if (test.should_throw) {
+ assert_throws_dom('SecurityError', () => { create_frame(source); });
+ } else {
+ create_frame(source);
+ }
+ }, test.title);
+}
+
+function create_frame(img) {
+ let frame = new VideoFrame(img, {timestamp: 0});
+ frame.close();
+}
+
+</script>
+</body>
+</html>