Index: third_party/WebKit/LayoutTests/media/track/track-cues-missed.html |
diff --git a/third_party/WebKit/LayoutTests/media/track/track-cues-missed.html b/third_party/WebKit/LayoutTests/media/track/track-cues-missed.html |
index 9b05ac374a9fed8ad6d1db472642125f925d44e1..40f2f756001f62b1a74194efbdb14fee1735ac79 100644 |
--- a/third_party/WebKit/LayoutTests/media/track/track-cues-missed.html |
+++ b/third_party/WebKit/LayoutTests/media/track/track-cues-missed.html |
@@ -1,80 +1,59 @@ |
<!DOCTYPE html> |
-<html> |
- <head> |
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
- |
- <script src=../media-file.js></script> |
- <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956 |
- (Please avoid writing new tests using video-test.js) --> |
- <script src=../video-test.js></script> |
- <script> |
- var videoCanPlayThrough = false; |
- var trackLoaded = false; |
- |
- var currentCue; |
- var cueCount; |
- var testTrack; |
- |
- function runTests() |
- { |
- if (!trackLoaded || !videoCanPlayThrough) |
- return; |
- |
- testTrack = document.getElementById("testTrack"); |
- testExpected("testTrack.track.cues.length", 7); |
- |
- for (cueCount = 2; cueCount < testTrack.track.cues.length; cueCount++) { |
- var cue = testTrack.track.cues[cueCount]; |
- |
- cue.addEventListener('enter', cueEnteredOrExited); |
- cue.addEventListener('exit', cueEnteredOrExited); |
- } |
- |
- cueCount = 3; |
- run("video.play()"); |
- } |
- |
- function cueEnteredOrExited() |
- { |
- consoleWrite(""); |
- consoleWrite("EVENT(" + event.type + ")"); |
- |
- currentCue = event.target; |
- testExpected("testTrack.track.cues.getCueById(cueCount).text", currentCue.text, "=="); |
- testExpected("currentCue.id", cueCount); |
- |
- if (event.type == 'exit') { |
- cueCount++; |
- } |
- } |
- |
- waitForEvent('ended', endTest); |
- |
- waitForEventOnce('canplaythrough', function() { |
- video.currentTime = 5.00; |
- videoCanPlayThrough = true; |
- |
- runTests(); |
- }); |
- |
- function loaded() |
- { |
- trackLoaded = true; |
- |
- runTests(); |
- }; |
- |
- function bodyLoaded() |
- { |
- findMediaElement(); |
- video.src = findMediaFile("video", "../content/test"); |
- } |
- </script> |
- </head> |
- <body onload="bodyLoaded()"> |
- <p>Tests that events are triggered for missed (skipped) cues during normal playback.</p> |
- <video controls> |
- <track id="testTrack" src="captions-webvtt/missed-cues.vtt" onload="loaded()" default> |
- </video> |
- </body> |
-</html> |
+<title>Tests that events are triggered for missed (skipped) cues during normal playback.</title> |
+<script src="../media-file.js"></script> |
+<script src="../../resources/testharness.js"></script> |
+<script src="../../resources/testharnessreport.js"></script> |
+<video> |
+ <track src="captions-webvtt/missed-cues.vtt" default> |
+</video> |
+<script> |
+async_test(function(t) { |
+ var video = document.querySelector("video"); |
+ var testTrack = document.querySelector("track"); |
+ |
+ video.src = findMediaFile("video", "../content/test"); |
+ |
+ video.onended = t.step_func_done(); |
+ |
+ video.oncanplaythrough = t.step_func(function() { |
+ video.oncanplaythrough = null; |
+ video.currentTime = 5.00; |
+ runTests(); |
+ }); |
+ |
+ testTrack.onload = t.step_func(runTests); |
+ |
+ var cueCount; |
+ var eventCount = 0; |
+ function runTests() { |
+ eventCount++; |
+ |
+ if(eventCount != 2) |
+ return; |
+ |
+ assert_equals(testTrack.track.cues.length, 7); |
+ |
+ for (cueCount = 2; cueCount < testTrack.track.cues.length; cueCount++) { |
+ var cue = testTrack.track.cues[cueCount]; |
+ |
+ cue.onenter = t.step_func(cueEnteredOrExited); |
+ cue.onexit = t.step_func(cueEnteredOrExited); |
+ } |
+ |
+ // Test events for missed cues, which are cues with ids |
+ // from 3 to 7 in the file captions-webvtt/missed-cues.vtt. |
+ cueCount = 3; |
+ video.play(); |
+ } |
+ |
+ function cueEnteredOrExited() { |
+ var currentCue = event.target; |
+ assert_equals(testTrack.track.cues.getCueById(cueCount).text, currentCue.text); |
+ assert_equals(currentCue.id, cueCount.toString()); |
Srirama
2016/04/26 06:49:27
toString() for 2nd argument is fine? or is it bett
mlamouri (slow - plz ping)
2016/04/26 14:19:32
Sounds fine. It's pretty much the same.
Alternati
|
+ |
+ if (event.type == "exit") |
+ cueCount++; |
+ } |
+ |
+}); |
+</script> |