Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <script src="/w3c/resources/testharness.js"></script> | |
| 5 <script src="/w3c/resources/testharnessreport.js"></script> | |
| 6 | |
| 7 <link rel='stylesheet' href='/w3c/resources/testharness.css'> | |
| 8 </head> | |
| 9 <body> | |
| 10 <div id="log"></div> | |
| 11 <script> | |
| 12 | |
| 13 test(function() | |
| 14 { | |
| 15 var originalTrackDefaults = [ | |
| 16 // Same everything, but different byteStreamTrackID, should be allowed by the constructor. | |
| 17 new TrackDefault("audio", "en-US", "label", ["main"], ""), | |
| 18 new TrackDefault("audio", "en-US", "label", ["main"], "1"), | |
| 19 new TrackDefault("audio", "en-US", "label", ["main"], "2"), | |
| 20 new TrackDefault("audio", "en-US", "label", [""], "3"), | |
| 21 | |
| 22 // Same everything, but different type, should be allowed by the constructor. | |
| 23 new TrackDefault("video", "en-US", "label", ["main"], ""), | |
| 24 new TrackDefault("video", "en-US", "label", ["main"], "1"), | |
| 25 new TrackDefault("video", "en-US", "label", ["main"], "2"), | |
| 26 new TrackDefault("video", "en-US", "label", [""], "3") | |
| 27 ]; | |
| 28 | |
| 29 // Get a new array containing the same objects as |originalTrack Defaults|. | |
| 30 var trackDefaults = originalTrackDefaults.slice(); | |
| 31 | |
| 32 var trackDefaultList = new TrackDefaultList(trackDefaults); | |
| 33 assert_array_equals(trackDefaultList, originalTrackDefaults, "co nstruction and read-back succeeded"); | |
| 34 assert_equals(trackDefaultList[trackDefaultList.length], undefin ed, "out of range indexed property getter result is undefined"); | |
| 35 assert_equals(trackDefaultList[trackDefaultList.length + 1], und efined, "out of range indexed property getter result is undefined"); | |
| 36 | |
| 37 // Introduce same-type, same-empty-string-byteStreamTrackId conf lict in trackDefaults[0 vs 4]. | |
| 38 trackDefaults[4] = new TrackDefault("audio", "en-GB", "another l abel", ["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.
| |
| 39 assert_equals(trackDefaults[0].type, trackDefaults[4].type, "sam e-type conflict setup"); | |
| 40 assert_equals(trackDefaults[0].byteStreamTrackID, trackDefaults[ 4].byteStreamTrackID, "same-byteStreamTrackID conflict setup"); | |
| 41 assert_throws("InvalidAccessError", | |
| 42 function() { new TrackDefaultList(trackDefaults); }, | |
| 43 "TrackDefaultList construction should throw exception due to same type and byteStreamTrackID across at least 2 items in trackDefaults"); | |
| 44 | |
| 45 // Introduce same-type, same-non-empty-string-byteStreamTrackId conflict in trackDefaults[4 vs 5]. | |
| 46 trackDefaults[4] = new TrackDefault("video", "en-GB", "another l abel", ["alternative", "commentary"], "1"); | |
| 47 assert_equals(trackDefaults[4].type, trackDefaults[5].type, "sam e-type conflict setup"); | |
| 48 assert_equals(trackDefaults[4].byteStreamTrackID, trackDefaults[ 5].byteStreamTrackID, "same-byteStreamTrackID conflict setup"); | |
| 49 assert_throws("InvalidAccessError", | |
| 50 function() { new TrackDefaultList(trackDefaults); }, | |
| 51 "TrackDefaultList construction should throw exception due to same type and byteStreamTrackID across at least 2 items in trackDefaults"); | |
| 52 | |
| 53 assert_array_equals(trackDefaultList, originalTrackDefaults, "re ad-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
| |
| 54 }, "Test track default list construction, length, and indexed proper ty getter"); | |
| 55 | |
| 56 </script> | |
| 57 </body> | |
| 58 </html> | |
| OLD | NEW |