Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/media/track/track-cues-cuechange.html |
| diff --git a/third_party/WebKit/LayoutTests/media/track/track-cues-cuechange.html b/third_party/WebKit/LayoutTests/media/track/track-cues-cuechange.html |
| index e63cdd00a9a5190acc6737c99c9f9749f350db99..5ac0d0324538cd9b81cba5204446e972178133e0 100644 |
| --- a/third_party/WebKit/LayoutTests/media/track/track-cues-cuechange.html |
| +++ b/third_party/WebKit/LayoutTests/media/track/track-cues-cuechange.html |
| @@ -1,90 +1,43 @@ |
| <!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 cueChangeCount = 0; |
| - var currentCue; |
| - var testTrack; |
| - |
| - var trackLoaded = false; |
| - var videoCanPlayThrough = false; |
| - |
| - function attemptTests() |
| - { |
| - if (!trackLoaded || !videoCanPlayThrough) |
| - return; |
| - |
| - testTrack = document.getElementById("testTrack"); |
| - testExpected("testTrack.track.cues.length", 3); |
| - testTrack.addEventListener('cuechange', cueChangedFromTrackElement); |
| - testTrack.track.addEventListener('cuechange', cueChangedFromTextTrack); |
| - run("video.play()"); |
| - consoleWrite(""); |
| - } |
| - |
| - function cueChangedFromTextTrack() |
| - { |
| - consoleWrite("EVENT(cuechange) from TextTrack"); |
| - } |
| - |
| - function cueChangedFromTrackElement() |
| - { |
| - consoleWrite("EVENT(cuechange) from <track>"); |
| - |
| - currentCueIndex = Math.floor(cueChangeCount / 2); |
| - currentCue = event.target.track.cues[currentCueIndex]; |
| - checkCue(); |
| - |
| - ++cueChangeCount; |
| - if (cueChangeCount == testTrack.track.cues.length * 2) |
| - endTest(); |
| - } |
| - |
| - function checkCue() |
| - { |
| - if (cueChangeCount % 2 == 0) { |
| - consoleWrite("Cue entered"); |
| - testExpected(currentCue, testTrack.track.activeCues[0]); |
| - testExpected("currentCue.id", currentCueIndex + 1); |
| - } else |
| - consoleWrite("Cue exited"); |
| - consoleWrite(""); |
| - } |
| - |
| - waitForEvent('canplaythrough', |
| - function () |
| - { |
| - videoCanPlayThrough = true; |
| - attemptTests(); |
| - } |
| - ); |
| - |
| - function loaded() |
| - { |
| - trackLoaded = true; |
| - attemptTests(); |
| +<title>Tests that TextTrack's cues are indexed and updated in order during video playback. Test uses the cuechange event.</title> |
| +<script src="../media-file.js"></script> |
| +<script src="../../resources/testharness.js"></script> |
| +<script src="../../resources/testharnessreport.js"></script> |
| +<video> |
| + <track src="captions-webvtt/cues-chrono-order.vtt" kind="captions" default> |
| +</video> |
| +<script> |
| +async_test(function(t) { |
| + var video = document.querySelector("video"); |
| + var testTrack = document.querySelector("track"); |
| + |
| + video.src = findMediaFile("video", "../content/test"); |
| + video.oncanplaythrough = t.step_func(attemptTests); |
| + |
| + function attemptTests() { |
| + assert_equals(testTrack.track.cues.length, 3); |
| + testTrack.oncuechange = t.step_func(cueChangedFromTrackElement); |
| + video.play(); |
| + } |
| + |
| + var currentCueIndex; |
| + var cueChangeCount = 0; |
| + function cueChangedFromTrackElement() { |
| + currentCueIndex = Math.floor(cueChangeCount / 2); |
| + currentCue = event.target.track.cues[currentCueIndex]; |
| + checkCue(); |
| + |
| + ++cueChangeCount; |
| + if (cueChangeCount == testTrack.track.cues.length * 2) |
| + t.done(); |
| + } |
| + |
| + function checkCue() { |
| + if (cueChangeCount % 2 == 0) { |
| + // Cue entered. |
|
mlamouri (slow - plz ping)
2016/04/22 10:27:56
Could the check be done outside this method?
Srirama
2016/04/22 12:13:31
For each cue, this function is called on "enter" a
mlamouri (slow - plz ping)
2016/04/25 15:37:47
I meant adding the check in `cueChangedFromTrackEl
Srirama
2016/04/26 06:49:27
Sorry, didn't read the comment properly.
Inlined i
|
| + assert_equals(currentCue, testTrack.track.activeCues[0]); |
| + assert_equals(currentCue.id, (currentCueIndex + 1).toString()); |
| } |
| - |
| - function start() |
| - { |
| - findMediaElement(); |
| - video.src = findMediaFile("video", "../content/test"); |
| - } |
| - |
| - </script> |
| - </head> |
| - <body onload="start()"> |
| - <p>Tests that TextTrack's cues are indexed and updated in order during video playback. Test uses the cuechange event.</p> |
| - <video controls> |
| - <track id="testTrack" src="captions-webvtt/cues-chrono-order.vtt" kind="captions" onload="loaded()" default> |
| - </video> |
| - </body> |
| -</html> |
| + } |
| +}); |
| +</script> |