Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/media/video-play-stall.html

Issue 2115143002: Transition media element to HAVE_CURRENT_DATA upon underflow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <video></video> 1 <video id="test_video"></video>
wolenetz 2016/07/07 21:32:03 {linux,win}_chromium_rel_ng bots didn't pass this
chcunningham 2016/07/07 22:29:41 The failure is: 17:12:24.365 252 worker/0 http/te
chcunningham 2016/07/12 00:47:17 I've changed the console.log calls to instead log
wolenetz 2016/07/13 22:27:54 Acknowledged.
2 <p>Test that stalled, timeupdate and waiting events are sent when media load sta lls in the middle.</p> 2 <p>Test that stalled, timeupdate and waiting events are sent when media load sta lls in the middle.</p>
3 <script src=../../media-resources/media-file.js></script> 3 <script src=../../media-resources/media-file.js></script>
4 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 4 <script src="/w3c/resources/testharness.js"></script>
5 (Please avoid writing new tests using video-test.js) --> 5 <script src="/w3c/resources/testharnessreport.js"></script>
6 <script src=../../media-resources/video-test.js></script>
7 <script> 6 <script>
7 async_test(t => {
wolenetz 2016/07/07 21:32:03 nit: left justify 0-margin the outermost portion o
wolenetz 2016/07/07 21:32:03 nit: is the => {... consistent with other tests? W
chcunningham 2016/07/12 00:47:17 Done.
chcunningham 2016/07/12 00:47:18 I think you mean async_test(function(t) { ... }).
wolenetz 2016/07/13 22:27:54 Acknowledged.
8 let video = document.getElementById('test_video');
8 9
9 var timeupdateCount = 0; 10 // For debugging.
10 var waitingCount = 0; 11 function logEvent(e) { console.log('event fired:' + e.type); };
11 12
12 waitForEvent('durationchange'); 13 let ReadyState = {
wolenetz 2016/07/07 21:32:03 These are already exposed on the IDL for HTMLMedia
chcunningham 2016/07/12 00:47:18 Duh! Done.
13 waitForEvent('loadedmetadata'); 14 HAVE_NOTHING: 0,
14 waitForEvent('loadeddata'); 15 HAVE_METADATA: 1,
15 waitForEvent('canplaythrough'); 16 HAVE_CURRENT_DATA: 2,
16 waitForEvent('canplay', function () { 17 HAVE_FUTURE_DATA: 3,
18 HAVE_ENOUGH_DATA: 4
19 }
17 20
18 mediaElement.addEventListener('timeupdate', function () { 21 playback_ew = new EventWatcher(t, video, [
19 // timeupdate events are fired as playback progresses so only verify that at least one 22 'canplay',
20 // event is fired 23 'canplaythrough',
21 ++timeupdateCount; 24 'durationchange',
22 if (timeupdateCount == 1) 25 'loadedmetadata',
23 consoleWrite("EVENT(timeupdate)"); 26 'loadeddata',
24 } ); 27 'play',
28 'playing',
29 'waiting']);
25 30
26 waitForEvent('waiting', function () { 31 // The stalled event needs a separate watcher as it can be fired at
27 ++waitingCount; 32 // any point during the sequence of other playback events. Stalled is
28 if (waitingCount > 1) 33 // triggered by prolonged network inactivity.
29 failTest("too many 'waiting' events fired."); 34 stalled_ew = new EventWatcher(t, video, [
35 'stalled']);
30 36
31 waitForEvent('timeupdate'); 37 // This helper is an alternative to EventWatcher for events that fire
32 } ); 38 // on a recurring basis. EventWatcher is not suitable because you must
39 // always be "waiting" for the event to fire every time, whereas this
40 // method allows you to just verify that it fired once and move on.
41 function waitForRecurringEvent(name) {
42 let resolve_cb;
43 let promise = new Promise(function(resolve, reject) {
44 resolve_cb = resolve;
45 });
46 video.addEventListener(name, t.step_func((evt) => resolve_cb(evt)));
47 return promise;
48 }
33 49
34 waitForEventAndEnd('stalled'); 50 // NOTE: Event sequence verification is achieved by chaining together
35 } ); 51 // promises via then(). To verify separate parallel event sequences
52 // (e.g. playback vs network), we setup separate chains of promises.
53 // Promise.all ensures that all separate sequences complete.
36 54
37 // Find a supported media file. 55 // Verify playback progress then runs out of data.
38 var mediaFile = findMediaFile("video", "content/test"); 56 Promise.all([
39 var mimeType = mimeTypeForFile(mediaFile); 57 // First wait for the resource to load.
58 playback_ew.wait_for('durationchange').then(logEvent)
59 .then(() => playback_ew.wait_for('loadedmetadata')).then(logEvent)
60 .then(() => playback_ew.wait_for('loadeddata')).then(logEvent)
61 .then(() => playback_ew.wait_for('canplay')).then(logEvent)
62 .then(() => playback_ew.wait_for('canplaythrough')).then(logEvent)
63 .then(t.step_func(function() {
64 assert_true(video.readyState > ReadyState.HAVE_CURRENT_DATA);
65 }))
66 // Now play the file and wait for playback to stall (fire waiting).
67 .then(t.step_func(function() {
68 video.play();
69 // NOTE: setting the wait_for here because we will miss it if we
70 // do it after the play call resolves its promise.
71 return playback_ew.wait_for('play').then(logEvent);
72 }))
73 .then(() => playback_ew.wait_for('playing')).then(logEvent)
74 // Now observe waiting event and verify readyState
75 .then(() => playback_ew.wait_for('waiting')).then(logEvent)
76 .then(t.step_func(function(){
77 assert_equals(ReadyState.HAVE_CURRENT_DATA, video.readyState);
78 })),
40 79
41 video.src = "http://127.0.0.1:8000/resources/load-and-stall.cgi?name=../../. ./media/" + mediaFile + "&mimeType=" + mimeType + "&stallAt=100000&stallFor=6"; 80 // timeupdate should fire throughout playback. Make sure we see one.
42 run("video.play()"); 81 waitForRecurringEvent('timeupdate').then(logEvent),
82
83 // progress should fire throughout download. Make sure we see one.
84 // Later the download should stall.
85 waitForRecurringEvent('progress').then(logEvent)
86 .then(() => stalled_ew.wait_for('stalled')).then(logEvent)
87
88 // Verify download and playback resume.
89 ]).then(() => Promise.all([
90 // Playback should resume when download again makes progress.
91 waitForRecurringEvent('progress').then(logEvent),
92
93 // timeupdate should fire throughout playback. Make sure we see one.
94 waitForRecurringEvent('timeupdate').then(logEvent),
95
96 // Verify correct sequence of playback events.
97 playback_ew.wait_for('canplay').then(logEvent)
98 .then(t.step_func(function() {
99 assert_true(video.readyState > ReadyState.HAVE_CURRENT_DATA);
100 }))
101 .then(() => playback_ew.wait_for('playing')).then(logEvent)
102 .then(() => playback_ew.wait_for('canplaythrough')).then(logEvent)
103 ])).then(t.step_func_done());
104
105
106 // Find a supported media file.
107 var mediaFile = findMediaFile("video", "content/test");
108 var mimeType = mimeTypeForFile(mediaFile);
109 // URL will load part of the file, pause for 6 seconds, then load the re st.
110 // The delay of 6 seconds is chosen to reduce flakiness in waiting for t he
111 // stalled event, which should arrive after roughly 3 seconds of inactiv ity.
112 video.src = "http://127.0.0.1:8000/resources/load-and-stall.cgi?name=../ ../../media/" + mediaFile + "&mimeType=" + mimeType + "&stallAt=100000&stallFor= 6";
113
114 }, "Stalled download pauses playback. When download resumes playback continu es. Verify events and readyStates.");
43 </script> 115 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698