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 <script src="mediasource-util.js"></script> | |
7 <link rel='stylesheet' href='/w3c/resources/testharness.css'> | |
8 </head> | |
9 <body> | |
10 <div id="log"></div> | |
11 <script> | |
12 // Fill up a given SourceBuffer by appending data repeatedly via doApp endDataFunc until | |
13 // an exception is thrown. The thrown exception is passed to onCaughtE xceptionCallback. | |
14 function fillUpSourceBuffer(test, sourceBuffer, doAppendDataFunc, onCa ughtExceptionCallback) { | |
15 // We are appending data repeatedly in sequence mode, there should be no gaps. | |
16 assert_false(sourceBuffer.buffered.length > 1, "unexpected gap in buffered ranges."); | |
17 try { | |
18 doAppendDataFunc(); | |
19 } catch(ex) { | |
20 onCaughtExceptionCallback(ex); | |
21 } | |
22 test.expectEvent(sourceBuffer, 'updateend', 'append ended.'); | |
23 test.waitForExpectedEvents(function() { fillUpSourceBuffer(test, s ourceBuffer, doAppendDataFunc, onCaughtExceptionCallback); }); | |
24 } | |
25 | |
26 mediasource_test(function(test, mediaElement, mediaSource) | |
27 { | |
28 MediaSourceUtil.fetchManifestAndData(test, 'webm/test-a-192k-44100 Hz-1ch-manifest.json', function(type, mediaData) | |
29 { | |
30 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil .AUDIO_ONLY_TYPE); | |
31 sourceBuffer.mode = 'sequence'; | |
32 | |
33 fillUpSourceBuffer(test, sourceBuffer, | |
34 function () { // doAppendDataFunc | |
35 sourceBuffer.appendBuffer(mediaData); | |
36 }, | |
37 function (ex) { // onCaughtExceptionCallback | |
38 assert_equals(ex.name, 'QuotaExceededError'); | |
39 test.done(); | |
40 }); | |
41 }); | |
42 }, 'Appending data repeatedly should fill up the buffer and throw a Qu otaExceededError when buffer is full.', {timeout: 25000}); | |
43 | |
44 function createMediaXHR(test, onFinished) { | |
45 var mediaURL = "/media/resources/media-source/webm/test-a-192k-441 00Hz-1ch.webm"; | |
46 var xhr = new XMLHttpRequest(); | |
47 xhr.open('GET', mediaURL, true); | |
48 xhr.responseType = 'legacystream'; | |
ddorwin
2015/07/08 19:04:51
Is there a reason you are using a stream instead o
servolk
2015/07/08 19:13:00
SourceBuffer::appendStream expects blink::Stream a
ddorwin
2015/07/08 19:24:09
Can you instead use a random stream? (Is there any
servolk
2015/07/08 20:58:26
No, it can't be random data, I tried that already.
| |
49 test.failOnEvent(xhr, 'error'); | |
50 xhr.onreadystatechange = function() { | |
51 if (xhr.readyState == 4 && xhr.status == 200) { | |
52 onFinished(); | |
53 } | |
54 }; | |
55 return xhr; | |
56 } | |
57 | |
58 mediasource_test(function(test, mediaElement, mediaSource) | |
59 { | |
60 var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUD IO_ONLY_TYPE); | |
61 sourceBuffer.mode = 'sequence'; | |
62 | |
63 function onUpdateEnd() { | |
64 var xhr = createMediaXHR(test, function() | |
65 { | |
66 // We are appending data repeatedly in sequence mode, ther e should be no gaps. | |
67 assert_false(sourceBuffer.buffered.length > 1, "unexpected gap in buffered ranges."); | |
68 try { | |
69 sourceBuffer.appendStream(xhr.response); | |
ddorwin
2015/07/08 19:04:51
Is there a reason you are using appendStream()? Th
servolk
2015/07/08 19:13:00
Philip asked me to add a test case for appendStrea
ddorwin
2015/07/08 19:24:09
I see, you're testing both, but only this one uses
servolk
2015/07/08 20:58:26
Hmm, that's definitely not the case currently - lo
philipj_slow
2015/07/09 09:56:04
I've certainly written many web-platform-tests tha
| |
70 } catch(ex) { | |
71 assert_equals(ex.name, 'QuotaExceededError'); | |
72 test.done(); | |
73 } | |
74 test.expectEvent(sourceBuffer, "updateend", "Append ended. "); | |
75 test.waitForExpectedEvents(onUpdateEnd); | |
76 }); | |
77 xhr.send(); | |
78 } | |
79 // Start appending data | |
80 onUpdateEnd(); | |
81 }, 'Calling appendStream repeatedly should fill up the buffer and thro w a QuotaExceededError when buffer is full.', {timeout: 45000}); | |
82 </script> | |
83 </body> | |
84 </html> | |
OLD | NEW |