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

Unified Diff: LayoutTests/media/track/track-remove-track.html

Issue 177243018: Prevent 'removetrack' events from firing when all inband text tracks are removed. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove console messages Created 6 years, 10 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 | LayoutTests/media/track/track-remove-track-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/media/track/track-remove-track.html
diff --git a/LayoutTests/media/track/track-remove-track.html b/LayoutTests/media/track/track-remove-track.html
index 49c28ad765cdaba753d00ce1a52c404618a4fea7..430ce9463c6d47465fa8aceed4c94db7787b1ab1 100644
--- a/LayoutTests/media/track/track-remove-track.html
+++ b/LayoutTests/media/track/track-remove-track.html
@@ -3,48 +3,105 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <script src=../media-file.js></script>
- <script src=../video-test.js></script>
+ <script src="../media-file.js"></script>
+ <script src="../video-test.js"></script>
+ <script src="../../resources/testharness.js"></script>
+ <script src="../../resources/testharnessreport.js"></script>
+ </head>
+ <body>
<script>
+ async_test(function(test)
+ {
+ var video = document.createElement("video");
+ var track;
- var trackElement;
- var track;
+ function trackRemoved()
+ {
+ assert_equals(event.target, video.textTracks);
+ assert_equals(event instanceof window.TrackEvent, true);
+ assert_equals(event.track, track);
+ test.done();
+ }
- function trackRemoved()
- {
- consoleWrite("EVENT(" + event.type + ")");
+ var trackElement = document.createElement('track');
+ video.appendChild(trackElement);
- testExpected("event.target", video.textTracks);
- testExpected("event instanceof window.TrackEvent", true);
- testExpected("event.track", track);
+ trackElement.src = 'captions-webvtt/tc004-webvtt-file.vtt';
+ trackElement.track.mode = 'hidden';
- consoleWrite("");
- endTest();
- }
+ assert_equals(video.textTracks.length, 1);
- function start()
+ track = video.textTracks[0];
+ video.removeChild(trackElement);
+ video.textTracks.addEventListener("removetrack", test.step_func(trackRemoved));
+ }, "Tests that the 'removetrack' event is fired when an out-of-band TextTrack is removed.");
+
+ async_test(function(test)
{
- findMediaElement();
+ var video = document.createElement("video");
- consoleWrite("** Test a TextTrack created for a &lt;track&gt; element.");
- run("trackElement = document.createElement('track')");
- run("video.appendChild(trackElement)");
+ // Create an out-of-band text track by adding a track element.
+ var trackElement = document.createElement('track');
- run("trackElement.src = 'captions-webvtt/tc004-webvtt-file.vtt'");
- run("trackElement.track.mode = 'hidden'");
- testExpected("video.textTracks.length", 1);
+ trackElement.addEventListener("error", test.step_func(function()
+ {
+ assert_unreached("'error' event on track element should not fire.")
+ }));
- track = video.textTracks[0];
- video.removeChild(trackElement);
+ video.appendChild(trackElement);
+ trackElement.src = 'captions-webvtt/tc004-webvtt-file.vtt';
+ trackElement.track.mode = 'hidden';
+
+ assert_equals(video.textTracks.length, 1);
+ var outOfBandTrack = video.textTracks[0];
- video.textTracks.addEventListener("removetrack", trackRemoved);
- }
+ // Load a media file with an inband text track.
+ var inbandTrack = null;
+ var url = "../content/test-vp8-vorbis-webvtt.webm"
+
+ var firstAddTrackHandler = test.step_func(function()
+ {
+ assert_equals(event.target, video.textTracks);
+ assert_equals(event instanceof window.TrackEvent, true);
+ if (event.track == outOfBandTrack) {
+ return;
+ }
+
+ assert_equals(inbandTrack, null);
+ assert_equals(video.textTracks.length, 2);
+ assert_equals(event.track, video.textTracks[1]);
+ inbandTrack = event.track;
+
+ video.textTracks.removeEventListener("addtrack", firstAddTrackHandler);
+
+ // Clear .src to force the inband track to get destroyed.
+ video.src = "";
+
+ // Verify that the inband track was removed.
+ assert_not_equals(inbandTrack, null);
+ assert_equals(video.textTracks.length, 1);
+ assert_equals(video.textTracks[0], outOfBandTrack);
+
+ // Load the URL again to trigger another 'addtrack' event to make sure
+ // no 'removetrack' event was queued.
+ video.src = url;
+ video.textTracks.addEventListener("addtrack", test.step_func(function()
+ {
+ assert_equals(video.textTracks.length, 2);
+ test.done();
+ }));
+ });
+ video.textTracks.addEventListener("addtrack", firstAddTrackHandler);
+
+ video.textTracks.addEventListener("removetrack", test.step_func(function()
+ {
+ assert_unreached("'removetrack' event should not fire.")
+ }));
+
+ video.src = url;
+ }, "Tests that the 'removetrack' event is NOT fired for inband TextTrack on a failed load.");
</script>
- </head>
- <body onload="start()">
- <p>Tests that the 'removetrack' event is fired when a TextTrack is removed.</p>
- <video>
- </video>
+ <div id="log"></div>
</body>
</html>
« no previous file with comments | « no previous file | LayoutTests/media/track/track-remove-track-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698