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

Side by Side Diff: third_party/WebKit/LayoutTests/media/track/track-cues-cuechange.html

Issue 1905923004: Convert track tests from video-test.js to testharness.js based (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 8 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 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <title>Tests that TextTrack's cues are indexed and updated in order during video playback. Test uses the cuechange event.</title>
3 <head> 3 <script src="../media-file.js"></script>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 4 <script src="../../resources/testharness.js"></script>
5 <script src="../../resources/testharnessreport.js"></script>
6 <video>
7 <track src="captions-webvtt/cues-chrono-order.vtt" kind="captions" default>
8 </video>
9 <script>
10 async_test(function(t) {
11 var video = document.querySelector("video");
12 var testTrack = document.querySelector("track");
5 13
6 <script src=../media-file.js></script> 14 video.src = findMediaFile("video", "../content/test");
7 <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956 15 video.oncanplaythrough = t.step_func(attemptTests);
8 (Please avoid writing new tests using video-test.js) -->
9 <script src=../video-test.js></script>
10 16
11 <script> 17 function attemptTests() {
18 assert_equals(testTrack.track.cues.length, 3);
19 testTrack.oncuechange = t.step_func(cueChangedFromTrackElement);
20 video.play();
21 }
12 22
13 var cueChangeCount = 0; 23 var currentCueIndex;
14 var currentCue; 24 var cueChangeCount = 0;
15 var testTrack; 25 function cueChangedFromTrackElement() {
16 26 currentCueIndex = Math.floor(cueChangeCount / 2);
17 var trackLoaded = false; 27 currentCue = event.target.track.cues[currentCueIndex];
18 var videoCanPlayThrough = false; 28 if (cueChangeCount % 2 == 0) {
19 29 // Cue entered.
20 function attemptTests() 30 assert_equals(currentCue, testTrack.track.activeCues[0]);
21 { 31 assert_equals(currentCue.id, (currentCueIndex + 1).toString());
22 if (!trackLoaded || !videoCanPlayThrough)
23 return;
24
25 testTrack = document.getElementById("testTrack");
26 testExpected("testTrack.track.cues.length", 3);
27 testTrack.addEventListener('cuechange', cueChangedFromTrackElement);
28 testTrack.track.addEventListener('cuechange', cueChangedFromTextTrac k);
29 run("video.play()");
30 consoleWrite("");
31 } 32 }
32 33
33 function cueChangedFromTextTrack() 34 ++cueChangeCount;
34 { 35 if (cueChangeCount == testTrack.track.cues.length * 2)
35 consoleWrite("EVENT(cuechange) from TextTrack"); 36 t.done();
36 } 37 }
37 38 });
38 function cueChangedFromTrackElement() 39 </script>
39 {
40 consoleWrite("EVENT(cuechange) from &lt;track&gt;");
41
42 currentCueIndex = Math.floor(cueChangeCount / 2);
43 currentCue = event.target.track.cues[currentCueIndex];
44 checkCue();
45
46 ++cueChangeCount;
47 if (cueChangeCount == testTrack.track.cues.length * 2)
48 endTest();
49 }
50
51 function checkCue()
52 {
53 if (cueChangeCount % 2 == 0) {
54 consoleWrite("Cue entered");
55 testExpected(currentCue, testTrack.track.activeCues[0]);
56 testExpected("currentCue.id", currentCueIndex + 1);
57 } else
58 consoleWrite("Cue exited");
59 consoleWrite("");
60 }
61
62 waitForEvent('canplaythrough',
63 function ()
64 {
65 videoCanPlayThrough = true;
66 attemptTests();
67 }
68 );
69
70 function loaded()
71 {
72 trackLoaded = true;
73 attemptTests();
74 }
75
76 function start()
77 {
78 findMediaElement();
79 video.src = findMediaFile("video", "../content/test");
80 }
81
82 </script>
83 </head>
84 <body onload="start()">
85 <p>Tests that TextTrack's cues are indexed and updated in order during v ideo playback. Test uses the cuechange event.</p>
86 <video controls>
87 <track id="testTrack" src="captions-webvtt/cues-chrono-order.vtt" ki nd="captions" onload="loaded()" default>
88 </video>
89 </body>
90 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698