summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/media-source/mediasource-sourcebufferlist.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/media-source/mediasource-sourcebufferlist.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/media-source/mediasource-sourcebufferlist.html')
-rw-r--r--testing/web-platform/tests/media-source/mediasource-sourcebufferlist.html97
1 files changed, 97 insertions, 0 deletions
diff --git a/testing/web-platform/tests/media-source/mediasource-sourcebufferlist.html b/testing/web-platform/tests/media-source/mediasource-sourcebufferlist.html
new file mode 100644
index 000000000..760e6df46
--- /dev/null
+++ b/testing/web-platform/tests/media-source/mediasource-sourcebufferlist.html
@@ -0,0 +1,97 @@
+<!DOCTYPE html>
+<!-- Copyright © 2016 Chromium authors and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). -->
+<html>
+ <head>
+ <title>SourceBufferList 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>
+ function verifySourceBufferLists(mediaSource, expected)
+ {
+ assert_equals(mediaSource.sourceBuffers.length, expected.length, "sourceBuffers length");
+ assert_equals(mediaSource.activeSourceBuffers.length, 0, "activeSourceBuffers length");
+ for (var i = 0; i < expected.length; ++i) {
+ assert_equals(mediaSource.sourceBuffers[i], expected[i], "Verifying mediaSource.sourceBuffers[" + i + "]");
+ }
+ assert_equals(mediaSource.sourceBuffers[expected.length], undefined,
+ "If index is greater than or equal to the length attribute then return undefined.");
+ }
+
+ mediasource_test(function(test, mediaElement, mediaSource)
+ {
+ var sourceBufferA = mediaSource.addSourceBuffer(MediaSourceUtil.VIDEO_ONLY_TYPE);
+ verifySourceBufferLists(mediaSource, [sourceBufferA]);
+
+ var sourceBufferB = mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_ONLY_TYPE);
+ verifySourceBufferLists(mediaSource, [sourceBufferA, sourceBufferB]);
+ test.done();
+ }, "Test SourceBufferList getter method");
+
+ mediasource_test(function(test, mediaElement, mediaSource)
+ {
+ test.expectEvent(mediaSource.sourceBuffers, "addsourcebuffer", "sourceBuffers");
+ var sourceBufferA = mediaSource.addSourceBuffer(MediaSourceUtil.VIDEO_ONLY_TYPE);
+ var sourceBufferB = null;
+
+ test.waitForExpectedEvents(function()
+ {
+ test.expectEvent(mediaSource.sourceBuffers, "addsourcebuffer", "sourceBuffers");
+ sourceBufferB = mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_ONLY_TYPE);
+
+ verifySourceBufferLists(mediaSource, [sourceBufferA, sourceBufferB]);
+ });
+
+ test.waitForExpectedEvents(function()
+ {
+ test.expectEvent(mediaSource.sourceBuffers, "removesourcebuffer", "sourceBuffers");
+ mediaSource.removeSourceBuffer(sourceBufferA);
+
+ verifySourceBufferLists(mediaSource, [sourceBufferB]);
+
+ test.expectEvent(mediaSource.sourceBuffers, "addsourcebuffer", "sourceBuffers");
+ sourceBufferA = mediaSource.addSourceBuffer(MediaSourceUtil.VIDEO_ONLY_TYPE);
+
+ verifySourceBufferLists(mediaSource, [sourceBufferB, sourceBufferA]);
+ });
+
+ test.waitForExpectedEvents(function()
+ {
+ test.done();
+ });
+ }, "Test SourceBufferList event dispatching.");
+
+ mediasource_test(function(test, mediaElement, mediaSource)
+ {
+ test.expectEvent(mediaSource.sourceBuffers, "addsourcebuffer", "sourceBuffers");
+ test.expectEvent(mediaSource.sourceBuffers, "addsourcebuffer", "sourceBuffers");
+ var sourceBufferA = mediaSource.addSourceBuffer(MediaSourceUtil.VIDEO_ONLY_TYPE);
+ var sourceBufferB = mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_ONLY_TYPE);
+
+ verifySourceBufferLists(mediaSource, [sourceBufferA, sourceBufferB]);
+
+ test.waitForExpectedEvents(function()
+ {
+ verifySourceBufferLists(mediaSource, [sourceBufferA, sourceBufferB]);
+
+ // Force the media element to close the MediaSource object.
+ test.expectEvent(mediaSource.sourceBuffers, "removesourcebuffer", "sourceBuffers");
+ test.expectEvent(mediaSource, "sourceclose", "mediaSource closing");
+ mediaElement.src = "";
+ });
+
+ test.waitForExpectedEvents(function()
+ {
+ assert_equals(mediaSource.readyState, "closed", "mediaSource is closed.");
+
+ verifySourceBufferLists(mediaSource, []);
+ test.done();
+ });
+ }, "Test that only 1 removesourcebuffer event fires on each SourceBufferList when the MediaSource closes.");
+
+ </script>
+ </body>
+</html>