summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/mediacapture-fromelement/cross-origin.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
commit0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch)
treea31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /testing/web-platform/tests/mediacapture-fromelement/cross-origin.html
parentInitial commit. (diff)
downloadfirefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz
firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/mediacapture-fromelement/cross-origin.html')
-rw-r--r--testing/web-platform/tests/mediacapture-fromelement/cross-origin.html41
1 files changed, 41 insertions, 0 deletions
diff --git a/testing/web-platform/tests/mediacapture-fromelement/cross-origin.html b/testing/web-platform/tests/mediacapture-fromelement/cross-origin.html
new file mode 100644
index 0000000000..14d92c8fc8
--- /dev/null
+++ b/testing/web-platform/tests/mediacapture-fromelement/cross-origin.html
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+</head>
+<body>
+<video autoplay controls id="output"></video>
+<script>
+
+// Run captureStream() on cross-origin <video> content
+ async_test(function() {
+ const video = document.createElement('video');
+ video.src = location.origin.replace("//", "//www1.") + "/media/white.webm";
+ video.onerror = this.unreached_func("<video> error");
+ video.loop = true;
+ video.play();
+
+ const stream = video.captureStream();
+ assert_not_equals(stream, null, "error generating stream");
+ const output = document.getElementById("output");
+ const canvas = document.createElement("canvas");
+ const ctx = canvas.getContext('2d');
+
+ stream.onaddtrack = this.step_func_done(function() {
+ canvas.width = output.videoWidth || 320;
+ canvas.height = output.videoHeight || 240;
+ // The stream got a (number of) MediaStreamTracks added.
+ assert_equals(stream.getVideoTracks().length, 1, 'video tracks');
+ assert_equals(stream.getAudioTracks().length, 0, 'audio');
+ assert_true(stream.getVideoTracks()[0].muted, 'cross-origin video is muted');
+ ctx.drawImage(output, 0, 0, canvas.width, canvas.height);
+
+ const pixels = ctx.getImageData(0,0,canvas.width, canvas.height);
+ assert_equals(pixels.data[canvas.width*canvas.height*4 - 4], 0, "cross-origin content appears black");
+ }, "<video>.captureStream() returns muted/black stream");
+ }, "Capturing stream from cross-origin video");
+
+</script>
+</body>
+</html>