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

Side by Side Diff: third_party/WebKit/LayoutTests/media/track/track-cues-sorted-before-dispatch.html

Issue 2074913006: Convert track-cues* and track-delete* tests to testharness.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address nit Created 4 years, 6 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/media/track/track-cues-sorted-before-dispatch-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <title>Tests that all events are triggered in chronological order.</title>
3 <head> 3 <script src="../../resources/testharness.js"></script>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 4 <script src="../../resources/testharnessreport.js"></script>
5 <script src="../media-file.js"></script>
6 <video>
7 <track src="captions-webvtt/sorted-dispatch.vtt" default>
8 </video>
9 <script>
10 async_test(function(t) {
11 var video = document.querySelector("video");
12 video.src = findMediaFile("video", "../content/test");
13 var track = document.querySelector("track");
5 14
6 <script src=../media-file.js></script> 15 track.onload = t.step_func(function() {
7 <!-- TODO(foolip): Convert test to testharness.js. crbug.com/588956 16 var cues = track.track.cues;
8 (Please avoid writing new tests using video-test.js) --> 17 assert_equals(cues.length, 8);
9 <script src=../video-test.js></script>
10 <script>
11 var videoCanPlayThrough = false;
12 var trackLoaded = false;
13 18
14 var currentCue; 19 for (var i = 0; i < cues.length; ++i) {
15 var testTrack; 20 cues[i].onenter = t.step_func(cueEnteredOrExited);
21 cues[i].onexit = t.step_func(cueEnteredOrExited);
22 }
16 23
17 var dispatchedEvents = []; 24 video.play();
25 });
18 26
19 function runTests() 27 var cueTimings = [];
20 { 28 function cueEnteredOrExited(event) {
21 if (!trackLoaded || !videoCanPlayThrough) 29 var currentCue = event.target;
22 return;
23 30
24 testTrack = document.getElementById("testTrack"); 31 if (event.type == "exit")
25 testExpected("testTrack.track.cues.length", 8); 32 cueTimings.push(currentCue.endTime);
33 else
34 cueTimings.push(currentCue.startTime);
35 }
26 36
27 for (var i = 0; i < testTrack.track.cues.length; ++i) { 37 video.onended = t.step_func_done(function() {
28 testTrack.track.cues[i].addEventListener('enter', cueEntered OrExited); 38 assert_equals(cueTimings.length, 14);
29 testTrack.track.cues[i].addEventListener('exit', cueEnteredO rExited); 39 var time = 0;
30 } 40 for (var i = 0; i < cueTimings.length; ++i) {
41 assert_less_than_equal(time, cueTimings[i], "cueTimings[" + i + "]") ;
42 time = cueTimings[i];
43 }
44 });
31 45
32 run("video.play()"); 46 video.currentTime = 5;
33 } 47 });
34 48 </script>
35 function cueEnteredOrExited(event)
36 {
37 currentCue = event.target;
38
39 var eventObj = {};
40
41 eventObj.time = currentCue.startTime;
42 if (event.type == 'exit')
43 eventObj.time = currentCue.endTime;
44
45 eventObj.type = event.type;
46 eventObj.cue = currentCue;
47
48 dispatchedEvents.push(eventObj);
49 }
50
51 function loaded()
52 {
53 trackLoaded = true;
54 runTests();
55 }
56
57 function bodyLoaded()
58 {
59 findMediaElement();
60 video.src = findMediaFile("video", "../content/test");
61 }
62
63 function logEndTest()
64 {
65 for (var i = 0; i < dispatchedEvents.length; ++i) {
66 consoleWrite("Cue event: " + dispatchedEvents[i].type +
67 " id: " + dispatchedEvents[i].cue.id +
68 " time: " + dispatchedEvents[i].time);
69 }
70
71 endTest();
72 }
73
74 waitForEvent('ended', logEndTest);
75
76 waitForEventOnce('canplaythrough', function() {
77 video.currentTime = 5.00;
78 videoCanPlayThrough = true;
79
80 runTests();
81 });
82
83 </script>
84 </head>
85 <body onload="bodyLoaded()">
86 <p>Tests that all events events are triggered in chronological order.</p >
87 <video controls>
88 <track id="testTrack" src="captions-webvtt/sorted-dispatch.vtt" onlo ad="loaded()" default>
89 </video>
90 </body>
91 </html>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/media/track/track-cues-sorted-before-dispatch-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698