summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/media-source/mediasource-closed.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/media-source/mediasource-closed.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/media-source/mediasource-closed.html')
-rw-r--r--testing/web-platform/tests/media-source/mediasource-closed.html140
1 files changed, 140 insertions, 0 deletions
diff --git a/testing/web-platform/tests/media-source/mediasource-closed.html b/testing/web-platform/tests/media-source/mediasource-closed.html
new file mode 100644
index 0000000000..79d522f2f9
--- /dev/null
+++ b/testing/web-platform/tests/media-source/mediasource-closed.html
@@ -0,0 +1,140 @@
+<!DOCTYPE html>
+<!-- Copyright © 2016 Chromium authors and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). -->
+<html>
+ <head>
+ <title>MediaSource.readyState equals "closed" test cases.</title>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="mediasource-util.js"></script>
+ </head>
+ <body>
+ <div id="log"></div>
+ <script>
+ test(function ()
+ {
+ var mediaSource = new MediaSource();
+ assert_equals(mediaSource.sourceBuffers.length, 0, "sourceBuffers is empty");
+ assert_equals(mediaSource.activeSourceBuffers.length, 0, "activeSourceBuffers is empty");
+ assert_equals(mediaSource.readyState, "closed", "readyState is 'closed'");
+ assert_true(isNaN(mediaSource.duration), "duration is NaN");
+ }, "Test attribute values on a closed MediaSource object.");
+
+ test(function ()
+ {
+ var mediaSource = new MediaSource();
+ assert_throws_dom("InvalidStateError",
+ function() { mediaSource.addSourceBuffer(MediaSourceUtil.VIDEO_ONLY_TYPE); },
+ "addSourceBuffer() throws an exception when closed.");
+ }, "Test addSourceBuffer() while closed.");
+
+ mediasource_test(function(test, mediaElement, mediaSource)
+ {
+ var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_ONLY_TYPE);
+
+ // Setup a handler to run when the MediaSource closes.
+ mediaSource.addEventListener('sourceclose', test.step_func(function (event)
+ {
+ assert_equals(mediaSource.sourceBuffers.length, 0, "sourceBuffers is empty");
+ assert_equals(mediaSource.activeSourceBuffers.length, 0, "activeSourceBuffers is empty");
+ assert_equals(mediaSource.readyState, "closed", "readyState is 'closed'");
+ assert_throws_dom("NotFoundError",
+ function() { mediaSource.removeSourceBuffer(sourceBuffer); },
+ "removeSourceBuffer() throws an exception when closed.");
+ test.done();
+ }));
+
+ // Trigger the MediaSource to close.
+ mediaElement.src = "";
+ }, "Test removeSourceBuffer() while closed.");
+
+ test(function ()
+ {
+ var mediaSource = new MediaSource();
+ assert_throws_dom("InvalidStateError",
+ function() { mediaSource.endOfStream(); },
+ "endOfStream() throws an exception when closed.");
+ }, "Test endOfStream() while closed.");
+
+ test(function ()
+ {
+ var mediaSource = new MediaSource();
+ assert_throws_dom("InvalidStateError",
+ function() { mediaSource.endOfStream("decode"); },
+ "endOfStream(decode) throws an exception when closed.");
+ }, "Test endOfStream(decode) while closed.");
+
+ test(function ()
+ {
+ var mediaSource = new MediaSource();
+ assert_throws_dom("InvalidStateError",
+ function() { mediaSource.endOfStream("network"); },
+ "endOfStream(network) throws an exception when closed.");
+ }, "Test endOfStream(network) while closed.");
+
+ test(function ()
+ {
+ var mediaSource = new MediaSource();
+ assert_throws_dom("InvalidStateError",
+ function() { mediaSource.duration = 10; },
+ "Setting duration throws an exception when closed.");
+ }, "Test setting duration while closed.");
+
+ mediasource_test(function(test, mediaElement, mediaSource)
+ {
+ var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_ONLY_TYPE);
+
+ assert_equals(mediaSource.readyState, "open", "readyState is 'open'");
+ // Setup a handler to run when the MediaSource closes.
+ mediaSource.addEventListener("sourceclose", test.step_func(function (event)
+ {
+ assert_equals(mediaSource.readyState, "closed", "readyState is 'closed'");
+ assert_throws_dom("InvalidStateError",
+ function() { mediaSource.duration = 10; },
+ "Setting duration when closed throws an exception");
+ test.done();
+ }));
+
+ // Trigger the MediaSource to close.
+ mediaElement.src = "";
+ }, "Test setting duration while open->closed.");
+
+ mediasource_test(function(test, mediaElement, mediaSource)
+ {
+ var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_ONLY_TYPE);
+
+ assert_equals(mediaSource.readyState, "open", "readyState is 'open'");
+ // Setup a handler to run when the MediaSource closes.
+ mediaSource.addEventListener("sourceclose", test.step_func(function (event)
+ {
+ assert_equals(mediaSource.readyState, "closed", "readyState is 'closed'");
+ assert_true(isNaN(mediaSource.duration), "duration is NaN");
+ test.done();
+ }));
+
+ // Trigger the MediaSource to close.
+ mediaElement.src = "";
+ }, "Test getting duration while open->closed.");
+
+ mediasource_test(function(test, mediaElement, mediaSource)
+ {
+ var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_ONLY_TYPE);
+
+ assert_equals(mediaSource.readyState, "open", "readyState is open");
+
+ // Setup a handler to run when the MediaSource closes.
+ mediaSource.addEventListener("sourceclose", test.step_func(function (event)
+ {
+ assert_equals(mediaSource.readyState, "closed", "readyState is closed");
+ assert_throws_dom("InvalidStateError",
+ function() { sourceBuffer.abort(); },
+ "sourceBuffer.abort() throws INVALID_STATE_ERROR");
+ test.done();
+ }));
+
+ // Trigger the MediaSource to close.
+ mediaElement.src = "";
+ }, "Test sourcebuffer.abort when closed.");
+
+ </script>
+ </body>
+</html>