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

Unified Diff: third_party/WebKit/LayoutTests/media/track/track-webvtt-tc001-utf8.html

Issue 1956213002: Convert track-webvtt-tc[000-002] tests to testharness.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
Index: third_party/WebKit/LayoutTests/media/track/track-webvtt-tc001-utf8.html
diff --git a/third_party/WebKit/LayoutTests/media/track/track-webvtt-tc001-utf8.html b/third_party/WebKit/LayoutTests/media/track/track-webvtt-tc001-utf8.html
index 4794cad941aca5aa04bdd39daa9d9ab23de1b20c..b11786be2999dfa6cbf62bf30fd9213b683b3a33 100644
--- a/third_party/WebKit/LayoutTests/media/track/track-webvtt-tc001-utf8.html
+++ b/third_party/WebKit/LayoutTests/media/track/track-webvtt-tc001-utf8.html
@@ -1,77 +1,54 @@
<!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>
-
- numberOfTrackTests = 2;
-
- function trackLoaded()
- {
- numberOfTracksLoaded++;
- if (numberOfTracksLoaded == numberOfTrackTests) {
- testTrack0();
- testTrack1();
- }
- }
-
- function testTrack0()
- {
- findMediaElement();
- var expected =
- {
- length : 2,
- tests:
- [
- {
- property : "id",
- values : [1, 2],
- },
- {
- property : "startTime",
- values : [0.0, 31.0],
- },
- {
- property : "endTime",
- values : [30.5, 1200.5],
- },
- {
- property : "text",
- values : ["景気判断", "電力不足"],
- },
- ],
- };
- testCues(0, expected);
-
- allTestsEnded();
- }
-
- function testTrack1()
- {
- findMediaElement();
- var expected =
- {
- length : 2,
- tests:
- [],
- };
- testCues(1, expected);
-
- allTestsEnded();
- }
-
- </script>
- </head>
- <body onload="enableAllTextTracks()">
- <p>Tests that UTF-8 encoded characters are recognized properly and that different encodings (iconv) are not recognized as a WebVTT file (we do allow it, it just looks ugly).</p>
- <video>
- <track src="captions-webvtt/tc001-utf8.vtt" onload="trackLoaded()">
- <track src="captions-webvtt/tc001-iso2022jp3.vtt" onload="trackLoaded()">
- </video>
- </body>
-</html>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>Tests that UTF-8 encoded characters are recognized properly and that different encodings (iconv) are not recognized as a WebVTT file (we do allow it, it just looks ugly).</title>
+<video>
+ <track src="captions-webvtt/tc001-utf8.vtt">
+ <track src="captions-webvtt/tc001-iso2022jp3.vtt">
+</video>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script>
+async_test(function(t) {
+ var video = document.querySelector("video");
+
+ var trackElements = document.querySelectorAll("track");
+ for (var i = 0; i < video.textTracks.length; i++) {
+ var track = video.textTracks[i];
+ if (track.mode == "disabled") {
+ track.mode = "hidden";
+ trackElements[i].onload = t.step_func(trackLoaded);
+ }
+ }
+
+ var numberOfTracksLoaded = 0;
+ function trackLoaded() {
+ numberOfTracksLoaded++;
+ if (numberOfTracksLoaded != 2)
+ return;
+
+ testTrack0();
+ testTrack1();
+ t.done();
+ }
+
+ function testTrack0() {
+ var idValues = ["1", "2"];
+ var startTimeValues = [0, 31];
+ var endTimeValues = [30.5, 1200.5];
+ var textValues = ["景気判断", "電力不足"];
+
+ var cues = video.textTracks[0].cues;
+ assert_equals(cues.length, 2);
+ for (var i = 0; i < cues.length; i++) {
+ assert_equals(cues[i].id, idValues[i]);
+ assert_equals(cues[i].startTime, startTimeValues[i]);
+ assert_equals(cues[i].endTime, endTimeValues[i]);
+ assert_equals(cues[i].text, textValues[i]);
+ }
+ }
+
+ function testTrack1() {
+ assert_equals(video.textTracks[1].cues.length, 2);
+ }
+});
+</script>

Powered by Google App Engine
This is Rietveld 408576698