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

Side by Side Diff: third_party/WebKit/LayoutTests/media/track/track-cues-enter-exit.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 enter and exits events on TextTrackCue.</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
8 (Please avoid writing new tests using video-test.js) --> 16 video.oncanplaythrough = t.step_func(attemptTests);
9 <script src=../video-test.js></script>
10 17
11 <script> 18 function attemptTests() {
19 assert_equals(testTrack.track.cues.length, 3);
20 for (var i = 0; i < testTrack.track.cues.length; i++) {
21 testTrack.track.cues[i].onenter = t.step_func(cueEntered);
22 testTrack.track.cues[i].onexit = t.step_func(cueExited);
23 }
24 video.play();
25 }
12 26
13 var cueCount = 0; 27 var cueCount = 0;
14 var currentCue; 28 function cueEntered() {
15 var testTrack; 29 var currentCue = event.target;
16 30
17 var trackLoaded = false; 31 // This cue is the currently active cue.
18 var videoCanPlayThrough = false; 32 assert_equals(currentCue, testTrack.track.activeCues[0]);
33 assert_equals(currentCue.id, (cueCount + 1).toString());
34 }
19 35
20 function attemptTests() 36 function cueExited() {
21 { 37 ++cueCount;
22 if (!trackLoaded || !videoCanPlayThrough) 38 if (cueCount == testTrack.track.cues.length)
23 return; 39 t.done();
24 40 }
25 testTrack = document.getElementById("testTrack"); 41 });
26 testExpected("testTrack.track.cues.length", 3); 42 </script>
27 for (var i = 0; i < testTrack.track.cues.length; i++) {
28 testTrack.track.cues[i].addEventListener('enter', cueEntered);
29 testTrack.track.cues[i].addEventListener('exit', cueExited);
30 }
31 run("video.play()");
32 consoleWrite("");
33 }
34
35 function cueEntered()
36 {
37 consoleWrite("EVENT(enter)");
38
39 currentCue = event.target;
40
41 consoleWrite("This cue is the currently active cue:");
42 testExpected(currentCue, testTrack.track.activeCues[0]);
43 testExpected("currentCue.id", cueCount + 1);
44 consoleWrite("");
45 }
46
47 function cueExited()
48 {
49 consoleWrite("EVENT(exit)");
50 consoleWrite("");
51
52 ++cueCount;
53 if (cueCount == testTrack.track.cues.length)
54 endTest();
55 }
56
57 waitForEvent('canplaythrough',
58 function ()
59 {
60 videoCanPlayThrough = true;
61 attemptTests();
62 }
63 );
64
65 function loaded()
66 {
67 trackLoaded = true;
68 attemptTests();
69 }
70
71 function start()
72 {
73 findMediaElement();
74 video.src = findMediaFile("video", "../content/test");
75 }
76 </script>
77 </head>
78 <body onload="start()">
79 <p>Tests that TextTrack's cues are indexed and updated in order during v ideo playback. Test uses the enter and exits events on TextTrackCue.</p>
80 <video controls>
81 <track id="testTrack" src="captions-webvtt/cues-chrono-order.vtt" ki nd="captions" onload="loaded()" default>
82 </video>
83 </body>
84 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698