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/MediaStream-MediaElement-preload-none.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/MediaStream-MediaElement-preload-none.https.html')
-rw-r--r-- | testing/web-platform/tests/mediacapture-streams/MediaStream-MediaElement-preload-none.https.html | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/testing/web-platform/tests/mediacapture-streams/MediaStream-MediaElement-preload-none.https.html b/testing/web-platform/tests/mediacapture-streams/MediaStream-MediaElement-preload-none.https.html new file mode 100644 index 0000000000..52a13af272 --- /dev/null +++ b/testing/web-platform/tests/mediacapture-streams/MediaStream-MediaElement-preload-none.https.html @@ -0,0 +1,84 @@ +<!DOCTYPE html> +<html> + <head> + <title>Test that the HTMLMediaElement preload 'none' attribute value is ignored for MediaStream used as srcObject and MediaStream object URLs used as src.</title> + <link rel="author" title="Matthew Wolenetz" href="mailto:wolenetz@chromium.org"/> + <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> + </head> + <body> + <p class="instructions">When prompted, accept to share your audio and video streams.</p> + <p class="instructions">This test checks that the HTMLMediaElement preload 'none' attribute value is ignored for MediaStream used as srcObject and MediaStream object URLs used as src.</p> + <div id=log></div> + + <audio preload="none"></audio> + <video preload="none"></video> + + <script> + async function testPreloadNone(mediaElement, stream) + { + let rejectSuspendedPromise, rejectErrorPromise, resolveDataLoadedPromise; + const suspended = new Promise((r, rej) => { + rejectSuspendedPromise = rej; + }); + const errored = new Promise((r, rej) => { + rejectErrorPromise = rej; + }); + const loaded = new Promise(resolve => { + resolveDataLoadedPromise = resolve; + }); + + // The optional deferred load steps (for preload none) for MediaStream resources should be skipped. + mediaElement.addEventListener("suspend", () => { + rejectSuspendedPromise("'suspend' should not be fired.") + }); + mediaElement.addEventListener("error", () => { + rejectErrorPromise("'error' should not be fired, code=" + mediaElement.error.code); + }); + + mediaElement.addEventListener("loadeddata", () => { + assert_equals(mediaElement.networkState, mediaElement.NETWORK_LOADING); + resolveDataLoadedPromise(); + }); + + mediaElement.srcObject = stream; + assert_equals(mediaElement.networkState, mediaElement.NETWORK_NO_SOURCE); // Resource selection is active. + try { + await Promise.race([suspended, errored, loaded]); + } catch (msg) { + assert_unreached(msg); + } +2 } + + promise_test(async () => + { + const aud = document.querySelector("audio"); + // camera is needed for the next test, asking for both at once + await setMediaPermission(); + let stream; + try { + stream = await navigator.mediaDevices.getUserMedia({audio:true}); + } catch (e) { + assert_unreached("getUserMedia error callback was invoked."); + } + await testPreloadNone(aud, stream); + }, "Test that preload 'none' is ignored for MediaStream object URL used as srcObject for audio"); + + promise_test(async () => + { + const vid = document.querySelector("video"); + let stream; + try { + stream = await navigator.mediaDevices.getUserMedia({video:true}); + } catch (e) { + assert_unreached("getUserMedia error callback was invoked.") + } + await testPreloadNone(vid, stream); + + }, "Test that preload 'none' is ignored for MediaStream used as srcObject for video"); + </script> + </body> +</html> |