Index: LayoutTests/media/avtrack/addtrack.html |
diff --git a/LayoutTests/media/avtrack/addtrack.html b/LayoutTests/media/avtrack/addtrack.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..18c9097a42aeaffe411185562585840e8ac8ff5c |
--- /dev/null |
+++ b/LayoutTests/media/avtrack/addtrack.html |
@@ -0,0 +1,66 @@ |
+<!doctype html> |
+<html> |
+ <head> |
+ <title>AudioTrackList & VideoTrackList addtrack event</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 addtrack_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; |
+ |
+ var expectedEvents = ["addtrack"]; |
+ 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); |
+ } |
+ |
+ addtrack_test("audio", findMediaFile("audio", "../content/test"), "audio-only"); |
+ addtrack_test("audio", findMediaFile("video", "../content/test"), "audio-video"); |
+ addtrack_test("video", findMediaFile("audio", "../content/test"), "audio-only"); |
+ addtrack_test("video", findMediaFile("video", "../content/test"), "audio-video"); |
+ </script> |
+ </body> |
+</html> |