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

Unified Diff: third_party/WebKit/LayoutTests/media/track/track-cue-mutable-text.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-text.html
diff --git a/third_party/WebKit/LayoutTests/media/track/track-cue-mutable-text.html b/third_party/WebKit/LayoutTests/media/track/track-cue-mutable-text.html
index d7088c8d5555d35ccbeac0ab255bf8e814bc37a5..054968c3ea45dfab898c244fa9b0bd0a768816ee 100644
--- a/third_party/WebKit/LayoutTests/media/track/track-cue-mutable-text.html
+++ b/third_party/WebKit/LayoutTests/media/track/track-cue-mutable-text.html
@@ -1,87 +1,73 @@
<!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 src=../media-controls.js></script>
-
- <script>
-
- var testTrack;
- var fragment;
-
- function testMutability()
- {
- consoleWrite("<br>** Test initial cue info");
-
- testExpected("testTrack.track.activeCues.length", 0);
- testExpected("textTrackDisplayElement(video, 'display').innerText", "");
-
- testExpected("testTrack.track.cues[0].startTime", 1.0);
- testExpected("testTrack.track.cues[1].startTime", 3.0);
-
- testExpected("testTrack.track.cues[0].text", "Lorem ipsum dolor sit amet,");
- fragment = document.createDocumentFragment();
- fragment.appendChild(document.createTextNode("Lorem ipsum dolor sit amet,"));
- testExpected("fragment.isEqualNode(testTrack.track.cues[0].getCueAsHTML())", true);
-
- consoleWrite("<br>** Change the start time of cue #1, it should become visible.");
- run("testTrack.track.cues[0].startTime = 0");
- testExpected("testTrack.track.cues[0].startTime", 0);
- testExpected("textTrackDisplayElement(video, 'display').innerText", "Lorem ipsum dolor sit amet,");
-
- consoleWrite("<br>** Change the cue text, getCueAsHTML() should return a new, correct fragment.");
- run("testTrack.track.cues[0].text = 'Lorem <b>ipsum</b> <u>dolor</u> <i.sit>sit</i> amet,'");
- testExpected("testTrack.track.cues[0].text", "Lorem <b>ipsum</b> <u>dolor</u> <i.sit>sit</i> amet,");
-
- fragment = document.createDocumentFragment();
- fragment.appendChild(document.createTextNode("Lorem "));
-
- var bold = document.createElement("b");
- bold.appendChild(document.createTextNode("ipsum"));
- fragment.appendChild(bold);
-
- fragment.appendChild(document.createTextNode(" "));
-
- var underline = document.createElement("u");
- underline.appendChild(document.createTextNode("dolor"));
- fragment.appendChild(underline);
-
- fragment.appendChild(document.createTextNode(" "));
-
- var italics = document.createElement("i");
- italics.className = "sit";
- italics.appendChild(document.createTextNode("sit"));
- fragment.appendChild(italics);
-
- fragment.appendChild(document.createTextNode(" amet,"));
-
- testExpected("fragment.isEqualNode(testTrack.track.cues[0].getCueAsHTML())", true);
-
- consoleWrite("");
- endTest();
- }
-
- function loaded()
- {
- findMediaElement();
- testTrack = document.querySelector('track');
-
- waitForEventsAndCall([[video, 'canplaythrough'], [testTrack, 'load']], testMutability);
-
- video.src = findMediaFile('video', '../content/counting');
- }
-
- </script>
- </head>
- <body onload="loaded()">
- <video controls >
- <track src="captions-webvtt/captions-gaps.vtt" kind="captions" default >
- </video>
- <p>Test that cue text is mutable.</p>
- </body>
-</html>
+<title>Test that cue text is mutable.</title>
+<script src="../media-file.js"></script>
+<script src="../media-controls.js"></script>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<video>
+ <track src="captions-webvtt/captions-gaps.vtt" kind="captions" default >
+</video>
+<script>
+async_test(function(t) {
+ var video = document.querySelector("video");
+ var testTrack = document.querySelector("track");
+
+ video.oncanplaythrough = t.step_func(testMutability);
+ testTrack.onload = t.step_func(testMutability);
+
+ var eventCount = 0;
+ function testMutability() {
+ eventCount++;
+ if (eventCount != 2)
+ return;
+
+ // Test initial cue info.
+ assert_equals(testTrack.track.activeCues.length, 0);
+
+ assert_equals(testTrack.track.cues[0].startTime, 1.0);
+ assert_equals(testTrack.track.cues[1].startTime, 3.0);
+
+ assert_equals(testTrack.track.cues[0].text, "Lorem ipsum dolor sit amet,");
+ var fragment = document.createDocumentFragment();
+ fragment.appendChild(document.createTextNode("Lorem ipsum dolor sit amet,"));
+ assert_true(fragment.isEqualNode(testTrack.track.cues[0].getCueAsHTML()));
+
+ // Change the start time of cue #1, it should become visible.
+ testTrack.track.cues[0].startTime = 0;
+ assert_equals(testTrack.track.cues[0].startTime, 0);
+ assert_equals(textTrackDisplayElement(video, "display").innerText, "Lorem ipsum dolor sit amet,");
+
+ // Change the cue text, getCueAsHTML() should return a new, correct fragment.
+ testTrack.track.cues[0].text = "Lorem <b>ipsum</b> <u>dolor</u> <i.sit>sit</i> amet,";
+ assert_equals(testTrack.track.cues[0].text, "Lorem <b>ipsum</b> <u>dolor</u> <i.sit>sit</i> amet,");
+
+ fragment = document.createDocumentFragment();
+ fragment.appendChild(document.createTextNode("Lorem "));
+
+ var bold = document.createElement("b");
+ bold.appendChild(document.createTextNode("ipsum"));
+ fragment.appendChild(bold);
+
+ fragment.appendChild(document.createTextNode(" "));
+
+ var underline = document.createElement("u");
+ underline.appendChild(document.createTextNode("dolor"));
+ fragment.appendChild(underline);
+
+ fragment.appendChild(document.createTextNode(" "));
+
+ var italics = document.createElement("i");
+ italics.className = "sit";
+ italics.appendChild(document.createTextNode("sit"));
+ fragment.appendChild(italics);
+
+ fragment.appendChild(document.createTextNode(" amet,"));
+
+ assert_true(fragment.isEqualNode(testTrack.track.cues[0].getCueAsHTML()));
+
+ t.done();
+ }
+
+ video.src = findMediaFile("video", "../content/counting");
+});
+</script>

Powered by Google App Engine
This is Rietveld 408576698