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/track/track-cue-mutable.html

Issue 1879353002: Convert track tests from video-test.js to testharness.js based (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comment Created 4 years, 8 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/track/track-cue-mutable.html
diff --git a/third_party/WebKit/LayoutTests/media/track/track-cue-mutable.html b/third_party/WebKit/LayoutTests/media/track/track-cue-mutable.html
index 4e9e3878d3013c0e30186a3ca024ec305e1737a2..ea6a12687793ca6a245e27ea5f6ef68981c20d9c 100644
--- a/third_party/WebKit/LayoutTests/media/track/track-cue-mutable.html
+++ b/third_party/WebKit/LayoutTests/media/track/track-cue-mutable.html
@@ -1,112 +1,92 @@
<!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 cues;
-
- function logSpecURL(url, description)
- {
- consoleWrite("<br><i>" + description + "</i>");
- consoleWrite("<a href=" + url + ">" + url + "<" + "/a>");
- }
-
- function trackLoaded()
- {
- track = document.getElementById('captions');
- cues = track.track.cues;
-
- consoleWrite("** Test initial values.");
- run("textCue = cues.getCueById('1')");
-
- testExpected("textCue.startTime", 0);
- testExpected("textCue.endTime", 1.0);
- testExpected("textCue.pauseOnExit", false);
- testExpected("textCue.vertical", "");
- testExpected("textCue.snapToLines", true);
- testExpected("textCue.line", "auto");
- testExpected("textCue.position", "auto");
- testExpected("textCue.size", 100);
- testExpected("textCue.align", "middle");
-
- consoleWrite("<br>** Modify cue values.");
-
- run("textCue.startTime = 1.1");
- testExpected("textCue.startTime", 1.1);
-
- consoleWrite("");
- run("textCue.endTime = 3.9");
- testExpected("textCue.endTime", 3.9);
-
- consoleWrite("");
- run("textCue.pauseOnExit = true");
- testExpected("textCue.pauseOnExit", true);
-
- logSpecURL("http://dev.w3.org/html5/webvtt/#dfn-dom-vttcue-vertical",
- "On setting, the text track cue writing direction must be set to the value given in the first cell of the row in the table above whose second cell is a case-sensitive match for the new value.");
- run("textCue.vertical = 'RL'");
- testExpected("textCue.vertical", "");
- run("textCue.vertical = 'rl'");
- testExpected("textCue.vertical", "rl");
-
- consoleWrite("");
- run("textCue.snapToLines = false");
- testExpected("textCue.snapToLines", false);
-
- logSpecURL("http://dev.w3.org/html5/webvtt/#dfn-vttcue-line",
- "On setting, the text track cue line position must be set to the new value; if the new value is the string 'auto', then it must be interpreted as the special value auto.");
- testExpected("textCue.line", "auto");
- testException("textCue.line = 'gazonk'", '"TypeError: Failed to set the \'line\' property on \'VTTCue\': \'gazonk\' is not a valid enum value."');
- testExpected("textCue.line", "auto");
- run("textCue.line = 42");
- testExpected("textCue.line", 42);
- run("textCue.line = -2");
- testExpected("textCue.line", -2);
- run("textCue.line = 102");
- testExpected("textCue.line", 102);
- run("textCue.snapToLines = true");
- run("textCue.line = -2");
- testExpected("textCue.line", -2);
- run("textCue.line = 102");
- testExpected("textCue.line", 102);
-
- logSpecURL("http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-line",
- "On setting, if the new value is negative or greater than 100, then throw an IndexSizeError exception. Otherwise, set the text track cue text position to the new value.");
- testDOMException("textCue.position = -200", "DOMException.INDEX_SIZE_ERR");
- testDOMException("textCue.position = 110", "DOMException.INDEX_SIZE_ERR");
- run("textCue.position = 11");
- testExpected("textCue.position", 11);
-
- logSpecURL("http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-size",
- "On setting, if the new value is negative or greater than 100, then throw an IndexSizeError exception. Otherwise, set the text track cue size to the new value.");
- testDOMException("textCue.size = -200", "DOMException.INDEX_SIZE_ERR");
- testDOMException("textCue.size = 110", "DOMException.INDEX_SIZE_ERR");
- run("textCue.size = 57");
- testExpected("textCue.size", 57);
-
- logSpecURL("http://dev.w3.org/html5/webvtt/#dfn-dom-vttcue-align",
- "On setting, the text track cue text alignment must be set to the value given in the first cell of the row in the table above whose second cell is a case-sensitive match for the new value.");
- run("textCue.align = 'End'");
- testExpected("textCue.align", "middle");
- run("textCue.align = 'end'");
- testExpected("textCue.align", "end");
-
- consoleWrite("");
- endTest();
- }
-
- </script>
- </head>
- <body>
- <p>Tests modifying attributes of a VTTCue</p>
- <video controls>
- <track id="captions" src="captions-webvtt/captions.vtt" kind="captions" onload="trackLoaded()" default>
- </video>
- </body>
-</html>
+<title>Tests modifying attributes of a VTTCue</title>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<video>
+ <track id="captions" src="captions-webvtt/captions.vtt" kind="captions" default>
+</video>
+<script>
+async_test(function(t) {
+ var track = document.querySelector("track");
+
+ track.onload = t.step_func_done(function() {
+ var cues = track.track.cues;
+
+ // Test initial values.
+ textCue = cues.getCueById("1");
+
+ assert_equals(textCue.startTime, 0);
+ assert_equals(textCue.endTime, 1.0);
+ assert_equals(textCue.pauseOnExit, false);
+ assert_equals(textCue.vertical, "");
+ assert_equals(textCue.snapToLines, true);
+ assert_equals(textCue.line, "auto");
+ assert_equals(textCue.position, "auto");
+ assert_equals(textCue.size, 100);
+ assert_equals(textCue.align, "middle");
+
+ // Modify cue values.
+ textCue.startTime = 1.1;
+ assert_equals(textCue.startTime, 1.1);
+
+ textCue.endTime = 3.9;
+ assert_equals(textCue.endTime, 3.9);
+
+ textCue.pauseOnExit = true;
+ assert_equals(textCue.pauseOnExit, true);
+
+ // http://dev.w3.org/html5/webvtt/#dfn-dom-vttcue-vertical
+ // On setting, the text track cue writing direction must be set to the value given in the first cell
+ // of the row in the table above whose second cell is a case-sensitive match for the new value.
+ textCue.vertical = "RL";
+ assert_equals(textCue.vertical, "");
+ textCue.vertical = "rl";
+ assert_equals(textCue.vertical, "rl");
+
+ textCue.snapToLines = false;
+ assert_equals(textCue.snapToLines, false);
+
+ // http://dev.w3.org/html5/webvtt/#dfn-vttcue-line
+ // On setting, the text track cue line position must be set to the new value;
+ // if the new value is the string "auto", then it must be interpreted as the special value auto.
+ assert_equals(textCue.line, "auto");
+ assert_throws(new TypeError, function() { textCue.line = "gazonk"; });
+ assert_equals(textCue.line, "auto");
+ textCue.line = 42;
+ assert_equals(textCue.line, 42);
+ textCue.line = -2;
+ assert_equals(textCue.line, -2);
+ textCue.line = 102;
+ assert_equals(textCue.line, 102);
+ textCue.snapToLines = true;
+ textCue.line = -2;
+ assert_equals(textCue.line, -2);
+ textCue.line = 102;
+ assert_equals(textCue.line, 102);
+
+ // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-line
+ // On setting, if the new value is negative or greater than 100, then throw an IndexSizeError exception.
+ // Otherwise, set the text track cue text position to the new value.
+ assert_throws("IndexSizeError", function() { textCue.position = -200; });
+ assert_throws("IndexSizeError", function() { textCue.position = 110; });
+ textCue.position = 11;
+ assert_equals(textCue.position, 11);
+
+ // http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-size
+ // On setting, if the new value is negative or greater than 100, then throw an IndexSizeError exception.
+ // Otherwise, set the text track cue size to the new value.
+ assert_throws("IndexSizeError", function() { textCue.size = -200 });
+ assert_throws("IndexSizeError", function() { textCue.size = 110 });
+ textCue.size = 57;
+ assert_equals(textCue.size, 57);
+
+ // http://dev.w3.org/html5/webvtt/#dfn-dom-vttcue-align
+ // On setting, the text track cue text alignment must be set to the value given in the first cell
+ // of the row in the table above whose second cell is a case-sensitive match for the new value.
+ textCue.align = "End";
+ assert_equals(textCue.align, "middle");
+ textCue.align = "end";
+ assert_equals(textCue.align, "end");
+ });
+});
+</script>

Powered by Google App Engine
This is Rietveld 408576698