diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/mediacapture-streams/MediaStreamTrack-transfer.https.html | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.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/mediacapture-streams/MediaStreamTrack-transfer.https.html')
-rw-r--r-- | testing/web-platform/tests/mediacapture-streams/MediaStreamTrack-transfer.https.html | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/testing/web-platform/tests/mediacapture-streams/MediaStreamTrack-transfer.https.html b/testing/web-platform/tests/mediacapture-streams/MediaStreamTrack-transfer.https.html new file mode 100644 index 0000000000..e110b4b372 --- /dev/null +++ b/testing/web-platform/tests/mediacapture-streams/MediaStreamTrack-transfer.https.html @@ -0,0 +1,50 @@ +<!doctype html> +<title>MediaStreamTrack transfer to Worker</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script src=/resources/testdriver.js></script> +<script src=/resources/testdriver-vendor.js></script> +<script src=permission-helper.js></script> +<script id="workerCode" type="javascript/worker"> +self.onmessage = (e) => { + try { + if(e.data instanceof MediaStreamTrack) { + self.postMessage({result: 'Success'}); + return; + } else { + self.postMessage({ + result: 'Failure', + error: `${e.data} is not a MediaStreamTrack` + }); + } + } catch (error) { + self.postMessage({ + result: 'Failure', + error + }); + } +} +</script> +<script> +promise_test(async () => { + const workerBlob = new Blob([document.querySelector('#workerCode').textContent], + {type: "text/javascript"}); + const workerUrl = window.URL.createObjectURL(workerBlob); + const worker = new Worker(workerUrl); + window.URL.revokeObjectURL(workerUrl); + await setMediaPermission("granted", ["camera"]); + const stream = await navigator.mediaDevices.getDisplayMedia({video: true}); + const track = stream.getVideoTracks()[0]; + const result = new Promise((resolve, reject) => { + worker.onmessage = (e) => { + if (e.data.result === 'Failure') { + reject('Failed: ' + e.data.error); + } else { + resolve(); + } + }; + }); + worker.postMessage(track, [track]); + return result; +}); +</script> |