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

Side by Side Diff: third_party/WebKit/LayoutTests/media/track/track-css-matching-timestamps.html

Issue 1875923002: 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>Test that cues are being matched properly by :past and :future pseudo cla sses.</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="../media-controls.js"></script>
5 <script src="../../resources/testharness.js"></script>
6 <script src="../../resources/testharnessreport.js"></script>
7 <video></video>
8 <style>
9 video::cue {color: green}
10 video::cue(:past) {color: lime}
11 video::cue(:future) {color: gray}
12 </style>
13 <script>
14 async_test(function(t) {
15 var seekTimeIndex = 0;
16 var seekTimes = [0.1, 0.3, 0.5, 0.7, 0.9];
5 17
6 <script src=../media-file.js></script> 18 var info = [["rgb(128, 128, 128)", "rgb(128, 128, 128)", "rgb(128, 128, 128) ", "rgb(128, 128, 128)", "rgb(128, 128, 128)"],
7 <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956 19 ["rgb(0, 255, 0)", "rgb(128, 128, 128)", "rgb(128, 128, 128)", " rgb(128, 128, 128)", "rgb(128, 128, 128)"],
8 (Please avoid writing new tests using video-test.js) --> 20 ["rgb(0, 255, 0)", "rgb(0, 255, 0)", "rgb(128, 128, 128)", "rgb( 128, 128, 128)", "rgb(128, 128, 128)"],
9 <script src=../video-test.js></script> 21 ["rgb(0, 255, 0)", "rgb(0, 255, 0)", "rgb(0, 255, 0)", "rgb(128, 128, 128)", "rgb(0, 255, 0)"],
10 <script src=../media-controls.js></script> 22 ["rgb(0, 255, 0)", "rgb(0, 255, 0)", "rgb(0, 255, 0)", "rgb(0, 2 55, 0)", "rgb(0, 255, 0)"]];
23
24 var video = document.querySelector("video");
25 video.src = findMediaFile("video", "../content/test");
26
27 var track = document.createElement("track");
28 track.src = "captions-webvtt/styling-timestamps.vtt";
29 track.kind = "captions";
30 track.default = true;
31 video.appendChild(track);
11 32
12 <style> 33 video.onseeked = t.step_func(function() {
13 video::cue {color: green} 34 assert_equals(video.currentTime, seekTimes[seekTimeIndex]);
14 video::cue(:past) {color: lime} 35 var cueNode = textTrackDisplayElement(video, "cue").firstElementChild;
15 video::cue(:future) {color: gray} 36 assert_equals(getComputedStyle(cueNode).color, info[seekTimeIndex][0]);
16 </style> 37 cueNode = cueNode.nextElementSibling;
38 assert_equals(getComputedStyle(cueNode).color, info[seekTimeIndex][1]);
39 cueNode = cueNode.nextElementSibling.firstElementChild.firstChild;
40 assert_equals(getComputedStyle(cueNode).color, info[seekTimeIndex][2]);
41 cueNode = cueNode.nextElementSibling;
42 assert_equals(getComputedStyle(cueNode).color, info[seekTimeIndex][3]);
43 cueNode = cueNode.parentNode;
44 assert_equals(getComputedStyle(cueNode).color, info[seekTimeIndex][4]);
17 45
18 <script> 46 if (++seekTimeIndex == info.length)
47 t.done();
48 else
49 video.currentTime = seekTimes[seekTimeIndex];
50 });
19 51
20 var cueNode; 52 video.currentTime = seekTimes[seekTimeIndex];
21 var seekedCount = 0; 53 });
22 var seekTimes = [0.1, 0.3, 0.5, 0.7, 0.9]; 54 </script>
23
24 var info = [["rgb(128, 128, 128)", "rgb(128, 128, 128)", "rgb(128, 128, 128)", "rgb(128, 128, 128)", "rgb(128, 128, 128)"],
25 ["rgb(0, 255, 0)", "rgb(128, 128, 128)", "rgb(128, 128, 128) ", "rgb(128, 128, 128)", "rgb(128, 128, 128)"],
26 ["rgb(0, 255, 0)", "rgb(0, 255, 0)", "rgb(128, 128, 128)", " rgb(128, 128, 128)", "rgb(128, 128, 128)"],
27 ["rgb(0, 255, 0)", "rgb(0, 255, 0)", "rgb(0, 255, 0)", "rgb( 128, 128, 128)", "rgb(0, 255, 0)"],
28 ["rgb(0, 255, 0)", "rgb(0, 255, 0)", "rgb(0, 255, 0)", "rgb( 0, 255, 0)", "rgb(0, 255, 0)"]];
29
30 function seeked()
31 {
32 if (testEnded)
33 return;
34
35 cueNode = textTrackDisplayElement(video, 'cue').firstElementChild;
36 testExpected("getComputedStyle(cueNode).color", info[seekedCount][0] );
37 cueNode = cueNode.nextElementSibling;
38 testExpected("getComputedStyle(cueNode).color", info[seekedCount][1] );
39 cueNode = cueNode.nextElementSibling.firstElementChild.firstChild;
40 testExpected("getComputedStyle(cueNode).color", info[seekedCount][2] );
41 cueNode = cueNode.nextElementSibling;
42 testExpected("getComputedStyle(cueNode).color", info[seekedCount][3] );
43 cueNode = cueNode.parentNode;
44 testExpected("getComputedStyle(cueNode).color", info[seekedCount][4] );
45
46 if (++seekedCount == info.length)
47 endTest();
48 else {
49 consoleWrite("");
50 run("video.currentTime = " + seekTimes[seekedCount]);
51 }
52 }
53
54 function loaded()
55 {
56 consoleWrite("Test that cues are being matched properly by :past and :future pseudo classes.");
57 findMediaElement();
58 video.src = findMediaFile('video', '../content/test');
59 video.id = "testvideo";
60 waitForEvent('seeked', seeked);
61 waitForEventOnce('canplaythrough', function() { video.currentTime = seekTimes[0]; });
62 }
63
64 </script>
65 </head>
66 <body onload="loaded()">
67 <video controls >
68 <track src="captions-webvtt/styling-timestamps.vtt" kind="captions" default>
69 </video>
70 </body>
71 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698