Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / media / media-source / mediasource-removesourcebuffer.html
blob3e6dfd59d9dd008fd761fd31ec0634dcc2ad6a56
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="/w3c/resources/testharness.js"></script>
5 <script src="/w3c/resources/testharnessreport.js"></script>
6 <script src="mediasource-util.js"></script>
8 <link rel='stylesheet' href='/w3c/resources/testharness.css'>
9 </head>
10 <body>
11 <div id="log"></div>
12 <script>
13 mediasource_test(function(test, mediaElement, mediaSource)
15 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_VIDEO_TYPE);
16 assert_true(sourceBuffer != null, "New SourceBuffer returned");
18 mediaSource.removeSourceBuffer(sourceBuffer);
20 var sourceBuffer2 = mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_VIDEO_TYPE);
21 assert_true(sourceBuffer2 != null, "New SourceBuffer returned");
22 assert_true(sourceBuffer != sourceBuffer2, "SourceBuffers are different instances.");
23 assert_equals(mediaSource.sourceBuffers.length, 1, "sourceBuffers.length == 1");
25 test.done();
26 }, "Test addSourceBuffer(), removeSourceBuffer(), addSourceBuffer() sequence.");
28 mediasource_test(function(test, mediaElement, mediaSource)
30 assert_throws(new TypeError(),
31 function() { mediaSource.removeSourceBuffer(null); },
32 "removeSourceBuffer() threw an exception when passed null.");
33 test.done();
34 }, "Test removeSourceBuffer() with null");
36 mediasource_test(function(test, mediaElement, mediaSource)
38 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_VIDEO_TYPE);
39 assert_true(sourceBuffer != null, "New SourceBuffer returned");
41 mediaSource.removeSourceBuffer(sourceBuffer);
43 assert_throws("NotFoundError",
44 function() { mediaSource.removeSourceBuffer(sourceBuffer); },
45 "removeSourceBuffer() threw an exception when a SourceBuffer that was already removed.");
47 test.done();
48 }, "Test calling removeSourceBuffer() twice with the same object.");
50 mediasource_test(function(test, mediaElement, mediaSource)
52 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_VIDEO_TYPE);
53 assert_true(sourceBuffer != null, "New SourceBuffer returned");
55 mediaSource.endOfStream();
56 assert_true(mediaSource.readyState == 'ended', "MediaSource in ended state");
57 mediaSource.removeSourceBuffer(sourceBuffer);
59 assert_true(mediaSource.sourceBuffers.length == 0, "MediaSource.sourceBuffers is empty");
60 assert_true(mediaSource.activeSourceBuffers.length == 0, "MediaSource.activesourceBuffers is empty");
62 test.done();
63 }, "Test calling removeSourceBuffer() in ended state.");
65 mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
67 var initSegment = MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.init);
69 test.expectEvent(sourceBuffer, 'updateend', 'initSegment append ended.');
70 test.expectEvent(mediaElement, 'loadedmetadata', 'loadedmetadata done.');
71 sourceBuffer.appendBuffer(initSegment);
73 test.waitForExpectedEvents(function()
75 assert_true(mediaSource.sourceBuffers.length == 1, "MediaSource.sourceBuffers is not empty");
76 assert_true(mediaSource.activeSourceBuffers.length == 1, "MediaSource.activesourceBuffers is not empty");
77 assert_equals(mediaElement.readyState, mediaElement.HAVE_METADATA);
78 assert_equals(mediaSource.duration, segmentInfo.durationInInitSegment);
79 test.expectEvent(mediaSource.activeSourceBuffers, 'removesourcebuffer', 'SourceBuffer removed from activeSourceBuffers.');
80 test.expectEvent(mediaSource.sourceBuffers, 'removesourcebuffer', 'SourceBuffer removed.');
81 mediaSource.removeSourceBuffer(sourceBuffer);
82 });
84 test.waitForExpectedEvents(function()
86 assert_true(mediaSource.sourceBuffers.length == 0, "MediaSource.sourceBuffers is empty");
87 assert_true(mediaSource.activeSourceBuffers.length == 0, "MediaSource.activesourceBuffers is empty");
88 test.done();
89 });
90 }, 'Test removesourcebuffer event on activeSourceBuffers.');
91 </script>
92 </body>
93 </html>