Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="/w3c/resources/testharness.js"></script> | 4 <script src="/w3c/resources/testharness.js"></script> |
| 5 <script src="/w3c/resources/testharnessreport.js"></script> | 5 <script src="/w3c/resources/testharnessreport.js"></script> |
| 6 <script src="mediasource-util.js"></script> | 6 <script src="mediasource-util.js"></script> |
| 7 | 7 |
| 8 <link rel='stylesheet' href='/w3c/resources/testharness.css'> | 8 <link rel='stylesheet' href='/w3c/resources/testharness.css'> |
| 9 </head> | 9 </head> |
| 10 <body> | 10 <body> |
| 11 <div id="log"></div> | 11 <div id="log"></div> |
| 12 <script> | 12 <script> |
| 13 // TODO(wolenetz): Remove this hacky console warning once desktop and | 13 // TODO(wolenetz): Remove this hacky console warning once desktop and |
| 14 // android expectations match. It allows a passing platform-specific | 14 // android expectations match. It allows a passing platform-specific |
| 15 // expectation to override a failing non-platform-specific expectation . | 15 // expectation to override a failing non-platform-specific expectation . |
| 16 console.warn('Ignore this warning. See https://crbug.com/568704#c2'); | 16 console.warn('Ignore this warning. See https://crbug.com/568704#c2'); |
| 17 | 17 |
| 18 mediasource_test(function(test, mediaElement, mediaSource) | 18 mediasource_test(function(test, mediaElement, mediaSource) |
| 19 { | 19 { |
| 20 mediaSource.endOfStream(); | 20 mediaSource.endOfStream(); |
| 21 assert_throws("InvalidStateError", | 21 assert_throws("InvalidStateError", |
| 22 function() { mediaSource.addSourceBuffer(MediaSourceUt il.AUDIO_VIDEO_TYPE); }, | 22 function() { mediaSource.addSourceBuffer(MediaSourceUt il.AUDIO_VIDEO_TYPE); }, |
| 23 "addSourceBuffer() threw an exception when in 'ended' state."); | 23 "addSourceBuffer() threw an exception when in 'ended' state."); |
| 24 test.done(); | 24 test.done(); |
| 25 }, "Test addSourceBuffer() in 'ended' state."); | 25 }, "Test addSourceBuffer() in 'ended' state."); |
| 26 | 26 |
| 27 mediasource_test(function(test, mediaElement, mediaSource) | 27 mediasource_test(function(test, mediaElement, mediaSource) |
| 28 { | 28 { |
| 29 assert_throws("InvalidAccessError", | 29 assert_throws({name: "TypeError"}, |
|
foolip
2016/09/07 19:42:49
This does what the spec asks, but I do wonder why
wolenetz
2016/09/07 21:09:26
Good point. I believe this is implemented in other
| |
| 30 function() { mediaSource.addSourceBuffer(""); }, | 30 function() { mediaSource.addSourceBuffer(""); }, |
| 31 "addSourceBuffer() threw an exception when passed an e mpty string."); | 31 "addSourceBuffer() threw an exception when passed an e mpty string."); |
| 32 test.done(); | 32 test.done(); |
| 33 }, "Test addSourceBuffer() with empty type"); | 33 }, "Test addSourceBuffer() with empty type"); |
| 34 | 34 |
| 35 mediasource_test(function(test, mediaElement, mediaSource) | 35 mediasource_test(function(test, mediaElement, mediaSource) |
| 36 { | 36 { |
| 37 assert_throws("NotSupportedError", | 37 assert_throws("NotSupportedError", |
| 38 function() { mediaSource.addSourceBuffer(null); }, | 38 function() { mediaSource.addSourceBuffer(null); }, |
| 39 "addSourceBuffer() threw an exception when passed null ."); | 39 "addSourceBuffer() threw an exception when passed null ."); |
| 40 test.done(); | 40 test.done(); |
| 41 }, "Test addSourceBuffer() with null"); | 41 }, "Test addSourceBuffer() with null"); |
| 42 | 42 |
| 43 mediasource_test(function(test, mediaElement, mediaSource) | 43 mediasource_test(function(test, mediaElement, mediaSource) |
| 44 { | 44 { |
| 45 assert_throws("NotSupportedError", | 45 assert_throws("NotSupportedError", |
| 46 function() { mediaSource.addSourceBuffer("invalidType" ); }, | 46 function() { mediaSource.addSourceBuffer("invalidType" ); }, |
| 47 "addSourceBuffer() threw an exception for an unsupport ed type."); | 47 "addSourceBuffer() threw an exception for an unsupport ed type."); |
| 48 test.done(); | 48 test.done(); |
| 49 }, "Test addSourceBuffer() with unsupported type"); | 49 }, "Test addSourceBuffer() with unsupported type"); |
| 50 | 50 |
| 51 mediasource_test(function(test, mediaElement, mediaSource) | 51 mediasource_test(function(test, mediaElement, mediaSource) |
| 52 { | 52 { |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 83 var mimetype = MediaSourceUtil.VIDEO_ONLY_TYPE; | 83 var mimetype = MediaSourceUtil.VIDEO_ONLY_TYPE; |
| 84 | 84 |
| 85 assert_true(MediaSource.isTypeSupported(mimetype), mimetype + " is supported"); | 85 assert_true(MediaSource.isTypeSupported(mimetype), mimetype + " is supported"); |
| 86 | 86 |
| 87 var sourceBuffer = mediaSource.addSourceBuffer(mimetype); | 87 var sourceBuffer = mediaSource.addSourceBuffer(mimetype); |
| 88 assert_true(sourceBuffer != null, "New SourceBuffer returned"); | 88 assert_true(sourceBuffer != null, "New SourceBuffer returned"); |
| 89 assert_equals(mediaSource.sourceBuffers[0], sourceBuffer, "SourceB uffer is in mediaSource.sourceBuffers"); | 89 assert_equals(mediaSource.sourceBuffers[0], sourceBuffer, "SourceB uffer is in mediaSource.sourceBuffers"); |
| 90 assert_equals(mediaSource.activeSourceBuffers.length, 0, "SourceBu ffer is not in mediaSource.activeSourceBuffers"); | 90 assert_equals(mediaSource.activeSourceBuffers.length, 0, "SourceBu ffer is not in mediaSource.activeSourceBuffers"); |
| 91 test.done(); | 91 test.done(); |
| 92 }, "Test addSourceBuffer() video only"); | 92 }, "Test addSourceBuffer() video only"); |
| 93 | 93 |
| 94 mediasource_test(function(test, mediaElement, mediaSource) | 94 mediasource_test(function(test, mediaElement, mediaSource) |
| 95 { | 95 { |
| 96 var mimetype = MediaSourceUtil.AUDIO_ONLY_TYPE; | 96 var mimetype = MediaSourceUtil.AUDIO_ONLY_TYPE; |
| 97 | 97 |
| 98 assert_true(MediaSource.isTypeSupported(mimetype), mimetype + " is supported"); | 98 assert_true(MediaSource.isTypeSupported(mimetype), mimetype + " is supported"); |
| 99 | 99 |
| 100 var sourceBuffer = mediaSource.addSourceBuffer(mimetype); | 100 var sourceBuffer = mediaSource.addSourceBuffer(mimetype); |
| 101 assert_true(sourceBuffer != null, "New SourceBuffer returned"); | 101 assert_true(sourceBuffer != null, "New SourceBuffer returned"); |
| 102 assert_equals(mediaSource.sourceBuffers[0], sourceBuffer, "SourceB uffer is in mediaSource.sourceBuffers"); | 102 assert_equals(mediaSource.sourceBuffers[0], sourceBuffer, "SourceB uffer is in mediaSource.sourceBuffers"); |
| 103 assert_equals(mediaSource.activeSourceBuffers.length, 0, "SourceBu ffer is not in mediaSource.activeSourceBuffers"); | 103 assert_equals(mediaSource.activeSourceBuffers.length, 0, "SourceBu ffer is not in mediaSource.activeSourceBuffers"); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 148 reachedLimit = true; | 148 reachedLimit = true; |
| 149 break; | 149 break; |
| 150 } | 150 } |
| 151 } | 151 } |
| 152 assert_true(reachedLimit, "Reached SourceBuffer limit."); | 152 assert_true(reachedLimit, "Reached SourceBuffer limit."); |
| 153 test.done(); | 153 test.done(); |
| 154 }, "Test addSourceBuffer() QuotaExceededError."); | 154 }, "Test addSourceBuffer() QuotaExceededError."); |
| 155 </script> | 155 </script> |
| 156 </body> | 156 </body> |
| 157 </html> | 157 </html> |
| OLD | NEW |