Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/media/video-controls-captions-on-off.html |
| diff --git a/third_party/WebKit/LayoutTests/media/video-controls-captions-on-off.html b/third_party/WebKit/LayoutTests/media/video-controls-captions-on-off.html |
| index 062f74d564fe9590acb2e3c2bfc528f7371202bd..d06b11aada2043b92b556ef3561d5145eb05b711 100644 |
| --- a/third_party/WebKit/LayoutTests/media/video-controls-captions-on-off.html |
| +++ b/third_party/WebKit/LayoutTests/media/video-controls-captions-on-off.html |
| @@ -1,87 +1,53 @@ |
| <!DOCTYPE html> |
| -<html> |
| -<head> |
| - <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| - <title>Test closed caption track selection on and off.</title> |
| - <script src=media-file.js></script> |
| - <script src=media-controls.js></script> |
| - <!-- TODO(foolip): 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 text = ["First", "Second", "Third"]; |
| - var displayElement; |
| - |
| - function addTextTrack() |
| - { |
| - var track = video.addTextTrack('captions'); |
| - |
| - for (var i = 0; i < 3; i++) { |
| - var cue = new VTTCue(0, 120, text[i]); |
| - track.addCue(cue); |
| - } |
| - } |
| - |
| - function checkCaptionsDisplay() |
| - { |
| - for (var i = 0; i < 3; i++) { |
| - try { |
| - displayElement = textTrackDisplayElement(video, "display", i); |
| - testExpected("displayElement.innerText", text[i]); |
| - } catch (e) { |
| - consoleWrite(e); |
| - } |
| - } |
| +<title>Tests that tracks can be turned on and off through the track selection menu.</title> |
| +<script src="../resources/testharness.js"></script> |
| +<script src="../resources/testharnessreport.js"></script> |
| +<script src="media-file.js"></script> |
| +<script src="media-controls.js"></script> |
| +<video controls></video> |
| +<script> |
| +async_test(function(t) { |
| + var text = ["First", "Second", "Third"]; |
| + var video = document.querySelector("video"); |
| + |
| + video.oncanplaythrough = t.step_func_done(function() { |
| + var track = video.addTextTrack("captions"); |
| + |
| + for (var i = 0; i < 3; i++) { |
| + var cue = new VTTCue(0, 120, text[i]); |
| + track.addCue(cue); |
| } |
| - |
| - function startTest() |
| - { |
| - if (!window.eventSender) { |
| - consoleWrite("No eventSender found."); |
| - failTest(); |
| + assert_true(isClosedCaptionsButtonVisible(video)); |
| + |
| + // The captions track should be listed in textTracks, but not yet loaded. |
| + assert_equals(video.textTracks.length, 1); |
| + assert_equals(video.textTracks[0].mode, "hidden"); |
| + checkCaptionsDisplay(false); |
| + |
| + // Captions track should become visible after the track is selected. |
| + selectTextTrackAtIndex(video, 0); |
| + checkCaptionsDisplay(true); |
| + |
| + // Captions should not be visible after they're turned off through the menu. |
| + turnClosedCaptionsOff(video); |
| + checkCaptionsDisplay(false); |
| + |
| + // Captions track should become visible after the track is selected again. |
| + selectTextTrackAtIndex(video, 0); |
| + checkCaptionsDisplay(true); |
| + }); |
| + |
| + function checkCaptionsDisplay(captionsVisible) { |
|
fs
2016/07/04 08:46:55
Could probably also be split into two functions, e
Srirama
2016/07/04 13:00:23
Done.
|
| + for (var i = 0; i < 3; i++) { |
| + if (captionsVisible) { |
| + var cue = textTrackDisplayElement(video, "display", i); |
| + assert_equals(cue.innerText, text[i]); |
| + } else { |
| + assert_throws(null, function() { textTrackDisplayElement(video, "display", i); }); |
| } |
| - |
| - addTextTrack(); |
| - |
| - findMediaElement(); |
| - testClosedCaptionsButtonVisibility(true); |
| - |
| - consoleWrite(""); |
| - consoleWrite("** The captions track should be listed in textTracks, but not yet loaded. **"); |
| - testExpected("video.textTracks.length", 1); |
| - testExpected("video.textTracks[0].mode", "hidden"); |
| - checkCaptionsDisplay(); |
| - |
| - consoleWrite(""); |
| - consoleWrite("** Captions track should become visible after the track is selected **"); |
| - selectTextTrack(video, 0); |
| - checkCaptionsDisplay(); |
| - |
| - consoleWrite(""); |
| - consoleWrite("** Captions should not be visible after they're turned off through the menu **"); |
| - turnClosedCaptionsOff(video); |
| - checkCaptionsDisplay(); |
| - |
| - consoleWrite(""); |
| - consoleWrite("** Captions track should become visible after the track is selected again **"); |
| - selectTextTrack(video, 0); |
| - checkCaptionsDisplay(); |
| - |
| - consoleWrite(""); |
| - endTest(); |
| } |
| + } |
| - function loaded() |
| - { |
| - findMediaElement(); |
| - waitForEvent('canplaythrough', startTest); |
| - |
| - video.src = findMediaFile('video', 'content/counting'); |
| - } |
| - </script> |
| -</head> |
| -<body onload="loaded()"> |
| - <p>Tests that tracks can be turned on and off through the track selection menu</p> |
| - <video controls></video> |
| -</body> |
| -</html> |
| + video.src = findMediaFile("video", "content/counting"); |
| +}); |
| +</script> |