diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/mediasession/positionstate.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/mediasession/positionstate.html')
-rw-r--r-- | testing/web-platform/tests/mediasession/positionstate.html | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/testing/web-platform/tests/mediasession/positionstate.html b/testing/web-platform/tests/mediasession/positionstate.html new file mode 100644 index 0000000000..9141091a90 --- /dev/null +++ b/testing/web-platform/tests/mediasession/positionstate.html @@ -0,0 +1,106 @@ +<!DOCTYPE html> +<title>MediaSession.setPositionState</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<script> +test(() => { + window.navigator.mediaSession.setPositionState(null); +}, 'Test setPositionState with a null value'); + +test(() => { + window.navigator.mediaSession.setPositionState({ + duration: 60.9, + position: 10.1, + playbackRate: 1.5 + }); +}, 'Test setPositionState with a valid value for forward playback'); + +test(() => { + window.navigator.mediaSession.setPositionState({ + duration: 60.9, + playbackRate: 1.0 + }); +}, 'Test setPositionState with optional position'); + +test(() => { + window.navigator.mediaSession.setPositionState({ + duration: 60.9, + position: 10.1 + }); +}, 'Test setPositionState with optional playback rate'); + +test(() => { + window.navigator.mediaSession.setPositionState({ + duration: 60.9 + }); +}, 'Test setPositionState with only duration'); + +test(() => { + window.navigator.mediaSession.setPositionState({ + duration: 0 + }); +}, 'Test setPositionState with zero duration'); + +test(() => { + window.navigator.mediaSession.setPositionState({ + duration: 60.9, + position: 10.1, + playbackRate: -2.0 + }); +}, 'Test setPositionState with negative playback rate'); + +test(() => { + assert_throws_js( + TypeError, + _ => { + window.navigator.mediaSession.setPositionState({ + duration: -1 + }); + }); +}, 'Test setPositionState throws a TypeError if duration is negative'); + +test(() => { + assert_throws_js( + TypeError, + _ => { + window.navigator.mediaSession.setPositionState({ + duration: 10, + position: -1 + }); + }); +}, 'Test setPositionState throws a TypeError if position is negative'); + +test(() => { + assert_throws_js( + TypeError, + _ => { + window.navigator.mediaSession.setPositionState({ + duration: 10, + position: 20 + }); + }); +}, 'Test setPositionState throws a TypeError if duration is less than position'); + +test(() => { + assert_throws_js( + TypeError, + _ => { + window.navigator.mediaSession.setPositionState({ + duration: 60.9, + position: 10.1, + playbackRate: 0.0 + }); + }); +}, 'Test setPositionState throws a TypeError if playback rate is zero'); + +test(() => { + assert_throws_js( + TypeError, + _ => { + window.navigator.mediaSession.setPositionState({ + position: 10.1, + playbackRate: 1.0 + }); + }); +}, 'Test setPositionState throws a TypeError if duration is not specified'); +</script> |