Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 controls></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() { |
|
philipj_slow
2016/04/12 08:39:28
Assert something about currentTime here too.
Srirama
2016/04/12 11:20:05
Done.
| |
| 13 video::cue {color: green} | 34 var cueNode = textTrackDisplayElement(video, "cue").firstElementChild; |
| 14 video::cue(:past) {color: lime} | 35 assert_equals(getComputedStyle(cueNode).color, info[seekTimeIndex][0]); |
| 15 video::cue(:future) {color: gray} | 36 cueNode = cueNode.nextElementSibling; |
| 16 </style> | 37 assert_equals(getComputedStyle(cueNode).color, info[seekTimeIndex][1]); |
| 38 cueNode = cueNode.nextElementSibling.firstElementChild.firstChild; | |
| 39 assert_equals(getComputedStyle(cueNode).color, info[seekTimeIndex][2]); | |
| 40 cueNode = cueNode.nextElementSibling; | |
| 41 assert_equals(getComputedStyle(cueNode).color, info[seekTimeIndex][3]); | |
| 42 cueNode = cueNode.parentNode; | |
| 43 assert_equals(getComputedStyle(cueNode).color, info[seekTimeIndex][4]); | |
| 17 | 44 |
| 18 <script> | 45 if (++seekTimeIndex == info.length) |
| 46 t.done(); | |
| 47 else | |
| 48 video.currentTime = seekTimes[seekTimeIndex]; | |
| 49 }); | |
| 19 | 50 |
| 20 var cueNode; | 51 video.currentTime = seekTimes[seekTimeIndex]; |
| 21 var seekedCount = 0; | 52 }); |
| 22 var seekTimes = [0.1, 0.3, 0.5, 0.7, 0.9]; | 53 </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> | |
| OLD | NEW |