Chromium Code Reviews| Index: LayoutTests/http/tests/media/media-source/mediasource-trackdefaultlist.html |
| diff --git a/LayoutTests/http/tests/media/media-source/mediasource-trackdefaultlist.html b/LayoutTests/http/tests/media/media-source/mediasource-trackdefaultlist.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3ab7dcc96fc9d6ec97addfce27cac867a53bfd6c |
| --- /dev/null |
| +++ b/LayoutTests/http/tests/media/media-source/mediasource-trackdefaultlist.html |
| @@ -0,0 +1,58 @@ |
| +<!DOCTYPE html> |
| +<html> |
| + <head> |
| + <script src="/w3c/resources/testharness.js"></script> |
| + <script src="/w3c/resources/testharnessreport.js"></script> |
| + |
| + <link rel='stylesheet' href='/w3c/resources/testharness.css'> |
| + </head> |
| + <body> |
| + <div id="log"></div> |
| + <script> |
| + |
| + test(function() |
| + { |
| + var originalTrackDefaults = [ |
| + // Same everything, but different byteStreamTrackID, should be allowed by the constructor. |
| + new TrackDefault("audio", "en-US", "label", ["main"], ""), |
| + new TrackDefault("audio", "en-US", "label", ["main"], "1"), |
| + new TrackDefault("audio", "en-US", "label", ["main"], "2"), |
| + new TrackDefault("audio", "en-US", "label", [""], "3"), |
| + |
| + // Same everything, but different type, should be allowed by the constructor. |
| + new TrackDefault("video", "en-US", "label", ["main"], ""), |
| + new TrackDefault("video", "en-US", "label", ["main"], "1"), |
| + new TrackDefault("video", "en-US", "label", ["main"], "2"), |
| + new TrackDefault("video", "en-US", "label", [""], "3") |
| + ]; |
| + |
| + // Get a new array containing the same objects as |originalTrackDefaults|. |
| + var trackDefaults = originalTrackDefaults.slice(); |
| + |
| + var trackDefaultList = new TrackDefaultList(trackDefaults); |
| + assert_array_equals(trackDefaultList, originalTrackDefaults, "construction and read-back succeeded"); |
| + assert_equals(trackDefaultList[trackDefaultList.length], undefined, "out of range indexed property getter result is undefined"); |
| + assert_equals(trackDefaultList[trackDefaultList.length + 1], undefined, "out of range indexed property getter result is undefined"); |
| + |
| + // Introduce same-type, same-empty-string-byteStreamTrackId conflict in trackDefaults[0 vs 4]. |
| + trackDefaults[4] = new TrackDefault("audio", "en-GB", "another label", ["alternative", "commentary"], ""); |
|
philipj_slow
2014/12/04 15:29:14
Can you change a single thing only, to ensure that
wolenetz
2014/12/11 23:52:39
Done.
|
| + assert_equals(trackDefaults[0].type, trackDefaults[4].type, "same-type conflict setup"); |
| + assert_equals(trackDefaults[0].byteStreamTrackID, trackDefaults[4].byteStreamTrackID, "same-byteStreamTrackID conflict setup"); |
| + assert_throws("InvalidAccessError", |
| + function() { new TrackDefaultList(trackDefaults); }, |
| + "TrackDefaultList construction should throw exception due to same type and byteStreamTrackID across at least 2 items in trackDefaults"); |
| + |
| + // Introduce same-type, same-non-empty-string-byteStreamTrackId conflict in trackDefaults[4 vs 5]. |
| + trackDefaults[4] = new TrackDefault("video", "en-GB", "another label", ["alternative", "commentary"], "1"); |
| + assert_equals(trackDefaults[4].type, trackDefaults[5].type, "same-type conflict setup"); |
| + assert_equals(trackDefaults[4].byteStreamTrackID, trackDefaults[5].byteStreamTrackID, "same-byteStreamTrackID conflict setup"); |
| + assert_throws("InvalidAccessError", |
| + function() { new TrackDefaultList(trackDefaults); }, |
| + "TrackDefaultList construction should throw exception due to same type and byteStreamTrackID across at least 2 items in trackDefaults"); |
| + |
| + assert_array_equals(trackDefaultList, originalTrackDefaults, "read-back of original trackDefaultList unchanged"); |
|
philipj_slow
2014/12/04 15:29:14
I think this will fail if a deep copy is made, can
wolenetz
2014/12/11 23:52:39
I had done some manual verification while writing
|
| + }, "Test track default list construction, length, and indexed property getter"); |
| + |
| + </script> |
| + </body> |
| +</html> |