| 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 <link rel='stylesheet' href='/w3c/resources/testharness.css'> | 7 <link rel='stylesheet' href='/w3c/resources/testharness.css'> |
| 8 </head> | 8 </head> |
| 9 <body> | 9 <body> |
| 10 <div id="log"></div> | 10 <div id="log"></div> |
| 11 <script> | 11 <script> |
| 12 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) | 12 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) |
| 13 { | 13 { |
| 14 test.failOnEvent(mediaElement, 'error'); | 14 test.failOnEvent(mediaElement, 'error'); |
| 15 | 15 |
| 16 test.expectEvent(sourceBuffer, "updatestart", "Append started."); | 16 test.expectEvent(sourceBuffer, 'updatestart', 'Append started.'); |
| 17 test.expectEvent(sourceBuffer, "update", "Append success."); | 17 test.expectEvent(sourceBuffer, 'update', 'Append success.'); |
| 18 test.expectEvent(sourceBuffer, "updateend", "Append ended."); | 18 test.expectEvent(sourceBuffer, 'updateend', 'Append ended.'); |
| 19 sourceBuffer.appendBuffer(mediaData); | 19 sourceBuffer.appendBuffer(mediaData); |
| 20 | 20 |
| 21 assert_true(sourceBuffer.updating, "updating attribute is true"); | 21 assert_true(sourceBuffer.updating, 'updating attribute is true'); |
| 22 | 22 |
| 23 test.waitForExpectedEvents(function() | 23 test.waitForExpectedEvents(function() |
| 24 { | 24 { |
| 25 assert_false(sourceBuffer.updating, "updating attribute is fals
e"); | 25 assert_false(sourceBuffer.updating, 'updating attribute is fals
e'); |
| 26 test.done(); | 26 test.done(); |
| 27 }); | 27 }); |
| 28 }, "Test SourceBuffer.appendBuffer() event dispatching."); | 28 }, 'Test SourceBuffer.appendBuffer() event dispatching.'); |
| 29 | 29 |
| 30 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) | 30 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) |
| 31 { | 31 { |
| 32 test.failOnEvent(mediaElement, 'error'); | 32 test.failOnEvent(mediaElement, 'error'); |
| 33 | 33 |
| 34 test.expectEvent(sourceBuffer, "updatestart", "Append started."); | 34 test.expectEvent(sourceBuffer, 'updatestart', 'Append started.'); |
| 35 test.expectEvent(sourceBuffer, "update", "Append success."); | 35 test.expectEvent(sourceBuffer, 'update', 'Append success.'); |
| 36 test.expectEvent(sourceBuffer, "updateend", "Append ended."); | 36 test.expectEvent(sourceBuffer, 'updateend', 'Append ended.'); |
| 37 sourceBuffer.appendBuffer(mediaData); | 37 sourceBuffer.appendBuffer(mediaData); |
| 38 | 38 |
| 39 assert_true(sourceBuffer.updating, "updating attribute is true"); | 39 assert_true(sourceBuffer.updating, 'updating attribute is true'); |
| 40 | 40 |
| 41 assert_throws("InvalidStateError", | 41 assert_throws('InvalidStateError', |
| 42 function() { sourceBuffer.appendBuffer(mediaData); }, | 42 function() { sourceBuffer.appendBuffer(mediaData); }, |
| 43 "appendBuffer() throws an exception there is a pending append.
"); | 43 'appendBuffer() throws an exception there is a pending append.
'); |
| 44 | 44 |
| 45 assert_true(sourceBuffer.updating, "updating attribute is true"); | 45 assert_true(sourceBuffer.updating, 'updating attribute is true'); |
| 46 | 46 |
| 47 test.waitForExpectedEvents(function() | 47 test.waitForExpectedEvents(function() |
| 48 { | 48 { |
| 49 assert_false(sourceBuffer.updating, "updating attribute is fal
se"); | 49 assert_false(sourceBuffer.updating, 'updating attribute is fal
se'); |
| 50 test.done(); | 50 test.done(); |
| 51 }); | 51 }); |
| 52 }, "Test SourceBuffer.appendBuffer() call during a pending appendBuffe
r()."); | 52 }, 'Test SourceBuffer.appendBuffer() call during a pending appendBuffe
r().'); |
| 53 | 53 |
| 54 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) | 54 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) |
| 55 { | 55 { |
| 56 test.failOnEvent(mediaElement, 'error'); | 56 test.failOnEvent(mediaElement, 'error'); |
| 57 | 57 |
| 58 test.expectEvent(sourceBuffer, "updatestart", "Append started."); | 58 test.expectEvent(sourceBuffer, 'updatestart', 'Append started.'); |
| 59 test.expectEvent(sourceBuffer, "abort", "Append aborted."); | 59 test.expectEvent(sourceBuffer, 'abort', 'Append aborted.'); |
| 60 test.expectEvent(sourceBuffer, "updateend", "Append ended."); | 60 test.expectEvent(sourceBuffer, 'updateend', 'Append ended.'); |
| 61 sourceBuffer.appendBuffer(mediaData); | 61 sourceBuffer.appendBuffer(mediaData); |
| 62 | 62 |
| 63 assert_true(sourceBuffer.updating, "updating attribute is true"); | 63 assert_true(sourceBuffer.updating, 'updating attribute is true'); |
| 64 | 64 |
| 65 sourceBuffer.abort(); | 65 sourceBuffer.abort(); |
| 66 | 66 |
| 67 assert_false(sourceBuffer.updating, "updating attribute is false")
; | 67 assert_false(sourceBuffer.updating, 'updating attribute is false')
; |
| 68 | 68 |
| 69 test.waitForExpectedEvents(function() | 69 test.waitForExpectedEvents(function() |
| 70 { | 70 { |
| 71 assert_false(sourceBuffer.updating, "updating attribute is fal
se"); | 71 assert_false(sourceBuffer.updating, 'updating attribute is fal
se'); |
| 72 test.done(); | 72 test.done(); |
| 73 }); | 73 }); |
| 74 }, "Test SourceBuffer.abort() call during a pending appendBuffer()."); | 74 }, 'Test SourceBuffer.abort() call during a pending appendBuffer().'); |
| 75 | 75 |
| 76 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) | 76 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) |
| 77 { | 77 { |
| 78 test.failOnEvent(mediaElement, 'error'); | 78 test.failOnEvent(mediaElement, 'error'); |
| 79 | 79 |
| 80 test.expectEvent(sourceBuffer, "updatestart", "Append started."); | 80 test.expectEvent(sourceBuffer, 'updatestart', 'Append started.'); |
| 81 test.expectEvent(sourceBuffer, "update", "Append success."); | 81 test.expectEvent(sourceBuffer, 'update', 'Append success.'); |
| 82 test.expectEvent(sourceBuffer, "updateend", "Append ended."); | 82 test.expectEvent(sourceBuffer, 'updateend', 'Append ended.'); |
| 83 sourceBuffer.appendBuffer(mediaData); | 83 sourceBuffer.appendBuffer(mediaData); |
| 84 assert_true(sourceBuffer.updating, "updating attribute is true"); | 84 assert_true(sourceBuffer.updating, 'updating attribute is true'); |
| 85 | 85 |
| 86 test.waitForExpectedEvents(function() | 86 test.waitForExpectedEvents(function() |
| 87 { | 87 { |
| 88 assert_false(sourceBuffer.updating, "updating attribute is fal
se"); | 88 assert_false(sourceBuffer.updating, 'updating attribute is fal
se'); |
| 89 | 89 |
| 90 test.expectEvent(mediaSource, "sourceended", "MediaSource sour
ceended event"); | 90 test.expectEvent(mediaSource, 'sourceended', 'MediaSource sour
ceended event'); |
| 91 mediaSource.endOfStream(); | 91 mediaSource.endOfStream(); |
| 92 assert_equals(mediaSource.readyState, "ended", "MediaSource re
adyState is 'ended'"); | 92 assert_equals(mediaSource.readyState, 'ended', 'MediaSource re
adyState is "ended"'); |
| 93 }); | 93 }); |
| 94 | 94 |
| 95 test.waitForExpectedEvents(function() | 95 test.waitForExpectedEvents(function() |
| 96 { | 96 { |
| 97 assert_equals(mediaSource.readyState, "ended", "MediaSource re
adyState is 'ended'"); | 97 assert_equals(mediaSource.readyState, 'ended', 'MediaSource re
adyState is "ended"'); |
| 98 | 98 |
| 99 test.expectEvent(mediaSource, "sourceopen", "MediaSource sourc
eopen event"); | 99 test.expectEvent(mediaSource, 'sourceopen', 'MediaSource sourc
eopen event'); |
| 100 test.expectEvent(sourceBuffer, "updatestart", "Append started.
"); | 100 test.expectEvent(sourceBuffer, 'updatestart', 'Append started.
'); |
| 101 test.expectEvent(sourceBuffer, "update", "Append success."); | 101 test.expectEvent(sourceBuffer, 'update', 'Append success.'); |
| 102 test.expectEvent(sourceBuffer, "updateend", "Append ended."); | 102 test.expectEvent(sourceBuffer, 'updateend', 'Append ended.'); |
| 103 sourceBuffer.appendBuffer(mediaData); | 103 sourceBuffer.appendBuffer(mediaData); |
| 104 | 104 |
| 105 assert_equals(mediaSource.readyState, "open", "MediaSource rea
dyState is 'open'"); | 105 assert_equals(mediaSource.readyState, 'open', 'MediaSource rea
dyState is "open"'); |
| 106 assert_true(sourceBuffer.updating, "updating attribute is true
"); | 106 assert_true(sourceBuffer.updating, 'updating attribute is true
'); |
| 107 }); | 107 }); |
| 108 | 108 |
| 109 test.waitForExpectedEvents(function() | 109 test.waitForExpectedEvents(function() |
| 110 { | 110 { |
| 111 assert_equals(mediaSource.readyState, "open", "MediaSource rea
dyState is 'open'"); | 111 assert_equals(mediaSource.readyState, 'open', 'MediaSource rea
dyState is "open"'); |
| 112 assert_false(sourceBuffer.updating, "updating attribute is fal
se"); | 112 assert_false(sourceBuffer.updating, 'updating attribute is fal
se'); |
| 113 test.done(); | 113 test.done(); |
| 114 }); | 114 }); |
| 115 }, "Test SourceBuffer.appendBuffer() triggering an 'ended' to 'open' t
ransition."); | 115 }, 'Test SourceBuffer.appendBuffer() triggering an "ended" to "open" t
ransition.'); |
| 116 | 116 |
| 117 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) | 117 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) |
| 118 { | 118 { |
| 119 test.failOnEvent(mediaElement, 'error'); | 119 test.failOnEvent(mediaElement, 'error'); |
| 120 | 120 |
| 121 test.expectEvent(sourceBuffer, "updatestart", "Append started."); | 121 test.expectEvent(sourceBuffer, 'updatestart', 'Append started.'); |
| 122 test.expectEvent(sourceBuffer, "update", "Append success."); | 122 test.expectEvent(sourceBuffer, 'update', 'Append success.'); |
| 123 test.expectEvent(sourceBuffer, "updateend", "Append ended."); | 123 test.expectEvent(sourceBuffer, 'updateend', 'Append ended.'); |
| 124 sourceBuffer.appendBuffer(mediaData); | 124 sourceBuffer.appendBuffer(mediaData); |
| 125 assert_true(sourceBuffer.updating, "updating attribute is true"); | 125 assert_true(sourceBuffer.updating, 'updating attribute is true'); |
| 126 | 126 |
| 127 test.waitForExpectedEvents(function() | 127 test.waitForExpectedEvents(function() |
| 128 { | 128 { |
| 129 assert_false(sourceBuffer.updating, "updating attribute is fal
se"); | 129 assert_false(sourceBuffer.updating, 'updating attribute is fal
se'); |
| 130 | 130 |
| 131 test.expectEvent(mediaSource, "sourceended", "MediaSource sour
ceended event"); | 131 test.expectEvent(mediaSource, 'sourceended', 'MediaSource sour
ceended event'); |
| 132 mediaSource.endOfStream(); | 132 mediaSource.endOfStream(); |
| 133 assert_equals(mediaSource.readyState, "ended", "MediaSource re
adyState is 'ended'"); | 133 assert_equals(mediaSource.readyState, 'ended', 'MediaSource re
adyState is "ended"'); |
| 134 }); | 134 }); |
| 135 | 135 |
| 136 test.waitForExpectedEvents(function() | 136 test.waitForExpectedEvents(function() |
| 137 { | 137 { |
| 138 assert_equals(mediaSource.readyState, "ended", "MediaSource re
adyState is 'ended'"); | 138 assert_equals(mediaSource.readyState, 'ended', 'MediaSource re
adyState is "ended"'); |
| 139 | 139 |
| 140 test.expectEvent(mediaSource, "sourceopen", "MediaSource sourc
eopen event"); | 140 test.expectEvent(mediaSource, 'sourceopen', 'MediaSource sourc
eopen event'); |
| 141 test.expectEvent(sourceBuffer, "updatestart", "Append started.
"); | 141 test.expectEvent(sourceBuffer, 'updatestart', 'Append started.
'); |
| 142 test.expectEvent(sourceBuffer, "update", "Append success."); | 142 test.expectEvent(sourceBuffer, 'update', 'Append success.'); |
| 143 test.expectEvent(sourceBuffer, "updateend", "Append ended."); | 143 test.expectEvent(sourceBuffer, 'updateend', 'Append ended.'); |
| 144 sourceBuffer.appendBuffer(new Uint8Array(0)); | 144 sourceBuffer.appendBuffer(new Uint8Array(0)); |
| 145 | 145 |
| 146 assert_equals(mediaSource.readyState, "open", "MediaSource rea
dyState is 'open'"); | 146 assert_equals(mediaSource.readyState, 'open', 'MediaSource rea
dyState is "open"'); |
| 147 assert_true(sourceBuffer.updating, "updating attribute is true
"); | 147 assert_true(sourceBuffer.updating, 'updating attribute is true
'); |
| 148 }); | 148 }); |
| 149 | 149 |
| 150 test.waitForExpectedEvents(function() | 150 test.waitForExpectedEvents(function() |
| 151 { | 151 { |
| 152 assert_equals(mediaSource.readyState, "open", "MediaSource rea
dyState is 'open'"); | 152 assert_equals(mediaSource.readyState, 'open', 'MediaSource rea
dyState is "open"'); |
| 153 assert_false(sourceBuffer.updating, "updating attribute is fal
se"); | 153 assert_false(sourceBuffer.updating, 'updating attribute is fal
se'); |
| 154 test.done(); | 154 test.done(); |
| 155 }); | 155 }); |
| 156 }, "Test zero byte SourceBuffer.appendBuffer() call triggering an 'end
ed' to 'open' transition."); | 156 }, 'Test zero byte SourceBuffer.appendBuffer() call triggering an "end
ed" to "open" transition.'); |
| 157 | 157 |
| 158 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) | 158 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) |
| 159 { | 159 { |
| 160 test.failOnEvent(mediaElement, 'error'); | 160 test.failOnEvent(mediaElement, 'error'); |
| 161 | 161 |
| 162 test.expectEvent(sourceBuffer, "updatestart", "Append started."); | 162 test.expectEvent(sourceBuffer, 'updatestart', 'Append started.'); |
| 163 test.expectEvent(sourceBuffer, "abort", "Append aborted."); | 163 test.expectEvent(sourceBuffer, 'abort', 'Append aborted.'); |
| 164 test.expectEvent(sourceBuffer, "updateend", "Append ended."); | 164 test.expectEvent(sourceBuffer, 'updateend', 'Append ended.'); |
| 165 sourceBuffer.appendBuffer(mediaData); | 165 sourceBuffer.appendBuffer(mediaData); |
| 166 | 166 |
| 167 assert_true(sourceBuffer.updating, "updating attribute is true"); | 167 assert_true(sourceBuffer.updating, 'updating attribute is true'); |
| 168 | 168 |
| 169 test.expectEvent(mediaSource.activeSourceBuffers, "removesourcebuf
fer", "activeSourceBuffers"); | 169 test.expectEvent(mediaSource.activeSourceBuffers, 'removesourcebuf
fer', 'activeSourceBuffers'); |
| 170 test.expectEvent(mediaSource.sourceBuffers, "removesourcebuffer",
"sourceBuffers"); | 170 test.expectEvent(mediaSource.sourceBuffers, 'removesourcebuffer',
'sourceBuffers'); |
| 171 mediaSource.removeSourceBuffer(sourceBuffer); | 171 mediaSource.removeSourceBuffer(sourceBuffer); |
| 172 | 172 |
| 173 assert_false(sourceBuffer.updating, "updating attribute is false")
; | 173 assert_false(sourceBuffer.updating, 'updating attribute is false')
; |
| 174 | 174 |
| 175 assert_throws("InvalidStateError", | 175 assert_throws('InvalidStateError', |
| 176 function() { sourceBuffer.appendBuffer(mediaData); }, | 176 function() { sourceBuffer.appendBuffer(mediaData); }, |
| 177 "appendBuffer() throws an exception because it isn't attached
to the mediaSource anymore."); | 177 'appendBuffer() throws an exception because it isn\'t attached
to the mediaSource anymore.'); |
| 178 | 178 |
| 179 test.waitForExpectedEvents(function() | 179 test.waitForExpectedEvents(function() |
| 180 { | 180 { |
| 181 assert_false(sourceBuffer.updating, "updating attribute is fal
se"); | 181 assert_false(sourceBuffer.updating, 'updating attribute is fal
se'); |
| 182 test.done(); | 182 test.done(); |
| 183 }); | 183 }); |
| 184 }, "Test MediaSource.removeSourceBuffer() call during a pending append
Buffer()."); | 184 }, 'Test MediaSource.removeSourceBuffer() call during a pending append
Buffer().'); |
| 185 | 185 |
| 186 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) | 186 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) |
| 187 { | 187 { |
| 188 test.failOnEvent(mediaElement, 'error'); | 188 test.failOnEvent(mediaElement, 'error'); |
| 189 | 189 |
| 190 test.expectEvent(sourceBuffer, "updatestart", "Append started."); | 190 test.expectEvent(sourceBuffer, 'updatestart', 'Append started.'); |
| 191 test.expectEvent(sourceBuffer, "updateend", "Append ended."); | 191 test.expectEvent(sourceBuffer, 'updateend', 'Append ended.'); |
| 192 sourceBuffer.appendBuffer(mediaData); | 192 sourceBuffer.appendBuffer(mediaData); |
| 193 | 193 |
| 194 assert_true(sourceBuffer.updating, "updating attribute is true"); | 194 assert_true(sourceBuffer.updating, 'updating attribute is true'); |
| 195 | 195 |
| 196 assert_throws("InvalidStateError", | 196 assert_throws('InvalidStateError', |
| 197 function() { mediaSource.duration = 1.0; }, | 197 function() { mediaSource.duration = 1.0; }, |
| 198 "set duration throws an exception when updating attribute is t
rue."); | 198 'set duration throws an exception when updating attribute is t
rue.'); |
| 199 | 199 |
| 200 test.waitForExpectedEvents(function() | 200 test.waitForExpectedEvents(function() |
| 201 { | 201 { |
| 202 assert_false(sourceBuffer.updating, "updating attribute is fal
se"); | 202 assert_false(sourceBuffer.updating, 'updating attribute is fal
se'); |
| 203 test.done(); | 203 test.done(); |
| 204 }); | 204 }); |
| 205 }, "Test set MediaSource.duration during a pending appendBuffer() for
one of its SourceBuffers."); | 205 }, 'Test set MediaSource.duration during a pending appendBuffer() for
one of its SourceBuffers.'); |
| 206 | 206 |
| 207 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) | 207 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) |
| 208 { | 208 { |
| 209 test.failOnEvent(mediaElement, "error"); | 209 test.failOnEvent(mediaElement, 'error'); |
| 210 test.failOnEvent(mediaSource, "sourceended"); | 210 test.failOnEvent(mediaSource, 'sourceended'); |
| 211 | 211 |
| 212 test.expectEvent(sourceBuffer, "updatestart", "Append started."); | 212 test.expectEvent(sourceBuffer, 'updatestart', 'Append started.'); |
| 213 test.expectEvent(sourceBuffer, "updateend", "Append ended."); | 213 test.expectEvent(sourceBuffer, 'updateend', 'Append ended.'); |
| 214 sourceBuffer.appendBuffer(mediaData); | 214 sourceBuffer.appendBuffer(mediaData); |
| 215 | 215 |
| 216 assert_true(sourceBuffer.updating, "updating attribute is true"); | 216 assert_true(sourceBuffer.updating, 'updating attribute is true'); |
| 217 | 217 |
| 218 assert_throws("InvalidStateError", | 218 assert_throws('InvalidStateError', |
| 219 function() { mediaSource.endOfStream(); }, | 219 function() { mediaSource.endOfStream(); }, |
| 220 "endOfStream() throws an exception when updating attribute is
true."); | 220 'endOfStream() throws an exception when updating attribute is
true.'); |
| 221 | 221 |
| 222 assert_equals(mediaSource.readyState, "open"); | 222 assert_equals(mediaSource.readyState, 'open'); |
| 223 | 223 |
| 224 test.waitForExpectedEvents(function() | 224 test.waitForExpectedEvents(function() |
| 225 { | 225 { |
| 226 assert_false(sourceBuffer.updating, "updating attribute is fal
se"); | 226 assert_false(sourceBuffer.updating, 'updating attribute is fal
se'); |
| 227 assert_equals(mediaSource.readyState, "open"); | 227 assert_equals(mediaSource.readyState, 'open'); |
| 228 test.done(); | 228 test.done(); |
| 229 }); | 229 }); |
| 230 }, "Test MediaSource.endOfStream() during a pending appendBuffer() for
one of its SourceBuffers."); | 230 }, 'Test MediaSource.endOfStream() during a pending appendBuffer() for
one of its SourceBuffers.'); |
| 231 | 231 |
| 232 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) | 232 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) |
| 233 { | 233 { |
| 234 test.failOnEvent(mediaElement, 'error'); | 234 test.failOnEvent(mediaElement, 'error'); |
| 235 | 235 |
| 236 test.expectEvent(sourceBuffer, "updatestart", "Append started."); | 236 test.expectEvent(sourceBuffer, 'updatestart', 'Append started.'); |
| 237 test.expectEvent(sourceBuffer, "updateend", "Append ended."); | 237 test.expectEvent(sourceBuffer, 'updateend', 'Append ended.'); |
| 238 sourceBuffer.appendBuffer(mediaData); | 238 sourceBuffer.appendBuffer(mediaData); |
| 239 | 239 |
| 240 assert_true(sourceBuffer.updating, "updating attribute is true"); | 240 assert_true(sourceBuffer.updating, 'updating attribute is true'); |
| 241 | 241 |
| 242 assert_throws("InvalidStateError", | 242 assert_throws('InvalidStateError', |
| 243 function() { sourceBuffer.timestampOffset = 10.0; }, | 243 function() { sourceBuffer.timestampOffset = 10.0; }, |
| 244 "set timestampOffset throws an exception when updating attribu
te is true."); | 244 'set timestampOffset throws an exception when updating attribu
te is true.'); |
| 245 | 245 |
| 246 test.waitForExpectedEvents(function() | 246 test.waitForExpectedEvents(function() |
| 247 { | 247 { |
| 248 assert_false(sourceBuffer.updating, "updating attribute is fal
se"); | 248 assert_false(sourceBuffer.updating, 'updating attribute is fal
se'); |
| 249 test.done(); | 249 test.done(); |
| 250 }); | 250 }); |
| 251 }, "Test set SourceBuffer.timestampOffset during a pending appendBuffe
r()."); | 251 }, 'Test set SourceBuffer.timestampOffset during a pending appendBuffe
r().'); |
| 252 | 252 |
| 253 mediasource_test(function(test, mediaElement, mediaSource) | 253 mediasource_test(function(test, mediaElement, mediaSource) |
| 254 { | 254 { |
| 255 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.VID
EO_ONLY_TYPE); | 255 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.VID
EO_ONLY_TYPE); |
| 256 | 256 |
| 257 test.expectEvent(sourceBuffer, "updatestart", "Append started."); | 257 test.expectEvent(sourceBuffer, 'updatestart', 'Append started.'); |
| 258 test.expectEvent(sourceBuffer, "update", "Append success."); | 258 test.expectEvent(sourceBuffer, 'update', 'Append success.'); |
| 259 test.expectEvent(sourceBuffer, "updateend", "Append ended."); | 259 test.expectEvent(sourceBuffer, 'updateend', 'Append ended.'); |
| 260 sourceBuffer.appendBuffer(new Uint8Array(0)); | 260 sourceBuffer.appendBuffer(new Uint8Array(0)); |
| 261 | 261 |
| 262 assert_true(sourceBuffer.updating, "updating attribute is true"); | 262 assert_true(sourceBuffer.updating, 'updating attribute is true'); |
| 263 | 263 |
| 264 test.waitForExpectedEvents(function() | 264 test.waitForExpectedEvents(function() |
| 265 { | 265 { |
| 266 assert_false(sourceBuffer.updating, "updating attribute is fal
se"); | 266 assert_false(sourceBuffer.updating, 'updating attribute is fal
se'); |
| 267 test.done(); | 267 test.done(); |
| 268 }); | 268 }); |
| 269 }, "Test appending an empty ArrayBufferView."); | 269 }, 'Test appending an empty ArrayBufferView.'); |
| 270 | 270 |
| 271 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) | 271 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) |
| 272 { | 272 { |
| 273 test.failOnEvent(mediaElement, 'error'); | 273 test.failOnEvent(mediaElement, 'error'); |
| 274 | 274 |
| 275 test.expectEvent(sourceBuffer, "updatestart", "Append started."); | 275 test.expectEvent(sourceBuffer, 'updatestart', 'Append started.'); |
| 276 test.expectEvent(sourceBuffer, "update", "Append success."); | 276 test.expectEvent(sourceBuffer, 'update', 'Append success.'); |
| 277 test.expectEvent(sourceBuffer, "updateend", "Append ended."); | 277 test.expectEvent(sourceBuffer, 'updateend', 'Append ended.'); |
| 278 | 278 |
| 279 var arrayBufferView = new Uint8Array(mediaData); | 279 var arrayBufferView = new Uint8Array(mediaData); |
| 280 | 280 |
| 281 assert_equals(arrayBufferView.length, mediaData.length, "arrayBuff
erView.length before transfer."); | 281 assert_equals(arrayBufferView.length, mediaData.length, 'arrayBuff
erView.length before transfer.'); |
| 282 | 282 |
| 283 // Send the buffer as in a message so it gets neutered. | 283 // Send the buffer as in a message so it gets neutered. |
| 284 window.postMessage( "test", "*", [arrayBufferView.buffer]); | 284 window.postMessage( 'test', '*', [arrayBufferView.buffer]); |
| 285 | 285 |
| 286 assert_equals(arrayBufferView.length, 0, "arrayBufferView.length a
fter transfer."); | 286 assert_equals(arrayBufferView.length, 0, 'arrayBufferView.length a
fter transfer.'); |
| 287 | 287 |
| 288 sourceBuffer.appendBuffer(arrayBufferView); | 288 sourceBuffer.appendBuffer(arrayBufferView); |
| 289 | 289 |
| 290 assert_true(sourceBuffer.updating, "updating attribute is true"); | 290 assert_true(sourceBuffer.updating, 'updating attribute is true'); |
| 291 | 291 |
| 292 test.waitForExpectedEvents(function() | 292 test.waitForExpectedEvents(function() |
| 293 { | 293 { |
| 294 assert_false(sourceBuffer.updating, "updating attribute is fals
e"); | 294 assert_false(sourceBuffer.updating, 'updating attribute is fals
e'); |
| 295 test.done(); | 295 test.done(); |
| 296 }); | 296 }); |
| 297 }, "Test appending a neutered ArrayBufferView."); | 297 }, 'Test appending a neutered ArrayBufferView.'); |
| 298 | 298 |
| 299 mediasource_test(function(test, mediaElement, mediaSource) | 299 mediasource_test(function(test, mediaElement, mediaSource) |
| 300 { | 300 { |
| 301 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.VID
EO_ONLY_TYPE); | 301 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.VID
EO_ONLY_TYPE); |
| 302 | 302 |
| 303 test.expectEvent(sourceBuffer, "updatestart", "Append started."); | 303 test.expectEvent(sourceBuffer, 'updatestart', 'Append started.'); |
| 304 test.expectEvent(sourceBuffer, "update", "Append success."); | 304 test.expectEvent(sourceBuffer, 'update', 'Append success.'); |
| 305 test.expectEvent(sourceBuffer, "updateend", "Append ended."); | 305 test.expectEvent(sourceBuffer, 'updateend', 'Append ended.'); |
| 306 sourceBuffer.appendBuffer(new ArrayBuffer(0)); | 306 sourceBuffer.appendBuffer(new ArrayBuffer(0)); |
| 307 | 307 |
| 308 assert_true(sourceBuffer.updating, "updating attribute is true"); | 308 assert_true(sourceBuffer.updating, 'updating attribute is true'); |
| 309 | 309 |
| 310 test.waitForExpectedEvents(function() | 310 test.waitForExpectedEvents(function() |
| 311 { | 311 { |
| 312 assert_false(sourceBuffer.updating, "updating attribute is fal
se"); | 312 assert_false(sourceBuffer.updating, 'updating attribute is fal
se'); |
| 313 test.done(); | 313 test.done(); |
| 314 }); | 314 }); |
| 315 }, "Test appending an empty ArrayBuffer."); | 315 }, 'Test appending an empty ArrayBuffer.'); |
| 316 | 316 |
| 317 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) | 317 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) |
| 318 { | 318 { |
| 319 test.failOnEvent(mediaElement, 'error'); | 319 test.failOnEvent(mediaElement, 'error'); |
| 320 | 320 |
| 321 test.expectEvent(sourceBuffer, "updatestart", "Append started."); | 321 test.expectEvent(sourceBuffer, 'updatestart', 'Append started.'); |
| 322 test.expectEvent(sourceBuffer, "update", "Append success."); | 322 test.expectEvent(sourceBuffer, 'update', 'Append success.'); |
| 323 test.expectEvent(sourceBuffer, "updateend", "Append ended."); | 323 test.expectEvent(sourceBuffer, 'updateend', 'Append ended.'); |
| 324 | 324 |
| 325 var arrayBuffer = mediaData.buffer.slice(); | 325 var arrayBuffer = mediaData.buffer.slice(); |
| 326 | 326 |
| 327 assert_equals(arrayBuffer.byteLength, mediaData.buffer.byteLength,
"arrayBuffer.byteLength before transfer."); | 327 assert_equals(arrayBuffer.byteLength, mediaData.buffer.byteLength,
'arrayBuffer.byteLength before transfer.'); |
| 328 | 328 |
| 329 // Send the buffer as in a message so it gets neutered. | 329 // Send the buffer as in a message so it gets neutered. |
| 330 window.postMessage( "test", "*", [arrayBuffer]); | 330 window.postMessage( 'test', '*', [arrayBuffer]); |
| 331 | 331 |
| 332 assert_equals(arrayBuffer.byteLength, 0, "arrayBuffer.byteLength a
fter transfer."); | 332 assert_equals(arrayBuffer.byteLength, 0, 'arrayBuffer.byteLength a
fter transfer.'); |
| 333 | 333 |
| 334 sourceBuffer.appendBuffer(arrayBuffer); | 334 sourceBuffer.appendBuffer(arrayBuffer); |
| 335 | 335 |
| 336 assert_true(sourceBuffer.updating, "updating attribute is true"); | 336 assert_true(sourceBuffer.updating, 'updating attribute is true'); |
| 337 | 337 |
| 338 test.waitForExpectedEvents(function() | 338 test.waitForExpectedEvents(function() |
| 339 { | 339 { |
| 340 assert_false(sourceBuffer.updating, "updating attribute is fals
e"); | 340 assert_false(sourceBuffer.updating, 'updating attribute is fals
e'); |
| 341 test.done(); | 341 test.done(); |
| 342 }); | 342 }); |
| 343 }, "Test appending a neutered ArrayBuffer."); | 343 }, 'Test appending a neutered ArrayBuffer.'); |
| 344 | 344 |
| 345 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) | 345 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) |
| 346 { | 346 { |
| 347 var initSegment = MediaSourceUtil.extractSegmentData(mediaData, se
gmentInfo.init); |
| 348 var halfIndex = (initSegment.length + 1) / 2; |
| 349 var partialInitSegment = initSegment.subarray(0, halfIndex); |
| 350 var remainingInitSegment = initSegment.subarray(halfIndex); |
| 351 var mediaSegment = MediaSourceUtil.extractSegmentData(mediaData, s
egmentInfo.media[0]); |
| 352 |
| 353 test.expectEvent(sourceBuffer, 'updateend', 'partialInitSegment ap
pend ended.'); |
| 354 sourceBuffer.appendBuffer(partialInitSegment); |
| 355 |
| 356 test.waitForExpectedEvents(function() |
| 357 { |
| 358 assert_equals(mediaElement.readyState, mediaElement.HAVE_NOTHI
NG); |
| 359 assert_equals(mediaSource.duration, Number.NaN); |
| 360 test.expectEvent(sourceBuffer, 'updateend', 'remainingInitSegm
ent append ended.'); |
| 361 test.expectEvent(mediaElement, 'loadedmetadata', 'loadedmetada
ta event received.'); |
| 362 sourceBuffer.appendBuffer(remainingInitSegment); |
| 363 }); |
| 364 |
| 365 test.waitForExpectedEvents(function() |
| 366 { |
| 367 assert_equals(mediaElement.readyState, mediaElement.HAVE_METAD
ATA); |
| 368 assert_equals(mediaSource.duration, segmentInfo.durationInInit
Segment); |
| 369 test.expectEvent(sourceBuffer, 'updateend', 'mediaSegment appe
nd ended.'); |
| 370 test.expectEvent(mediaElement, 'loadeddata', 'loadeddata fired
.'); |
| 371 sourceBuffer.appendBuffer(mediaSegment); |
| 372 }); |
| 373 |
| 374 test.waitForExpectedEvents(function() |
| 375 { |
| 376 assert_greater_than_equal(mediaElement.readyState, mediaElemen
t.HAVE_CURRENT_DATA); |
| 377 assert_equals(sourceBuffer.updating, false); |
| 378 assert_equals(mediaSource.readyState, 'open'); |
| 379 test.done(); |
| 380 }); |
| 381 }, 'Test appendBuffer with partial init segments.'); |
| 382 |
| 383 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) |
| 384 { |
| 385 var initSegment = MediaSourceUtil.extractSegmentData(mediaData, se
gmentInfo.init); |
| 386 var mediaSegment = MediaSourceUtil.extractSegmentData(mediaData, s
egmentInfo.media[0]); |
| 387 var halfIndex = (mediaSegment.length + 1) / 2; |
| 388 var partialMediaSegment = mediaSegment.subarray(0, halfIndex); |
| 389 var remainingMediaSegment = mediaSegment.subarray(halfIndex); |
| 390 |
| 391 test.expectEvent(sourceBuffer, 'updateend', 'InitSegment append en
ded.'); |
| 392 test.expectEvent(mediaElement, 'loadedmetadata', 'loadedmetadata d
one.'); |
| 393 sourceBuffer.appendBuffer(initSegment); |
| 394 |
| 395 test.waitForExpectedEvents(function() |
| 396 { |
| 397 assert_equals(mediaElement.readyState, mediaElement.HAVE_METAD
ATA); |
| 398 assert_equals(mediaSource.duration, segmentInfo.durationInInit
Segment); |
| 399 test.expectEvent(sourceBuffer, 'updateend', 'partial media seg
ment append ended.'); |
| 400 sourceBuffer.appendBuffer(partialMediaSegment); |
| 401 }); |
| 402 |
| 403 test.waitForExpectedEvents(function() |
| 404 { |
| 405 test.expectEvent(sourceBuffer, 'updateend', 'mediaSegment appe
nd ended.'); |
| 406 test.expectEvent(mediaElement, 'loadeddata', 'loadeddata fired
.'); |
| 407 sourceBuffer.appendBuffer(remainingMediaSegment); |
| 408 }); |
| 409 |
| 410 test.waitForExpectedEvents(function() |
| 411 { |
| 412 assert_greater_than_equal(mediaElement.readyState, mediaElemen
t.HAVE_CURRENT_DATA); |
| 413 assert_equals(mediaSource.readyState, 'open'); |
| 414 assert_equals(sourceBuffer.updating, false); |
| 415 test.done(); |
| 416 }); |
| 417 }, 'Test appendBuffer with partial media segments.'); |
| 418 |
| 419 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) |
| 420 { |
| 347 var initSegment = MediaSourceUtil.extractSegmentData(mediaData, se
gmentInfo.init); | 421 var initSegment = MediaSourceUtil.extractSegmentData(mediaData, se
gmentInfo.init); |
| 348 var partialInitSegment = initSegment.subarray(0, initSegment.lengt
h / 2); | 422 var partialInitSegment = initSegment.subarray(0, initSegment.lengt
h / 2); |
| 349 var mediaSegment = MediaSourceUtil.extractSegmentData(mediaData, s
egmentInfo.media[0]); | 423 var mediaSegment = MediaSourceUtil.extractSegmentData(mediaData, s
egmentInfo.media[0]); |
| 350 | 424 |
| 351 test.expectEvent(sourceBuffer, "updateend", "partialInitSegment ap
pend ended."); | 425 test.expectEvent(sourceBuffer, 'updateend', 'partialInitSegment ap
pend ended.'); |
| 352 sourceBuffer.appendBuffer(partialInitSegment); | 426 sourceBuffer.appendBuffer(partialInitSegment); |
| 353 | 427 |
| 354 test.waitForExpectedEvents(function() | 428 test.waitForExpectedEvents(function() |
| 355 { | 429 { |
| 356 // Call abort to reset the parser. | 430 // Call abort to reset the parser. |
| 357 sourceBuffer.abort(); | 431 sourceBuffer.abort(); |
| 358 | 432 |
| 359 // Append the full intiialization segment. | 433 // Append the full intiialization segment. |
| 360 test.expectEvent(sourceBuffer, "updateend", "initSegment appen
d ended."); | 434 test.expectEvent(sourceBuffer, 'updateend', 'initSegment appen
d ended.'); |
| 361 sourceBuffer.appendBuffer(initSegment); | 435 sourceBuffer.appendBuffer(initSegment); |
| 362 }); | 436 }); |
| 363 | 437 |
| 364 test.waitForExpectedEvents(function() | 438 test.waitForExpectedEvents(function() |
| 365 { | 439 { |
| 366 test.expectEvent(sourceBuffer, "updateend", "mediaSegment appe
nd ended."); | 440 test.expectEvent(sourceBuffer, 'updateend', 'mediaSegment appe
nd ended.'); |
| 367 test.expectEvent(mediaElement, "loadeddata", "loadeddata fired
."); | 441 test.expectEvent(mediaElement, 'loadeddata', 'loadeddata fired
.'); |
| 368 sourceBuffer.appendBuffer(mediaSegment); | 442 sourceBuffer.appendBuffer(mediaSegment); |
| 369 }); | 443 }); |
| 370 | 444 |
| 371 test.waitForExpectedEvents(function() | 445 test.waitForExpectedEvents(function() |
| 372 { | 446 { |
| 373 test.done(); | 447 test.done(); |
| 374 }); | 448 }); |
| 375 }, "Test abort in the middle of an initialization segment."); | 449 }, 'Test abort in the middle of an initialization segment.'); |
| 376 | 450 |
| 377 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) | 451 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) |
| 378 { | 452 { |
| 379 var initSegment = MediaSourceUtil.extractSegmentData(mediaData, se
gmentInfo.init); | 453 var initSegment = MediaSourceUtil.extractSegmentData(mediaData, se
gmentInfo.init); |
| 380 var mediaSegment = MediaSourceUtil.extractSegmentData(mediaData, s
egmentInfo.media[0]); | 454 var mediaSegment = MediaSourceUtil.extractSegmentData(mediaData, s
egmentInfo.media[0]); |
| 381 var partialMediaSegment = mediaSegment.subarray(0, 3 * mediaSegmen
t.length / 4); | 455 var partialMediaSegment = mediaSegment.subarray(0, 3 * mediaSegmen
t.length / 4); |
| 382 var partialBufferedRanges = null; | 456 var partialBufferedRanges = null; |
| 383 | 457 |
| 384 test.expectEvent(sourceBuffer, "updateend", "initSegment append en
ded."); | 458 test.expectEvent(sourceBuffer, 'updateend', 'initSegment append en
ded.'); |
| 385 sourceBuffer.appendBuffer(initSegment); | 459 sourceBuffer.appendBuffer(initSegment); |
| 386 | 460 |
| 387 test.waitForExpectedEvents(function() | 461 test.waitForExpectedEvents(function() |
| 388 { | 462 { |
| 389 test.expectEvent(sourceBuffer, "updateend", "partialMediaSegme
nt append ended."); | 463 test.expectEvent(sourceBuffer, 'updateend', 'partialMediaSegme
nt append ended.'); |
| 390 sourceBuffer.appendBuffer(partialMediaSegment); | 464 sourceBuffer.appendBuffer(partialMediaSegment); |
| 391 }); | 465 }); |
| 392 | 466 |
| 393 test.waitForExpectedEvents(function() | 467 test.waitForExpectedEvents(function() |
| 394 { | 468 { |
| 395 // Call abort to reset the parser. | 469 // Call abort to reset the parser. |
| 396 sourceBuffer.abort(); | 470 sourceBuffer.abort(); |
| 397 | 471 |
| 398 // Keep a copy of the buffered ranges before we append the who
le media segment. | 472 // Keep a copy of the buffered ranges before we append the who
le media segment. |
| 399 partialBufferedRanges = sourceBuffer.buffered; | 473 partialBufferedRanges = sourceBuffer.buffered; |
| 400 assert_equals(partialBufferedRanges.length, 1, "partialBuffere
dRanges has 1 range"); | 474 assert_equals(partialBufferedRanges.length, 1, 'partialBuffere
dRanges has 1 range'); |
| 401 | 475 |
| 402 // Append the full media segment. | 476 // Append the full media segment. |
| 403 test.expectEvent(sourceBuffer, "updateend", "mediaSegment appe
nd ended."); | 477 test.expectEvent(sourceBuffer, 'updateend', 'mediaSegment appe
nd ended.'); |
| 404 sourceBuffer.appendBuffer(mediaSegment); | 478 sourceBuffer.appendBuffer(mediaSegment); |
| 405 }); | 479 }); |
| 406 | 480 |
| 407 test.waitForExpectedEvents(function() | 481 test.waitForExpectedEvents(function() |
| 408 { | 482 { |
| 409 test.expectEvent(sourceBuffer, "updateend", "Append ended."); | 483 test.expectEvent(sourceBuffer, 'updateend', 'Append ended.'); |
| 410 | 484 |
| 411 assert_equals(sourceBuffer.buffered.length, 1, "sourceBuffer.b
uffered has 1 range"); | 485 assert_equals(sourceBuffer.buffered.length, 1, 'sourceBuffer.b
uffered has 1 range'); |
| 412 assert_equals(sourceBuffer.buffered.length, partialBufferedRan
ges.length, "sourceBuffer.buffered and partialBufferedRanges are the same length
."); | 486 assert_equals(sourceBuffer.buffered.length, partialBufferedRan
ges.length, 'sourceBuffer.buffered and partialBufferedRanges are the same length
.'); |
| 413 assert_equals(sourceBuffer.buffered.start(0), partialBufferedR
anges.start(0), "sourceBuffer.buffered and partialBufferedRanges start times mat
ch."); | 487 assert_equals(sourceBuffer.buffered.start(0), partialBufferedR
anges.start(0), 'sourceBuffer.buffered and partialBufferedRanges start times mat
ch.'); |
| 414 assert_greater_than(sourceBuffer.buffered.end(0), partialBuffe
redRanges.end(0), "sourceBuffer.buffered has a higher end time than partialBuffe
redRanges."); | 488 assert_greater_than(sourceBuffer.buffered.end(0), partialBuffe
redRanges.end(0), 'sourceBuffer.buffered has a higher end time than partialBuffe
redRanges.'); |
| 415 test.done(); | 489 test.done(); |
| 416 }); | 490 }); |
| 417 }, "Test abort in the middle of a media segment."); | 491 }, 'Test abort in the middle of a media segment.'); |
| 492 |
| 493 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) |
| 494 { |
| 495 test.expectEvent(mediaSource.sourceBuffers, 'removesourcebuffer',
'SourceBuffer removed.'); |
| 496 mediaSource.removeSourceBuffer(sourceBuffer); |
| 497 test.waitForExpectedEvents(function() |
| 498 { |
| 499 assert_throws('InvalidStateError', |
| 500 function() { sourceBuffer.abort(); }, |
| 501 'sourceBuffer.abort() throws an exception for InvalidState
Error.'); |
| 502 |
| 503 test.done(); |
| 504 }); |
| 505 }, 'Test abort after removing sourcebuffer.'); |
| 418 | 506 |
| 507 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) |
| 508 { |
| 509 test.expectEvent(mediaSource, 'sourceended', 'source ended'); |
| 510 |
| 511 assert_equals(mediaSource.readyState, 'open', 'readyState is open.
'); |
| 512 mediaSource.endOfStream(); |
| 513 |
| 514 test.waitForExpectedEvents(function() |
| 515 { |
| 516 assert_equals(mediaSource.readyState, 'ended', 'readyState is
ended.'); |
| 517 assert_throws('InvalidStateError', |
| 518 function() { sourceBuffer.abort(); }, |
| 519 'sourceBuffer.abort() throws an exception for InvalidState
Error.'); |
| 520 test.done(); |
| 521 }); |
| 522 |
| 523 }, 'Test abort after readyState is ended.'); |
| 524 |
| 525 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) |
| 526 { |
| 527 test.expectEvent(sourceBuffer, 'updatestart', 'Append started.'); |
| 528 test.expectEvent(sourceBuffer, 'updateend', 'Append ended.'); |
| 529 sourceBuffer.appendWindowStart = 1; |
| 530 sourceBuffer.appendWindowEnd = 100; |
| 531 sourceBuffer.appendBuffer(mediaData); |
| 532 |
| 533 test.waitForExpectedEvents(function() |
| 534 { |
| 535 assert_false(sourceBuffer.updating, 'updating attribute is fal
se'); |
| 536 sourceBuffer.abort(); |
| 537 assert_equals(sourceBuffer.appendWindowStart, 0, 'appendWindow
Start is reset to 0'); |
| 538 assert_equals(sourceBuffer.appendWindowEnd, Number.POSITIVE_IN
FINITY, |
| 539 'appendWindowEnd is reset to +INFINITY'); |
| 540 test.done(); |
| 541 }); |
| 542 }, 'Test abort after appendBuffer update ends.'); |
| 543 |
| 419 mediasource_test(function(test, mediaElement, mediaSource) | 544 mediasource_test(function(test, mediaElement, mediaSource) |
| 420 { | 545 { |
| 421 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.VID
EO_ONLY_TYPE); | 546 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.VID
EO_ONLY_TYPE); |
| 422 | 547 |
| 423 test.expectEvent(sourceBuffer, "updatestart", "Append started."); | 548 test.expectEvent(sourceBuffer, 'updatestart', 'Append started.'); |
| 424 test.expectEvent(sourceBuffer, "update", "Append success."); | 549 test.expectEvent(sourceBuffer, 'update', 'Append success.'); |
| 425 test.expectEvent(sourceBuffer, "updateend", "Append ended."); | 550 test.expectEvent(sourceBuffer, 'updateend', 'Append ended.'); |
| 426 | 551 |
| 427 assert_throws( { name: "TypeError"} , | 552 assert_throws( { name: 'TypeError'} , |
| 428 function() { sourceBuffer.appendBuffer(null); }, | 553 function() { sourceBuffer.appendBuffer(null); }, |
| 429 "appendBuffer(null) throws an exception."); | 554 'appendBuffer(null) throws an exception.'); |
| 430 test.done(); | 555 test.done(); |
| 431 }, "Test appending null."); | 556 }, 'Test appending null.'); |
| 432 | 557 |
| 433 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) | 558 mediasource_testafterdataloaded(function(test, mediaElement, mediaSour
ce, segmentInfo, sourceBuffer, mediaData) |
| 434 { | 559 { |
| 435 mediaSource.removeSourceBuffer(sourceBuffer); | 560 mediaSource.removeSourceBuffer(sourceBuffer); |
| 436 | 561 |
| 437 assert_throws( { name: "InvalidStateError"} , | 562 assert_throws( { name: 'InvalidStateError'} , |
| 438 function() { sourceBuffer.appendBuffer(mediaData); }, | 563 function() { sourceBuffer.appendBuffer(mediaData); }, |
| 439 "appendBuffer() throws an exception when called after removeSo
urceBuffer()."); | 564 'appendBuffer() throws an exception when called after removeSo
urceBuffer().'); |
| 440 test.done(); | 565 test.done(); |
| 441 }, "Test appending after removeSourceBuffer()."); | 566 }, 'Test appending after removeSourceBuffer().'); |
| 442 </script> | 567 </script> |
| 443 </body> | 568 </body> |
| 444 </html> | 569 </html> |
| OLD | NEW |