Index: LayoutTests/media/avtracklists.html |
diff --git a/LayoutTests/media/avtracklists.html b/LayoutTests/media/avtracklists.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..af104a6767b682de82186a7fa2f151b6e45fd793 |
--- /dev/null |
+++ b/LayoutTests/media/avtracklists.html |
@@ -0,0 +1,93 @@ |
+<!doctype html> |
+<html> |
+ <head> |
+ <title>AudioTrackList & VideoTrackList tests</title> |
+ <script src="../resources/testharness.js"></script> |
+ <script src="../resources/testharnessreport.js"></script> |
+ <script src="media-file.js"></script> |
+ </head> |
+ <body> |
+ <div id="log"></div> |
+ <script> |
+ function basic_tracklist_test(tagName, src, label) |
+ { |
+ function onTrackListEvent(actualEventList, e) |
+ { |
+ actualEventList.push(e.type); |
+ |
+ if (e.type == "addtrack") { |
+ assert_equals(e.track, e.target[0], "Track property matches first track in list."); |
+ } |
+ } |
+ |
+ function setupTrackListHandlers(t, trackList, actualEventList) |
+ { |
+ trackList.addEventListener('addtrack', t.step_func(onTrackListEvent.bind(this, actualEventList))); |
+ trackList.addEventListener('change', t.step_func(onTrackListEvent.bind(this, actualEventList))); |
+ trackList.addEventListener('removetrack', t.step_func(onTrackListEvent.bind(this, actualEventList))); |
+ } |
+ |
+ async_test(function(t) |
+ { |
+ var e = document.createElement(tagName); |
+ e.src = src; |
+ e.preload = "none"; |
+ |
+ var expectedEvents = ['addtrack', 'change']; |
+ var actualAudioEvents = []; |
+ var actualVideoEvents = []; |
+ setupTrackListHandlers(t, e.audioTracks, actualAudioEvents, "audioTracks events"); |
+ setupTrackListHandlers(t, e.videoTracks, actualVideoEvents, "videoTracks events"); |
+ |
+ e.load(); |
+ |
+ e.addEventListener('loadedmetadata', t.step_func(function() |
+ { |
+ assert_array_equals(actualAudioEvents, expectedEvents); |
+ |
+ if (e.videoTracks.length > 0) { |
+ assert_equals(label, "audio-video"); |
+ assert_array_equals(actualVideoEvents, expectedEvents); |
+ } else { |
+ assert_equals(label, "audio-only"); |
+ assert_equals(actualVideoEvents.length, 0); |
+ } |
+ |
+ t.done(); |
+ })); |
+ }, tagName + " : " + label); |
+ } |
+ |
+ basic_tracklist_test('audio', findMediaFile('audio', 'content/test'), "audio-only"); |
+ basic_tracklist_test('audio', findMediaFile('video', 'content/test'), "audio-video"); |
+ basic_tracklist_test('video', findMediaFile('audio', 'content/test'), "audio-only"); |
+ basic_tracklist_test('video', findMediaFile('video', 'content/test'), "audio-video"); |
+ |
+ async_test(function(t) |
+ { |
+ var e = document.createElement('video'); |
+ e.src = findMediaFile('video', 'content/test'); |
+ e.preload = "none"; |
+ var expectedEvents = ['addtrack', 'change']; |
+ var actualAudioEvents = []; |
+ var actualVideoEvents = []; |
+ |
+ e.load(); |
+ |
+ e.addEventListener('loadedmetadata', t.step_func(function() |
+ { |
+ assert_equals(e.audioTracks.length, 1, "audioTracks.length"); |
+ assert_equals(e.videoTracks.length, 1, "videoTracks.length"); |
+ |
+ // Clear the source and verify that the track lists are cleared. |
+ e.src = ""; |
+ e.load(); |
+ |
+ assert_equals(e.audioTracks.length, 0, "audioTracks.length"); |
+ assert_equals(e.videoTracks.length, 0, "videoTracks.length"); |
+ t.done(); |
+ })); |
+ }, "Verify audioTracks & videoTracks are cleared."); |
+ </script> |
+ </body> |
+</html> |