Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/media/track/track-active-cues.html |
| diff --git a/third_party/WebKit/LayoutTests/media/track/track-active-cues.html b/third_party/WebKit/LayoutTests/media/track/track-active-cues.html |
| index 5c751a15aaf21b8fd21617fa584611cd5e5ef3e7..f4a40ffb9053e408a1994b23d7340c444bb98958 100644 |
| --- a/third_party/WebKit/LayoutTests/media/track/track-active-cues.html |
| +++ b/third_party/WebKit/LayoutTests/media/track/track-active-cues.html |
| @@ -1,55 +1,49 @@ |
| <!doctype html> |
| -<html> |
| - <head> |
| - <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> |
| - function clearSrc() |
| - { |
| - consoleWrite("<br>** Video and track loaded, one cue should be active **"); |
| - testExpected("trackElement.track.activeCues.length", 1); |
| - |
| - consoleWrite("<br>** Clear video 'src' and force reload **"); |
| - run("video.src = ''"); |
| - consoleWrite(""); |
| - } |
| - |
| - function videoError() |
| - { |
| - consoleWrite("** 'error' event, no cues should be active **)"); |
| - testExpected("event.target", video); |
| - testExpected("video.error", null, "!="); |
| - testExpected("video.error.code", MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED); |
| - testExpected("video.networkState", HTMLMediaElement.NETWORK_NO_SOURCE); |
| - testExpected("trackElement.track.activeCues.length", 0); |
| - |
| - consoleWrite(""); |
| - endTest(); |
| - } |
| - |
| - function setup() |
| - { |
| - consoleWrite(""); |
| - |
| - findMediaElement(); |
| - trackElement = document.querySelector('track'); |
| - |
| - waitForEventsAndCall([[video, 'canplaythrough'], [trackElement, 'load'], [trackElement, 'cuechange']], clearSrc); |
| - |
| - video.src = findMediaFile("video", "../content/test"); |
| - } |
| - |
| - </script> |
| - </head> |
| - <body onload="setup()"> |
| - <video controls onerror="videoError()"> |
| - <track src="captions-webvtt/captions-fast.vtt" kind="captions" default> |
| - </video> |
| - |
| - <p>Test to ensure that a no text track cues are active after the video is unloaded.</p> |
| - |
| - </body> |
| -</html> |
| +<title>Test to ensure that no text track cues are active after the video is unloaded.</title> |
| +<script src="../media-file.js"></script> |
| +<script src="../../resources/testharness.js"></script> |
| +<script src="../../resources/testharnessreport.js"></script> |
| +<script> |
| +var eventCount = 0; |
|
philipj_slow
2016/04/11 11:50:03
Can you put this the helper inside the async_test
Srirama
2016/04/11 12:06:56
Done.
|
| +var video; |
| +var trackElement; |
| + |
| +function clearSrc() { |
|
philipj_slow
2016/04/11 11:50:02
clearSrc doesn't quite work as a name when you've
Srirama
2016/04/11 12:06:56
Done.
|
| + eventCount++; |
| + if (eventCount == 3) { |
| + assert_equals(trackElement.track.activeCues.length, 1); |
| + video.src = ''; |
| + } |
| +} |
| + |
| +async_test(function(t) { |
| + video = document.createElement('video'); |
| + video.src = findMediaFile('video', '../content/test'); |
| + trackElement = document.createElement('track'); |
| + |
| + trackElement.onload = t.step_func(function() { |
|
philipj_slow
2016/04/11 11:50:02
Just t.step_func(clearSrc) should work.
Srirama
2016/04/11 12:06:56
Done.
|
| + clearSrc(); |
| + }); |
| + |
| + trackElement.oncuechange = t.step_func(function() { |
| + clearSrc(); |
| + }); |
| + |
| + video.oncanplaythrough = t.step_func(function() { |
| + clearSrc(); |
| + }); |
| + |
| + video.onerror = t.step_func_done(function() { |
| + assert_equals(event.target, video); |
| + assert_not_equals(video.error, null); |
| + assert_equals(video.error.code, MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED); |
| + assert_equals(video.networkState, HTMLMediaElement.NETWORK_NO_SOURCE); |
| + assert_equals(trackElement.track.activeCues.length, 0); |
| + }); |
| + |
| + trackElement.src = 'captions-webvtt/captions-fast.vtt'; |
| + trackElement.kind = 'captions'; |
| + trackElement.default = true; |
| + video.appendChild(trackElement); |
| +}); |
| +</script> |