Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / http / tests / media / media-source / mediasource-seek-beyond-duration.html
blobce8f01442853cf6ac559d938c0303b5054ab927e
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 function seekToSpecifiedTimeSetEOSAndVerifyDone(test, mediaElement, mediaSource, seekToTime)
15 assert_less_than(mediaElement.currentTime, mediaElement.duration, 'Not at the end yet.');
16 test.expectEvent(mediaElement, 'seeking', 'mediaElement seeking');
17 // Seek to specified time.
18 mediaElement.currentTime = seekToTime;
19 if (seekToTime >= mediaSource.duration) {
20 assert_equals(mediaElement.currentTime, mediaSource.duration, 'Current time equals duration.');
21 } else {
22 assert_equals(mediaElement.currentTime, seekToTime, 'Current time equals specified seek time.');
25 test.waitForExpectedEvents(function()
27 test.expectEvent(mediaElement, 'timeupdate', 'mediaElement time updated.');
28 test.expectEvent(mediaElement, 'seeked', 'mediaElement seeked');
29 test.expectEvent(mediaElement, 'ended', 'mediaElement ended.');
30 test.expectEvent(mediaSource, 'sourceended', 'mediaSource ended.');
31 mediaSource.endOfStream();
32 assert_true(mediaElement.seeking, 'mediaElement seeking.');
33 });
35 test.waitForExpectedEvents(function()
37 assert_equals(mediaElement.currentTime, mediaSource.duration, 'Current time equals duration.');
38 test.done();
39 });
42 mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
44 mediaElement.play();
45 var initSegment = MediaSourceUtil.extractSegmentData(mediaData, segmentInfo.init);
47 // Append the initialization segment to trigger a transition to HAVE_METADATA.
48 test.expectEvent(sourceBuffer, 'updateend', 'sourceBuffer end update.');
49 test.expectEvent(mediaElement, 'loadedmetadata', 'Reached HAVE_METADATA');
50 sourceBuffer.appendBuffer(initSegment);
52 test.waitForExpectedEvents(function()
54 // Add sufficient segments to have at least 2s of play-time.
55 var playbackData = MediaSourceUtil.getMediaDataForPlaybackTime(mediaData, segmentInfo, 2.0);
56 test.expectEvent(sourceBuffer, 'updateend', 'sourceBuffer');
57 test.expectEvent(mediaElement, 'playing', 'Playing media.');
58 sourceBuffer.appendBuffer(playbackData);
59 });
61 test.waitForExpectedEvents(function()
63 assert_equals(mediaElement.duration, segmentInfo.durationInInitSegment);
64 assert_greater_than_equal(mediaElement.duration, 2.0, 'Duration is >2.0s.');
65 test.waitForCurrentTimeChange(mediaElement, function()
67 // Update duration.
68 mediaSource.duration = 1.5;
69 seekToSpecifiedTimeSetEOSAndVerifyDone(test, mediaElement, mediaSource, 1.8);
70 });
71 });
72 }, 'Test seeking beyond updated media duration.');
74 mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData)
76 mediaElement.play();
78 // Append all media data for complete playback.
79 test.expectEvent(sourceBuffer, 'updateend', 'sourceBuffer end update.');
80 test.expectEvent(mediaElement, 'loadedmetadata', 'Reached HAVE_METADATA');
81 test.expectEvent(mediaElement, 'playing', 'Playing media.');
82 sourceBuffer.appendBuffer(mediaData);
84 test.waitForExpectedEvents(function()
86 test.waitForCurrentTimeChange(mediaElement, function()
88 seekToSpecifiedTimeSetEOSAndVerifyDone(test, mediaElement, mediaSource, mediaSource.duration, mediaSource.duration + 0.1);
89 });
90 });
92 }, 'Test seeking beyond media duration.');
93 </script>
94 </body>
95 </html>