Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(537)

Side by Side Diff: LayoutTests/http/tests/media/media-source/mediasource-append-legacystream.html

Issue 552943002: MSE: Start letting SourceBuffer begin to do initialization segment received algorithm (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated to be part 1 of a 3-sided blink->chromium->blink set of changes Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 function createMediaXHR() { 12 function createMediaXHR() {
13 var mediaURL = MediaSourceUtil.SEGMENT_INFO.url; 13 var mediaURL = MediaSourceUtil.SEGMENT_INFO.url;
14 var xhr = new XMLHttpRequest(); 14 var xhr = new XMLHttpRequest();
15 xhr.open('GET', mediaURL, true); 15 xhr.open('GET', mediaURL, true);
16 xhr.responseType = 'legacystream'; 16 xhr.responseType = 'legacystream';
17 17
18 assert_equals(xhr.responseType, "legacystream", "Verify response t ype was set."); 18 assert_equals(xhr.responseType, 'legacystream', 'Verify response t ype was set.');
acolwell GONE FROM CHROMIUM 2014/09/10 17:16:26 nit: Please don't update do the " -> ' conversion
wolenetz 2014/09/10 21:18:21 Done.
19 19
20 return xhr; 20 return xhr;
21 } 21 }
22 22
23 function waitForLoadingState(test, xhr, callback) 23 function waitForLoadingState(test, xhr, callback)
24 { 24 {
25 var eventHandler = test.step_func(function(e) 25 var eventHandler = test.step_func(function(e)
26 { 26 {
27 if (e.target.readyState < e.target.LOADING) 27 if (e.target.readyState < e.target.LOADING)
28 return; 28 return;
29 xhr.removeEventListener('readystatechange', eventHandler); 29 xhr.removeEventListener('readystatechange', eventHandler);
30 callback(); 30 callback();
31 }); 31 });
32 xhr.addEventListener('readystatechange', eventHandler); 32 xhr.addEventListener('readystatechange', eventHandler);
33 } 33 }
34 34
35 function appendStream(test, sourceBuffer, callback) 35 function appendStream(test, sourceBuffer, callback)
36 { 36 {
37 var xhr = createMediaXHR(); 37 var xhr = createMediaXHR();
38 test.failOnEvent(xhr, 'error'); 38 test.failOnEvent(xhr, 'error');
39 39
40 xhr.send(); 40 xhr.send();
41 41
42 waitForLoadingState(test, xhr, function() 42 waitForLoadingState(test, xhr, function()
43 { 43 {
44 assert_true(xhr.response != null, "xhr.response is not null"); 44 assert_true(xhr.response != null, 'xhr.response is not null');
45 45
46 test.expectEvent(xhr, "load", "XHR load completed."); 46 test.expectEvent(xhr, 'load', 'XHR load completed.');
47 test.expectEvent(xhr, "loadend", "XHR load ended."); 47 test.expectEvent(xhr, 'loadend', 'XHR load ended.');
48 48
49 test.expectEvent(sourceBuffer, "updatestart", "Append started. "); 49 test.expectEvent(sourceBuffer, 'updatestart', 'Append started. ');
50 test.expectEvent(sourceBuffer, "update", "Append success."); 50 test.expectEvent(sourceBuffer, 'update', 'Append success.');
51 test.expectEvent(sourceBuffer, "updateend", "Append ended."); 51 test.expectEvent(sourceBuffer, 'updateend', 'Append ended.');
52 sourceBuffer.appendStream(xhr.response); 52 sourceBuffer.appendStream(xhr.response);
53 53
54 assert_true(sourceBuffer.updating, "updating attribute is true "); 54 assert_true(sourceBuffer.updating, 'updating attribute is true ');
55 55
56 test.waitForExpectedEvents(function() 56 test.waitForExpectedEvents(function()
57 { 57 {
58 assert_false(sourceBuffer.updating, "updating attribute is false"); 58 assert_false(sourceBuffer.updating, 'updating attribute is false');
59 callback(); 59 callback();
60 }); 60 });
61 }); 61 });
62 } 62 }
63 63
64 function appendStreamTest(callback, description) 64 function appendStreamTest(callback, description)
65 { 65 {
66 mediasource_test(function(test, mediaElement, mediaSource) 66 mediasource_test(function(test, mediaElement, mediaSource)
67 { 67 {
68 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil .SEGMENT_INFO.type); 68 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil .SEGMENT_INFO.type);
69 test.failOnEvent(mediaElement, 'error'); 69 test.failOnEvent(mediaElement, 'error');
70 callback(test, mediaElement, mediaSource, sourceBuffer); 70 callback(test, mediaElement, mediaSource, sourceBuffer);
71 }, description); 71 }, description);
72 } 72 }
73 73
74 appendStreamTest(function(test, mediaElement, mediaSource, sourceBuffe r) 74 appendStreamTest(function(test, mediaElement, mediaSource, sourceBuffe r)
75 { 75 {
76 test.expectEvent(mediaElement, "canplaythrough", "Reached HAVE_ENO UGH_DATA."); 76 test.expectEvent(mediaElement, 'canplaythrough', 'Reached HAVE_ENO UGH_DATA.');
77 appendStream(test, sourceBuffer, function() { test.done(); }); 77 appendStream(test, sourceBuffer, function() { test.done(); });
78 }, "Test SourceBuffer.appendStream() event dispatching."); 78 }, 'Test SourceBuffer.appendStream() event dispatching.');
79 79
80 appendStreamTest(function(test, mediaElement, mediaSource, sourceBuffe r) 80 appendStreamTest(function(test, mediaElement, mediaSource, sourceBuffe r)
81 { 81 {
82 var xhr = createMediaXHR(); 82 var xhr = createMediaXHR();
83 test.failOnEvent(xhr, 'error'); 83 test.failOnEvent(xhr, 'error');
84 xhr.send(); 84 xhr.send();
85 waitForLoadingState(test, xhr, function() 85 waitForLoadingState(test, xhr, function()
86 { 86 {
87 var xhr2 = createMediaXHR(); 87 var xhr2 = createMediaXHR();
88 xhr2.send(); 88 xhr2.send();
89 waitForLoadingState(test, xhr2, function() 89 waitForLoadingState(test, xhr2, function()
90 { 90 {
91 test.expectEvent(sourceBuffer, "updatestart", "Append star ted."); 91 test.expectEvent(sourceBuffer, 'updatestart', 'Append star ted.');
92 test.expectEvent(sourceBuffer, "update", "Append success." ); 92 test.expectEvent(sourceBuffer, 'update', 'Append success.' );
93 test.expectEvent(sourceBuffer, "updateend", "Append ended. "); 93 test.expectEvent(sourceBuffer, 'updateend', 'Append ended. ');
94 sourceBuffer.appendStream(xhr.response); 94 sourceBuffer.appendStream(xhr.response);
95 95
96 assert_true(sourceBuffer.updating, "updating attribute is true"); 96 assert_true(sourceBuffer.updating, 'updating attribute is true');
97 97
98 assert_throws("InvalidStateError", 98 assert_throws('InvalidStateError',
99 function() { sourceBuffer.appendStream(xhr2.response); }, 99 function() { sourceBuffer.appendStream(xhr2.response); },
100 "appendStream() throws an exception because there is a pending append."); 100 'appendStream() throws an exception because there is a pending append.');
101 101
102 assert_true(sourceBuffer.updating, "updating attribute is true"); 102 assert_true(sourceBuffer.updating, 'updating attribute is true');
103 103
104 test.waitForExpectedEvents(function() 104 test.waitForExpectedEvents(function()
105 { 105 {
106 assert_false(sourceBuffer.updating, "updating attribut e is false"); 106 assert_false(sourceBuffer.updating, 'updating attribut e is false');
107 test.done(); 107 test.done();
108 }); 108 });
109 }); 109 });
110 }); 110 });
111 }, "Test SourceBuffer.appendStream() call during a pending appendStrea m()."); 111 }, 'Test SourceBuffer.appendStream() call during a pending appendStrea m().');
112 112
113 appendStreamTest(function(test, mediaElement, mediaSource, sourceBuffe r) 113 appendStreamTest(function(test, mediaElement, mediaSource, sourceBuffe r)
114 { 114 {
115 var xhr = createMediaXHR(); 115 var xhr = createMediaXHR();
116 test.failOnEvent(xhr, 'error'); 116 test.failOnEvent(xhr, 'error');
117 xhr.send(); 117 xhr.send();
118 waitForLoadingState(test, xhr, function() 118 waitForLoadingState(test, xhr, function()
119 { 119 {
120 test.expectEvent(sourceBuffer, "updatestart", "Append started. "); 120 test.expectEvent(sourceBuffer, 'updatestart', 'Append started. ');
121 test.expectEvent(sourceBuffer, "abort", "Append aborted."); 121 test.expectEvent(sourceBuffer, 'abort', 'Append aborted.');
122 test.expectEvent(sourceBuffer, "updateend", "Append ended."); 122 test.expectEvent(sourceBuffer, 'updateend', 'Append ended.');
123 sourceBuffer.appendStream(xhr.response); 123 sourceBuffer.appendStream(xhr.response);
124 124
125 assert_true(sourceBuffer.updating, "updating attribute is true "); 125 assert_true(sourceBuffer.updating, 'updating attribute is true ');
126 126
127 sourceBuffer.abort(); 127 sourceBuffer.abort();
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.waitForExpectedEvents(function() 131 test.waitForExpectedEvents(function()
132 { 132 {
133 assert_false(sourceBuffer.updating, "updating attribute is false"); 133 assert_false(sourceBuffer.updating, 'updating attribute is false');
134 test.done(); 134 test.done();
135 }); 135 });
136 }); 136 });
137 }, "Test SourceBuffer.abort() call during a pending appendStream()."); 137 }, 'Test SourceBuffer.abort() call during a pending appendStream().');
138 138
139 appendStreamTest(function(test, mediaElement, mediaSource, sourceBuffe r) 139 appendStreamTest(function(test, mediaElement, mediaSource, sourceBuffe r)
140 { 140 {
141 appendStream(test, sourceBuffer, function() 141 appendStream(test, sourceBuffer, function()
142 { 142 {
143 test.expectEvent(mediaSource, "sourceended", "MediaSource sour ceended event"); 143 test.expectEvent(mediaSource, 'sourceended', 'MediaSource sour ceended event');
144 mediaSource.endOfStream(); 144 mediaSource.endOfStream();
145 assert_equals(mediaSource.readyState, "ended", "MediaSource re adyState is 'ended'"); 145 assert_equals(mediaSource.readyState, 'ended', 'MediaSource re adyState is "ended"');
146 146
147 test.waitForExpectedEvents(function() 147 test.waitForExpectedEvents(function()
148 { 148 {
149 assert_equals(mediaSource.readyState, "ended", "MediaSourc e readyState is 'ended'"); 149 assert_equals(mediaSource.readyState, 'ended', 'MediaSourc e readyState is "ended"');
150 150
151 var xhr2 = createMediaXHR(); 151 var xhr2 = createMediaXHR();
152 xhr2.send(); 152 xhr2.send();
153 waitForLoadingState(test, xhr2, function() 153 waitForLoadingState(test, xhr2, function()
154 { 154 {
155 test.expectEvent(mediaSource, "sourceopen", "MediaSour ce sourceopen event"); 155 test.expectEvent(mediaSource, 'sourceopen', 'MediaSour ce sourceopen event');
156 test.expectEvent(sourceBuffer, "updatestart", "Append started."); 156 test.expectEvent(sourceBuffer, 'updatestart', 'Append started.');
157 test.expectEvent(sourceBuffer, "update", "Append succe ss."); 157 test.expectEvent(sourceBuffer, 'update', 'Append succe ss.');
158 test.expectEvent(sourceBuffer, "updateend", "Append en ded."); 158 test.expectEvent(sourceBuffer, 'updateend', 'Append en ded.');
159 sourceBuffer.appendStream(xhr2.response); 159 sourceBuffer.appendStream(xhr2.response);
160 160
161 assert_equals(mediaSource.readyState, "open", "MediaSo urce readyState is 'open'"); 161 assert_equals(mediaSource.readyState, 'open', 'MediaSo urce readyState is "open"');
162 assert_true(sourceBuffer.updating, "updating attribute is true"); 162 assert_true(sourceBuffer.updating, 'updating attribute is true');
163 163
164 test.waitForExpectedEvents(function() 164 test.waitForExpectedEvents(function()
165 { 165 {
166 assert_equals(mediaSource.readyState, "open", "Med iaSource readyState is 'open'"); 166 assert_equals(mediaSource.readyState, 'open', 'Med iaSource readyState is "open"');
167 assert_false(sourceBuffer.updating, "updating attr ibute is false"); 167 assert_false(sourceBuffer.updating, 'updating attr ibute is false');
168 test.done(); 168 test.done();
169 }); 169 });
170 }); 170 });
171 }); 171 });
172 }); 172 });
173 }, "Test SourceBuffer.appendStream() triggering an 'ended' to 'open' t ransition."); 173 }, 'Test SourceBuffer.appendStream() triggering an "ended" to "open" t ransition.');
174 174
175 appendStreamTest(function(test, mediaElement, mediaSource, sourceBuffe r) 175 appendStreamTest(function(test, mediaElement, mediaSource, sourceBuffe r)
176 { 176 {
177 var xhr = createMediaXHR(); 177 var xhr = createMediaXHR();
178 test.failOnEvent(xhr, 'error'); 178 test.failOnEvent(xhr, 'error');
179 xhr.send(); 179 xhr.send();
180 waitForLoadingState(test, xhr, function() 180 waitForLoadingState(test, xhr, function()
181 { 181 {
182 test.expectEvent(sourceBuffer, "updatestart", "Append started. "); 182 test.expectEvent(sourceBuffer, 'updatestart', 'Append started. ');
183 test.expectEvent(sourceBuffer, "abort", "Append aborted."); 183 test.expectEvent(sourceBuffer, 'abort', 'Append aborted.');
184 test.expectEvent(sourceBuffer, "updateend", "Append ended."); 184 test.expectEvent(sourceBuffer, 'updateend', 'Append ended.');
185 sourceBuffer.appendStream(xhr.response); 185 sourceBuffer.appendStream(xhr.response);
186 186
187 assert_true(sourceBuffer.updating, "updating attribute is true "); 187 assert_true(sourceBuffer.updating, 'updating attribute is true ');
188 assert_equals(mediaSource.activeSourceBuffers.length, 0, 'acti veSourceBuffers.length');
188 189
189 test.expectEvent(mediaSource.activeSourceBuffers, "removesourc ebuffer", "activeSourceBuffers"); 190 test.expectEvent(mediaSource.sourceBuffers, 'removesourcebuffe r', 'sourceBuffers');
190 test.expectEvent(mediaSource.sourceBuffers, "removesourcebuffe r", "sourceBuffers");
191 mediaSource.removeSourceBuffer(sourceBuffer); 191 mediaSource.removeSourceBuffer(sourceBuffer);
192 192
193 assert_false(sourceBuffer.updating, "updating attribute is fal se"); 193 assert_false(sourceBuffer.updating, 'updating attribute is fal se');
194 194
195 var xhr2 = createMediaXHR(); 195 var xhr2 = createMediaXHR();
196 test.failOnEvent(xhr2, 'error'); 196 test.failOnEvent(xhr2, 'error');
197 xhr2.send(); 197 xhr2.send();
198 waitForLoadingState(test, xhr2, function() 198 waitForLoadingState(test, xhr2, function()
199 { 199 {
200 assert_throws("InvalidStateError", 200 assert_throws('InvalidStateError',
201 function() { sourceBuffer.appendStream(xhr2.response); }, 201 function() { sourceBuffer.appendStream(xhr2.response); },
202 "appendStream() throws an exception because it isn't a ttached to the mediaSource anymore."); 202 'appendStream() throws an exception because it is not attached to the mediaSource anymore.');
203 203
204 test.waitForExpectedEvents(function() 204 test.waitForExpectedEvents(function()
205 { 205 {
206 assert_false(sourceBuffer.updating, "updating attribut e is false"); 206 assert_false(sourceBuffer.updating, 'updating attribut e is false');
207 test.done(); 207 test.done();
208 }); 208 });
209 }); 209 });
210 }); 210 });
211 }, "Test MediaSource.removeSourceBuffer() call during a pending append Stream()."); 211 }, 'Test MediaSource.removeSourceBuffer() call during a pending append Stream().');
212 212
213 appendStreamTest(function(test, mediaElement, mediaSource, sourceBuffe r) 213 appendStreamTest(function(test, mediaElement, mediaSource, sourceBuffe r)
214 { 214 {
215 var xhr = createMediaXHR(); 215 var xhr = createMediaXHR();
216 test.failOnEvent(xhr, 'error'); 216 test.failOnEvent(xhr, 'error');
217 xhr.send(); 217 xhr.send();
218 waitForLoadingState(test, xhr, function() 218 waitForLoadingState(test, xhr, function()
219 { 219 {
220 test.expectEvent(sourceBuffer, "updatestart", "Append started. "); 220 test.expectEvent(sourceBuffer, 'updatestart', 'Append started. ');
221 test.expectEvent(sourceBuffer, "update", "Append success."); 221 test.expectEvent(sourceBuffer, 'update', 'Append success.');
222 test.expectEvent(sourceBuffer, "updateend", "Append ended."); 222 test.expectEvent(sourceBuffer, 'updateend', 'Append ended.');
223 sourceBuffer.appendStream(xhr.response); 223 sourceBuffer.appendStream(xhr.response);
224 224
225 assert_true(sourceBuffer.updating, "updating attribute is true "); 225 assert_true(sourceBuffer.updating, 'updating attribute is true ');
226 226
227 assert_throws("InvalidStateError", 227 assert_throws('InvalidStateError',
228 function() { mediaSource.duration = 1.0; }, 228 function() { mediaSource.duration = 1.0; },
229 "set duration throws an exception when updating attribute is true."); 229 'set duration throws an exception when updating attribute is true.');
230 230
231 test.waitForExpectedEvents(function() 231 test.waitForExpectedEvents(function()
232 { 232 {
233 assert_false(sourceBuffer.updating, "updating attribute is false"); 233 assert_false(sourceBuffer.updating, 'updating attribute is false');
234 test.done(); 234 test.done();
235 }); 235 });
236 }); 236 });
237 }, "Test setting MediaSource.duration during a pending appendStream() for one of its SourceBuffers."); 237 }, 'Test setting MediaSource.duration during a pending appendStream() for one of its SourceBuffers.');
238 238
239 appendStreamTest(function(test, mediaElement, mediaSource, sourceBuffe r) 239 appendStreamTest(function(test, mediaElement, mediaSource, sourceBuffe r)
240 { 240 {
241 var xhr = createMediaXHR(); 241 var xhr = createMediaXHR();
242 test.failOnEvent(xhr, "error"); 242 test.failOnEvent(xhr, 'error');
243 test.failOnEvent(mediaSource, "sourceended"); 243 test.failOnEvent(mediaSource, 'sourceended');
244 xhr.send(); 244 xhr.send();
245 waitForLoadingState(test, xhr, function() 245 waitForLoadingState(test, xhr, function()
246 { 246 {
247 test.expectEvent(sourceBuffer, "updatestart", "Append started. "); 247 test.expectEvent(sourceBuffer, 'updatestart', 'Append started. ');
248 test.expectEvent(sourceBuffer, "update", "Append success."); 248 test.expectEvent(sourceBuffer, 'update', 'Append success.');
249 test.expectEvent(sourceBuffer, "updateend", "Append ended."); 249 test.expectEvent(sourceBuffer, 'updateend', 'Append ended.');
250 sourceBuffer.appendStream(xhr.response); 250 sourceBuffer.appendStream(xhr.response);
251 251
252 assert_true(sourceBuffer.updating, "updating attribute is true "); 252 assert_true(sourceBuffer.updating, 'updating attribute is true ');
253 253
254 assert_throws("InvalidStateError", 254 assert_throws('InvalidStateError',
255 function() { mediaSource.endOfStream(); }, 255 function() { mediaSource.endOfStream(); },
256 "endOfStream() throws an exception when updating attribute is true."); 256 'endOfStream() throws an exception when updating attribute is true.');
257 257
258 assert_equals(mediaSource.readyState, "open"); 258 assert_equals(mediaSource.readyState, 'open');
259 259
260 test.waitForExpectedEvents(function() 260 test.waitForExpectedEvents(function()
261 { 261 {
262 assert_false(sourceBuffer.updating, "updating attribute is false"); 262 assert_false(sourceBuffer.updating, 'updating attribute is false');
263 assert_equals(mediaSource.readyState, "open"); 263 assert_equals(mediaSource.readyState, 'open');
264 test.done(); 264 test.done();
265 }); 265 });
266 }); 266 });
267 }, "Test MediaSource.endOfStream() during a pending appendStream() for one of its SourceBuffers."); 267 }, 'Test MediaSource.endOfStream() during a pending appendStream() for one of its SourceBuffers.');
268 268
269 appendStreamTest(function(test, mediaElement, mediaSource, sourceBuffe r) 269 appendStreamTest(function(test, mediaElement, mediaSource, sourceBuffe r)
270 { 270 {
271 var xhr = createMediaXHR(); 271 var xhr = createMediaXHR();
272 test.failOnEvent(xhr, 'error'); 272 test.failOnEvent(xhr, 'error');
273 xhr.send(); 273 xhr.send();
274 waitForLoadingState(test, xhr, function() 274 waitForLoadingState(test, xhr, function()
275 { 275 {
276 test.expectEvent(sourceBuffer, "updatestart", "Append started. "); 276 test.expectEvent(sourceBuffer, 'updatestart', 'Append started. ');
277 test.expectEvent(sourceBuffer, "update", "Append success."); 277 test.expectEvent(sourceBuffer, 'update', 'Append success.');
278 test.expectEvent(sourceBuffer, "updateend", "Append ended."); 278 test.expectEvent(sourceBuffer, 'updateend', 'Append ended.');
279 sourceBuffer.appendStream(xhr.response); 279 sourceBuffer.appendStream(xhr.response);
280 280
281 assert_true(sourceBuffer.updating, "updating attribute is true "); 281 assert_true(sourceBuffer.updating, 'updating attribute is true ');
282 282
283 assert_throws("InvalidStateError", 283 assert_throws('InvalidStateError',
284 function() { sourceBuffer.timestampOffset = 10.0; }, 284 function() { sourceBuffer.timestampOffset = 10.0; },
285 "set timestampOffset throws an exception when updating att ribute is true."); 285 'set timestampOffset throws an exception when updating att ribute is true.');
286 286
287 test.waitForExpectedEvents(function() 287 test.waitForExpectedEvents(function()
288 { 288 {
289 assert_false(sourceBuffer.updating, "updating attribute is false"); 289 assert_false(sourceBuffer.updating, 'updating attribute is false');
290 test.done(); 290 test.done();
291 }); 291 });
292 }); 292 });
293 }, "Test setting SourceBuffer.timestampOffset during a pending appendS tream()."); 293 }, 'Test setting SourceBuffer.timestampOffset during a pending appendS tream().');
294 294
295 appendStreamTest(function(test, mediaElement, mediaSource, sourceBuffe r) 295 appendStreamTest(function(test, mediaElement, mediaSource, sourceBuffe r)
296 { 296 {
297 var xhr = createMediaXHR(); 297 var xhr = createMediaXHR();
298 test.failOnEvent(xhr, 'error'); 298 test.failOnEvent(xhr, 'error');
299 xhr.send(); 299 xhr.send();
300 waitForLoadingState(test, xhr, function() 300 waitForLoadingState(test, xhr, function()
301 { 301 {
302 test.expectEvent(sourceBuffer, "updatestart", "Append started. "); 302 test.expectEvent(sourceBuffer, 'updatestart', 'Append started. ');
303 test.expectEvent(sourceBuffer, "update", "Append success."); 303 test.expectEvent(sourceBuffer, 'update', 'Append success.');
304 test.expectEvent(sourceBuffer, "updateend", "Append ended."); 304 test.expectEvent(sourceBuffer, 'updateend', 'Append ended.');
305 sourceBuffer.appendStream(xhr.response, 0); 305 sourceBuffer.appendStream(xhr.response, 0);
306 306
307 assert_true(sourceBuffer.updating, "updating attribute is true "); 307 assert_true(sourceBuffer.updating, 'updating attribute is true ');
308 308
309 test.waitForExpectedEvents(function() 309 test.waitForExpectedEvents(function()
310 { 310 {
311 assert_false(sourceBuffer.updating, "updating attribute is false"); 311 assert_false(sourceBuffer.updating, 'updating attribute is false');
312 test.done(); 312 test.done();
313 }); 313 });
314 }); 314 });
315 }, "Test appending a Stream with maxSize equal to 0."); 315 }, 'Test appending a Stream with maxSize equal to 0.');
316 316
317 appendStreamTest(function(test, mediaElement, mediaSource, sourceBuffe r) 317 appendStreamTest(function(test, mediaElement, mediaSource, sourceBuffe r)
318 { 318 {
319 var xhr = createMediaXHR(); 319 var xhr = createMediaXHR();
320 test.failOnEvent(xhr, 'error'); 320 test.failOnEvent(xhr, 'error');
321 xhr.send(); 321 xhr.send();
322 waitForLoadingState(test, xhr, function() 322 waitForLoadingState(test, xhr, function()
323 { 323 {
324 test.expectEvent(sourceBuffer, "updatestart", "Append started. "); 324 test.expectEvent(sourceBuffer, 'updatestart', 'Append started. ');
325 test.expectEvent(sourceBuffer, "update", "Append success."); 325 test.expectEvent(sourceBuffer, 'update', 'Append success.');
326 test.expectEvent(sourceBuffer, "updateend", "Append ended."); 326 test.expectEvent(sourceBuffer, 'updateend', 'Append ended.');
327 sourceBuffer.appendStream(xhr.response, 10); 327 sourceBuffer.appendStream(xhr.response, 10);
328 328
329 assert_true(sourceBuffer.updating, "updating attribute is true "); 329 assert_true(sourceBuffer.updating, 'updating attribute is true ');
330 330
331 test.waitForExpectedEvents(function() 331 test.waitForExpectedEvents(function()
332 { 332 {
333 assert_false(sourceBuffer.updating, "updating attribute is false"); 333 assert_false(sourceBuffer.updating, 'updating attribute is false');
334 test.done(); 334 test.done();
335 }); 335 });
336 }); 336 });
337 }, "Test appending a Stream with maxSize value less than the size of t he XHR response."); 337 }, 'Test appending a Stream with maxSize value less than the size of t he XHR response.');
338 338
339 appendStreamTest(function(test, mediaElement, mediaSource, sourceBuffe r) 339 appendStreamTest(function(test, mediaElement, mediaSource, sourceBuffe r)
340 { 340 {
341 var xhr = createMediaXHR(); 341 var xhr = createMediaXHR();
342 test.failOnEvent(xhr, 'error'); 342 test.failOnEvent(xhr, 'error');
343 xhr.send(); 343 xhr.send();
344 waitForLoadingState(test, xhr, function() 344 waitForLoadingState(test, xhr, function()
345 { 345 {
346 test.expectEvent(sourceBuffer, "updatestart", "Append started. "); 346 test.expectEvent(sourceBuffer, 'updatestart', 'Append started. ');
347 test.expectEvent(sourceBuffer, "update", "Append success."); 347 test.expectEvent(sourceBuffer, 'update', 'Append success.');
348 test.expectEvent(sourceBuffer, "updateend", "Append ended."); 348 test.expectEvent(sourceBuffer, 'updateend', 'Append ended.');
349 sourceBuffer.appendStream(xhr.response, 10 * 1024 * 1024); 349 sourceBuffer.appendStream(xhr.response, 10 * 1024 * 1024);
350 350
351 assert_true(sourceBuffer.updating, "updating attribute is true "); 351 assert_true(sourceBuffer.updating, 'updating attribute is true ');
352 352
353 test.waitForExpectedEvents(function() 353 test.waitForExpectedEvents(function()
354 { 354 {
355 assert_false(sourceBuffer.updating, "updating attribute is false"); 355 assert_false(sourceBuffer.updating, 'updating attribute is false');
356 test.done(); 356 test.done();
357 }); 357 });
358 }); 358 });
359 }, "Test appending a Stream with maxSize value greater than the size o f the XHR response."); 359 }, 'Test appending a Stream with maxSize value greater than the size o f the XHR response.');
360 360
361 appendStreamTest(function(test, mediaElement, mediaSource, sourceBuffe r) 361 appendStreamTest(function(test, mediaElement, mediaSource, sourceBuffe r)
362 { 362 {
363 var xhr = createMediaXHR(); 363 var xhr = createMediaXHR();
364 test.failOnEvent(xhr, 'error'); 364 test.failOnEvent(xhr, 'error');
365 xhr.send(); 365 xhr.send();
366 waitForLoadingState(test, xhr, function() 366 waitForLoadingState(test, xhr, function()
367 { 367 {
368 test.expectEvent(sourceBuffer, "updatestart", "Append started. "); 368 test.expectEvent(sourceBuffer, 'updatestart', 'Append started. ');
369 test.expectEvent(sourceBuffer, "update", "Append success."); 369 test.expectEvent(sourceBuffer, 'update', 'Append success.');
370 test.expectEvent(sourceBuffer, "updateend", "Append ended."); 370 test.expectEvent(sourceBuffer, 'updateend', 'Append ended.');
371 sourceBuffer.appendStream(xhr.response, "test"); 371 sourceBuffer.appendStream(xhr.response, 'test');
372 372
373 assert_true(sourceBuffer.updating, "updating attribute is true "); 373 assert_true(sourceBuffer.updating, 'updating attribute is true ');
374 374
375 test.waitForExpectedEvents(function() 375 test.waitForExpectedEvents(function()
376 { 376 {
377 assert_false(sourceBuffer.updating, "updating attribute is false"); 377 assert_false(sourceBuffer.updating, 'updating attribute is false');
378 test.done(); 378 test.done();
379 }); 379 });
380 }); 380 });
381 }, "Test appending a Stream with an invalid maxSize."); 381 }, 'Test appending a Stream with an invalid maxSize.');
382 382
383 </script> 383 </script>
384 </body> 384 </body>
385 </html> 385 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698