Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Unified Diff: third_party/WebKit/LayoutTests/media/video-controls-track-selection-menu.html

Issue 2121613002: Convert video-controls-[captions, overlay, track]* tests to testharness.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address nit Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/media/video-controls-track-selection-menu.html
diff --git a/third_party/WebKit/LayoutTests/media/video-controls-track-selection-menu.html b/third_party/WebKit/LayoutTests/media/video-controls-track-selection-menu.html
index 450899c8d957cd01636e693c2cac31819963a9dd..0730c49d4e6bcd5d1539b83f6eae33c6df670392 100644
--- a/third_party/WebKit/LayoutTests/media/video-controls-track-selection-menu.html
+++ b/third_party/WebKit/LayoutTests/media/video-controls-track-selection-menu.html
@@ -1,49 +1,50 @@
<!DOCTYPE html>
+<title>Test that we can display a track list menu and select tracks from the list.</title>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="track/track-helpers.js"></script>
<script src="media-file.js"></script>
-<!-- TODO(srivats): Convert test to testharness.js. crbug.com/588956
- (Please avoid writing new tests using video-test.js) -->
-<script src="video-test.js"></script>
<script src="media-controls.js"></script>
+<video controls>
+ <track src="track/captions-webvtt/captions.vtt" kind="captions" label="Track1">
+ <track src="track/captions-webvtt/long-word.vtt" kind="captions" label="Track2">
+</video>
<script>
+async_test(function(t) {
+ var video = document.querySelector("video");
- function startTest()
- {
- findMediaElement();
- testClosedCaptionsButtonVisibility(true);
- consoleWrite("");
- testExpected("video.textTracks.length", 2);
- testExpected("video.textTracks[0].mode", "hidden");
- testExpected("video.textTracks[1].mode", "hidden");
+ var trackElements = document.querySelectorAll("track");
+ for (var i = 0; i < video.textTracks.length; i++)
+ trackElements[i].onload = t.step_func(trackLoaded);
- consoleWrite("");
- consoleWrite("Select track 0 and verify it is displayed");
- selectTextTrack(video, 0);
- testExpected("video.textTracks[0].mode", "showing");
- testExpected("video.textTracks[1].mode", "hidden");
- testExpected("textTrackDisplayElement(video, 'display').innerText", "Lorem");
+ enableAllTextTracks(video.textTracks);
- consoleWrite("");
- consoleWrite("Select track 1 and verify it is displayed");
- selectTextTrack(video, 1);
- testExpected("video.textTracks[0].mode", "disabled");
- testExpected("video.textTracks[1].mode", "showing");
- testExpected("textTrackDisplayElement(video, 'display').innerText", "first caption");
+ var numberOfTracksLoaded = 0;
+ function trackLoaded() {
+ numberOfTracksLoaded++;
+ if (numberOfTracksLoaded != 2)
+ return;
- consoleWrite("");
- endTest();
- }
+ video.oncanplaythrough = t.step_func_done(function() {
+ assert_true(isClosedCaptionsButtonVisible(video));
+ assert_equals(video.textTracks.length, 2);
+ assert_equals(video.textTracks[0].mode, "hidden");
+ assert_equals(video.textTracks[1].mode, "hidden");
+
+ // Select track 0 and verify it is displayed.
+ clickTextTrackAtIndex(video, 0);
+ assert_equals(video.textTracks[0].mode, "showing");
+ assert_equals(video.textTracks[1].mode, "hidden");
+ assert_equals(textTrackCueElementByIndex(video, 0).innerText, "Lorem");
+
+ // Select track 1 and verify it is displayed.
+ clickTextTrackAtIndex(video, 1);
+ assert_equals(video.textTracks[0].mode, "disabled");
+ assert_equals(video.textTracks[1].mode, "showing");
+ assert_equals(textTrackCueElementByIndex(video, 0).innerText, "first caption");
+ });
- window.onload = function()
- {
- consoleWrite("Test that we can display a track list menu and select tracks from the list");
- findMediaElement();
video.src = findMediaFile("video", "content/test");
- enableAllTextTracks();
- waitForEvent("canplaythrough", startTest);
}
-
-</script>
-<video controls>
- <track src="track/captions-webvtt/captions.vtt" kind="captions" label="Track1">
- <track src="track/captions-webvtt/long-word.vtt" kind="captions" label="Track2">
-</video>
+});
+</script>

Powered by Google App Engine
This is Rietveld 408576698