Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / media / media-source / mediasource-seek-during-pending-seek.html
blobe0cf192b09e7f6d9c1d149bfc8090465ca7a5da3
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>
7 <link rel='stylesheet' href='/w3c/resources/testharness.css'>
8 </head>
9 <body>
10 <div id="log"></div>
11 <script>
13 mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
15 mediaElement.play();
17 var initSegment = MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.init);
18 var firstSegment = MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.media[0]);
19 var secondSegmentInfo = segmentInfo.media[2];
20 var secondSegment = MediaSourceUtil.extractSegmentData(mediaData, secondSegmentInfo);
22 // Append the initialization segment to trigger a transition to HAVE_METADATA.
23 test.expectEvent(sourceBuffer, 'updateend', 'sourceBuffer');
24 test.expectEvent(mediaElement, 'loadedmetadata', 'Reached HAVE_METADATA');
25 sourceBuffer.appendBuffer(initSegment);
27 test.waitForExpectedEvents(function()
29 assert_false(mediaElement.seeking, 'mediaElement is not seeking');
30 assert_equals(mediaElement.readyState, mediaElement.HAVE_METADATA, 'Still in HAVE_METADATA');
32 // Seek to a new position before letting the initial seek to 0 completes.
33 test.expectEvent(mediaElement, 'seeking', 'mediaElement');
34 mediaElement.currentTime = secondSegmentInfo.timecode;
35 assert_true(mediaElement.seeking, 'mediaElement is seeking');
37 // Append media data for time 0.
38 test.expectEvent(sourceBuffer, 'updateend', 'sourceBuffer');
39 sourceBuffer.appendBuffer(firstSegment);
40 });
42 test.waitForExpectedEvents(function()
44 // Verify that the media data didn't trigger a 'seeking' event or a transition beyond HAVE_METADATA.
45 assert_true(mediaElement.seeking, 'mediaElement is still seeking');
46 assert_equals(mediaElement.readyState, mediaElement.HAVE_METADATA, 'Still in HAVE_METADATA');
48 // Append media data for the current position.
49 test.expectEvent(sourceBuffer, 'updateend', 'sourceBuffer');
50 test.expectEvent(mediaElement, 'seeked', 'mediaElement finished seek');
51 test.expectEvent(mediaElement, 'playing', 'mediaElement playing');
52 sourceBuffer.appendBuffer(secondSegment);
53 });
55 test.waitForExpectedEvents(function()
57 test.expectEvent(mediaSource, 'sourceended', 'mediaSource ended');
58 mediaSource.endOfStream();
59 });
61 test.waitForExpectedEvents(function()
63 assert_greater_than(mediaElement.readyState, mediaElement.HAVE_CURRENT_DATA, 'Greater than HAVE_CURRENT_DATA');
64 test.done();
65 });
67 }, 'Test seeking to a new location before transitioning beyond HAVE_METADATA.', {timeout: 10000} );
69 mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
71 mediaElement.play();
73 var initSegment = MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.init);
74 var firstSegment = MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.media[0]);
75 var secondSegmentInfo = segmentInfo.media[2];
76 var secondSegment = MediaSourceUtil.extractSegmentData(mediaData, secondSegmentInfo);
77 var thirdSegmentInfo = segmentInfo.media[4];
78 var thirdSegment = MediaSourceUtil.extractSegmentData(mediaData, thirdSegmentInfo);
80 // Append the initialization segment to trigger a transition to HAVE_METADATA.
81 test.expectEvent(sourceBuffer, 'updateend', 'sourceBuffer');
82 test.expectEvent(mediaElement, 'loadedmetadata', 'Reached HAVE_METADATA');
83 sourceBuffer.appendBuffer(initSegment);
85 test.waitForExpectedEvents(function()
87 test.expectEvent(sourceBuffer, 'updateend', 'sourceBuffer');
88 test.expectEvent(mediaElement, 'playing', 'mediaElement playing');
89 sourceBuffer.appendBuffer(firstSegment);
90 });
92 test.waitForExpectedEvents(function()
94 assert_greater_than(mediaElement.readyState, mediaElement.HAVE_CURRENT_DATA, 'Greater than HAVE_CURRENT_DATA');
96 // Seek to a new position.
97 test.expectEvent(mediaElement, 'seeking', 'mediaElement');
98 mediaElement.currentTime = secondSegmentInfo.timecode;
99 assert_true(mediaElement.seeking, 'mediaElement is seeking');
103 test.waitForExpectedEvents(function()
105 assert_true(mediaElement.seeking, 'mediaElement is still seeking');
107 // Seek to a second position while the first seek is still pending.
108 test.expectEvent(mediaElement, 'seeking', 'mediaElement');
109 mediaElement.currentTime = thirdSegmentInfo.timecode;
110 assert_true(mediaElement.seeking, 'mediaElement is seeking');
112 // Append media data for the first seek position.
113 test.expectEvent(sourceBuffer, 'updateend', 'sourceBuffer');
114 sourceBuffer.appendBuffer(secondSegment);
117 test.waitForExpectedEvents(function()
119 assert_true(mediaElement.seeking, 'mediaElement is still seeking');
121 // Append media data for the second seek position.
122 test.expectEvent(sourceBuffer, 'updateend', 'sourceBuffer');
123 test.expectEvent(mediaElement, 'seeked', 'mediaElement finished seek');
124 sourceBuffer.appendBuffer(thirdSegment);
127 test.waitForExpectedEvents(function()
129 assert_false(mediaElement.seeking, 'mediaElement is no longer seeking');
131 test.expectEvent(mediaSource, 'sourceended', 'mediaSource ended');
132 mediaSource.endOfStream();
135 test.waitForExpectedEvents(function()
137 assert_greater_than(mediaElement.readyState, mediaElement.HAVE_CURRENT_DATA, 'Greater than HAVE_CURRENT_DATA');
138 test.done();
140 }, 'Test seeking to a new location during a pending seek.', {timeout: 10000} );
141 </script>
142 </body>
143 </html>