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-cues-sorted-before-dispatch.html

Issue 2074913006: Convert track-cues* and track-delete* tests to testharness.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address nit Created 4 years, 6 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-cues-sorted-before-dispatch-expected.txt » ('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-cues-sorted-before-dispatch.html
diff --git a/third_party/WebKit/LayoutTests/media/track/track-cues-sorted-before-dispatch.html b/third_party/WebKit/LayoutTests/media/track/track-cues-sorted-before-dispatch.html
index 8c6df18215931d22b0104527c937e01520327174..e602ee107762f6eddf9606a6332533530b3e5729 100644
--- a/third_party/WebKit/LayoutTests/media/track/track-cues-sorted-before-dispatch.html
+++ b/third_party/WebKit/LayoutTests/media/track/track-cues-sorted-before-dispatch.html
@@ -1,91 +1,48 @@
<!DOCTYPE html>
-<html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-
- <script src=../media-file.js></script>
- <!-- TODO(foolip): 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 videoCanPlayThrough = false;
- var trackLoaded = false;
-
- var currentCue;
- var testTrack;
-
- var dispatchedEvents = [];
-
- function runTests()
- {
- if (!trackLoaded || !videoCanPlayThrough)
- return;
-
- testTrack = document.getElementById("testTrack");
- testExpected("testTrack.track.cues.length", 8);
-
- for (var i = 0; i < testTrack.track.cues.length; ++i) {
- testTrack.track.cues[i].addEventListener('enter', cueEnteredOrExited);
- testTrack.track.cues[i].addEventListener('exit', cueEnteredOrExited);
- }
-
- run("video.play()");
- }
-
- function cueEnteredOrExited(event)
- {
- currentCue = event.target;
-
- var eventObj = {};
-
- eventObj.time = currentCue.startTime;
- if (event.type == 'exit')
- eventObj.time = currentCue.endTime;
-
- eventObj.type = event.type;
- eventObj.cue = currentCue;
-
- dispatchedEvents.push(eventObj);
- }
-
- function loaded()
- {
- trackLoaded = true;
- runTests();
- }
-
- function bodyLoaded()
- {
- findMediaElement();
- video.src = findMediaFile("video", "../content/test");
- }
-
- function logEndTest()
- {
- for (var i = 0; i < dispatchedEvents.length; ++i) {
- consoleWrite("Cue event: " + dispatchedEvents[i].type +
- " id: " + dispatchedEvents[i].cue.id +
- " time: " + dispatchedEvents[i].time);
- }
-
- endTest();
- }
-
- waitForEvent('ended', logEndTest);
-
- waitForEventOnce('canplaythrough', function() {
- video.currentTime = 5.00;
- videoCanPlayThrough = true;
-
- runTests();
- });
-
- </script>
- </head>
- <body onload="bodyLoaded()">
- <p>Tests that all events events are triggered in chronological order.</p>
- <video controls>
- <track id="testTrack" src="captions-webvtt/sorted-dispatch.vtt" onload="loaded()" default>
- </video>
- </body>
-</html>
+<title>Tests that all events are triggered in chronological order.</title>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script src="../media-file.js"></script>
+<video>
+ <track src="captions-webvtt/sorted-dispatch.vtt" default>
+</video>
+<script>
+async_test(function(t) {
+ var video = document.querySelector("video");
+ video.src = findMediaFile("video", "../content/test");
+ var track = document.querySelector("track");
+
+ track.onload = t.step_func(function() {
+ var cues = track.track.cues;
+ assert_equals(cues.length, 8);
+
+ for (var i = 0; i < cues.length; ++i) {
+ cues[i].onenter = t.step_func(cueEnteredOrExited);
+ cues[i].onexit = t.step_func(cueEnteredOrExited);
+ }
+
+ video.play();
+ });
+
+ var cueTimings = [];
+ function cueEnteredOrExited(event) {
+ var currentCue = event.target;
+
+ if (event.type == "exit")
+ cueTimings.push(currentCue.endTime);
+ else
+ cueTimings.push(currentCue.startTime);
+ }
+
+ video.onended = t.step_func_done(function() {
+ assert_equals(cueTimings.length, 14);
+ var time = 0;
+ for (var i = 0; i < cueTimings.length; ++i) {
+ assert_less_than_equal(time, cueTimings[i], "cueTimings[" + i + "]");
+ time = cueTimings[i];
+ }
+ });
+
+ video.currentTime = 5;
+});
+</script>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/media/track/track-cues-sorted-before-dispatch-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698