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

Unified Diff: third_party/WebKit/LayoutTests/media/track/track-mode.html

Issue 1942633002: Convert track-mode* tests to testharness.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 4 years, 7 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/media/track/track-mode-disabled-crash.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/media/track/track-mode.html
diff --git a/third_party/WebKit/LayoutTests/media/track/track-mode.html b/third_party/WebKit/LayoutTests/media/track/track-mode.html
index e9da0256fa690a0503af2fc77a50c9f8592e0a5a..bb4562f1b52c8cb7ace21b3b65cd3b8e102bb25a 100644
--- a/third_party/WebKit/LayoutTests/media/track/track-mode.html
+++ b/third_party/WebKit/LayoutTests/media/track/track-mode.html
@@ -1,93 +1,61 @@
<!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>
-
- var textTrack;
- var cueCount;
-
- function setMode(value)
- {
- run("textTrack.mode = '" + value + "'");
- testExpected("textTrack.mode", value);
- testExpected("video.textTracks[0].mode", value);
- if (value == "disabled")
- testExpected("textTrack.cues", null);
- else
- testExpected("textTrack.cues.length", textTrack.cues.length);
- consoleWrite("");
- }
-
- function start()
- {
- findMediaElement();
- cueCount = 0;
- consoleWrite("");
-
- textTrack = document.getElementById('track_1').track;
-
- consoleWrite("<b>++ Test default attribute value</b>");
- testExpected("textTrack.mode", "showing");
- testExpected("video.textTracks[0].mode", "showing");
- consoleWrite("");
-
- consoleWrite("<b>*** Set to bogus value, should return default</b>");
- var value = "bogus";
- run("textTrack.mode = '" + value + "'");
- testExpected("textTrack.mode", "showing");
- testExpected("video.textTracks[0].mode", "showing");
- consoleWrite("");
-
- consoleWrite("<b>*** Set to numeric value (no longer supported), should return default</b>");
- run("textTrack.mode = 2");
- testExpected("textTrack.mode", "showing");
- testExpected("video.textTracks[0].mode", "showing");
- consoleWrite("");
-
- consoleWrite("<b>*** Set to known values</b>");
- consoleWrite("<b>++ 'disabled'</b>");
- setMode("disabled");
-
- video.src = findMediaFile("video", "../content/test");
- video.play();
- // Wait for end of first cue (no events should fire while track is disabled).
- setTimeout(testHiddenAndShowing, 400);
- consoleWrite("++ 0 events expected while mode = disabled");
- consoleWrite("");
- }
-
- function testHiddenAndShowing()
- {
- consoleWrite("<b>++ 'hidden'</b>");
- setMode("hidden");
-
- consoleWrite("<b>++ 'showing'</b>");
- setMode("showing");
-
- consoleWrite("++ at least " + textTrack.cues.length + " events expected while mode = showing");
- }
-
- waitForEvent('cuechange',
- function (event)
- {
- cueCount++;
- if (cueCount == textTrack.cues.length)
- endTest();
-
- }
- );
-
- </script>
- </head>
- <body>
- <p>Tests that the TextTrack mode attribute is appropriately set.</p>
- <video>
- <track id=track_1 src="captions-webvtt/captions-fast.vtt" onload="start()" default>
- </video>
- </body>
-</html>
+<title>Tests that the TextTrack mode attribute is appropriately set.</title>
+<script src="../media-file.js"></script>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<video>
+ <track src="captions-webvtt/captions-fast.vtt" default>
+</video>
+<script>
+async_test(function(t) {
+ var video = document.querySelector("video");
+ var track = document.querySelector("track");
+ track.onload = t.step_func(trackLoaded);
+
+ var cueCount = 0;
+ var textTrack;
+ function trackLoaded() {
+ textTrack = track.track;
+ // Test default attribute value.
+ assert_equals(textTrack.mode, "showing");
+ assert_equals(video.textTracks[0].mode, "showing");
+ // Set to bogus value, should return default.
+ var value = "bogus";
+ textTrack.mode = value;
+ assert_equals(textTrack.mode, "showing");
+ assert_equals(video.textTracks[0].mode, "showing");
+
+ // Set to numeric value (no longer supported), should return default.
+ textTrack.mode = 2;
+ assert_equals(textTrack.mode, "showing");
+ assert_equals(video.textTracks[0].mode, "showing");
+
+ // Set to known values.
+ setModeAndCheck("disabled");
+
+ video.src = findMediaFile("video", "../content/test");
+ video.play();
+ // Wait for end of first cue (no events should fire while track is disabled).
+ setTimeout(testHiddenAndShowing, 400);
+ }
+
+ track.oncuechange = t.step_func(function(event) {
+ cueCount++;
+ if (cueCount == textTrack.cues.length)
+ t.done();
+ });
+
+ function setModeAndCheck(value) {
+ textTrack.mode = value;
+ assert_equals(textTrack.mode, value);
+ assert_equals(video.textTracks[0].mode, value);
+ if (value == "disabled")
+ assert_equals(textTrack.cues, null);
+ }
+
+ function testHiddenAndShowing() {
+ setModeAndCheck("hidden");
+ setModeAndCheck("showing");
+ }
+});
+</script>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/media/track/track-mode-disabled-crash.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698