Chromium Code Reviews| Index: LayoutTests/media/avtracklists.html |
| diff --git a/LayoutTests/media/avtracklists.html b/LayoutTests/media/avtracklists.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3634929908934735d2e9f0de23070232dba6fb11 |
| --- /dev/null |
| +++ b/LayoutTests/media/avtracklists.html |
| @@ -0,0 +1,97 @@ |
| +<!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 == "change") |
| + return; |
|
philipj_slow
2014/03/09 09:04:14
This early return can be removed.
acolwell GONE FROM CHROMIUM
2014/03/18 22:02:15
Done.
|
| + |
| + if (e.type == "addtrack") { |
| + // Verify that the track property matches the first track in the list. |
| + assert_equals(e.track, e.target[0]); |
| + } |
| + } |
| + |
| + 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"); |
|
philipj_slow
2014/03/09 09:04:14
Verify that e.audioTracks[0] is an AudioTrack and
acolwell GONE FROM CHROMIUM
2014/03/18 22:02:15
I didn't want to verify the attributes yet because
philipj_slow
2014/03/20 16:17:39
Makes sense. Verifying instanceof AudioTrack would
|
| + assert_equals(e.videoTracks.length, 1, "videoTracks.length"); |
| + |
| + // Clear the source and verify that the track lists are cleared. |
| + e.src = ""; |
|
philipj_slow
2014/03/20 16:17:39
I didn't notice this before. Setting the src attri
|
| + 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> |