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

Unified Diff: third_party/WebKit/LayoutTests/media/track/track-cue-gc-wrapper.html

Issue 2078443003: Convert media-element*, track-cue* and track-remove* tests to testharness.js (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use "onenter" event attribute 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
Index: third_party/WebKit/LayoutTests/media/track/track-cue-gc-wrapper.html
diff --git a/third_party/WebKit/LayoutTests/media/track/track-cue-gc-wrapper.html b/third_party/WebKit/LayoutTests/media/track/track-cue-gc-wrapper.html
index 0ff60be0612be4f4474b92d855b4c3a2d7f9a470..96ed4cf5b960ac397fa63bf22c71a241790d3743 100644
--- a/third_party/WebKit/LayoutTests/media/track/track-cue-gc-wrapper.html
+++ b/third_party/WebKit/LayoutTests/media/track/track-cue-gc-wrapper.html
@@ -1,74 +1,55 @@
<!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 cue;
- var track;
- var j = 0;
- var cueLimit = 10;
-
- function checkNativeProperty()
- {
- cue = this;
- testExpected("cue.hasOwnProperty('custom')", true);
- if (++j >= cueLimit)
- endTest();
- }
-
- function startTest()
- {
- findMediaElement();
- video.src = findMediaFile('video', '../content/test');
-
- video.textTracks.custom = "trackList";
- testExpected("video.textTracks.hasOwnProperty('custom')", true);
-
- consoleWrite("** Add a text track to the video element **");
-
- track = video.addTextTrack("captions", "regular captions track", "en");
- track.custom = "track";
- testExpected("track.hasOwnProperty('custom')", true);
-
- consoleWrite("** Add cues with own native property to the track with enter event listener. **");
- for (var i = 0; i < cueLimit; i++) {
- var c = new VTTCue(i / 4, i / 2 + 1, "Label" + i);
- c.custom = "cue";
- c.addEventListener("enter", checkNativeProperty);
- track.addCue(c);
- c = null;
- }
- for (var i = 0; i < 10; i++) {
- cue = track.cues[i];
- testExpected("cue.hasOwnProperty('custom')", true);
- }
-
- consoleWrite("");
- consoleWrite("** Trigger a garbage collection. **");
- track = null;
- cue = null;
- gc();
-
- testExpected("video.textTracks.hasOwnProperty('custom')", true);
-
- track = video.textTracks[0];
- testExpected("track.hasOwnProperty('custom')", true);
-
- consoleWrite("");
- consoleWrite("** Play the video and test cue wrappers. **");
- run("video.play()");
- track.mode = "showing";
- }
- </script>
- </head>
-
- <body onload="startTest()">
- <p>Tests that added cue object wrappers live across garbage collections.</p>
- <video controls />
- </body>
-</html>
+<title>Tests that added cue object wrappers live across garbage collections.</title>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script src="../media-file.js"></script>
+<video></video>
+<script>
+async_test(function(t) {
+ var cueIndex = 0;
+ var cueLimit = 10;
+ var video = document.querySelector("video");
+ video.src = findMediaFile("video", "../content/test");
+
+ video.textTracks.custom = "trackList";
+ assert_true(video.textTracks.hasOwnProperty("custom"));
+
+ // Add a text track to the video element.
+ var track = video.addTextTrack("captions", "regular captions track", "en");
+ track.custom = "track";
+ assert_true(track.hasOwnProperty("custom"));
+
+ // Add cues with own native property to the track with enter event listener.
+ for (var i = 0; i < cueLimit; i++) {
+ var cue = new VTTCue(i / 4, i / 2 + 1, "Label" + i);
+ cue.custom = "cue";
+
+ cue.onenter = t.step_func(function(event) {
+ var currentCue = event.target;
+ assert_true(currentCue.hasOwnProperty("custom"));
+ if (++cueIndex == cueLimit)
+ t.done();
+ });
+
+ track.addCue(cue);
+ }
+
+ for (var i = 0; i < cueLimit; i++) {
+ var cue = track.cues[i];
+ assert_true(cue.hasOwnProperty("custom"));
+ }
+
+ // Trigger a garbage collection.
+ track = null;
+ gc();
+
+ assert_true(video.textTracks.hasOwnProperty("custom"));
+
+ track = video.textTracks[0];
+ assert_true(track.hasOwnProperty("custom"));
+
+ // Play the video and test cue wrappers.
+ video.play();
+ track.mode = "showing";
+});
+</script>

Powered by Google App Engine
This is Rietveld 408576698