Index: LayoutTests/http/tests/media/media-source/mediasource-evict-frames.html |
diff --git a/LayoutTests/http/tests/media/media-source/mediasource-evict-frames.html b/LayoutTests/http/tests/media/media-source/mediasource-evict-frames.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3970cdbb515fbd9c82a6f339ae757d5114d7df58 |
--- /dev/null |
+++ b/LayoutTests/http/tests/media/media-source/mediasource-evict-frames.html |
@@ -0,0 +1,84 @@ |
+<!DOCTYPE html> |
+<html> |
+ <head> |
+ <script src="/w3c/resources/testharness.js"></script> |
+ <script src="/w3c/resources/testharnessreport.js"></script> |
+ <script src="mediasource-util.js"></script> |
+ <link rel='stylesheet' href='/w3c/resources/testharness.css'> |
+ </head> |
+ <body> |
+ <div id="log"></div> |
+ <script> |
+ // Fill up a given SourceBuffer by appending data repeatedly via doAppendDataFunc until |
+ // an exception is thrown. The thrown exception is passed to onCaughtExceptionCallback. |
+ function fillUpSourceBuffer(test, sourceBuffer, doAppendDataFunc, onCaughtExceptionCallback) { |
+ // We are appending data repeatedly in sequence mode, there should be no gaps. |
+ assert_false(sourceBuffer.buffered.length > 1, "unexpected gap in buffered ranges."); |
+ try { |
+ doAppendDataFunc(); |
+ } catch(ex) { |
+ onCaughtExceptionCallback(ex); |
+ } |
+ test.expectEvent(sourceBuffer, 'updateend', 'append ended.'); |
+ test.waitForExpectedEvents(function() { fillUpSourceBuffer(test, sourceBuffer, doAppendDataFunc, onCaughtExceptionCallback); }); |
+ } |
+ |
+ mediasource_test(function(test, mediaElement, mediaSource) |
+ { |
+ MediaSourceUtil.fetchManifestAndData(test, 'webm/test-a-192k-44100Hz-1ch-manifest.json', function(type, mediaData) |
+ { |
+ var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_ONLY_TYPE); |
+ sourceBuffer.mode = 'sequence'; |
+ |
+ fillUpSourceBuffer(test, sourceBuffer, |
+ function () { // doAppendDataFunc |
+ sourceBuffer.appendBuffer(mediaData); |
+ }, |
+ function (ex) { // onCaughtExceptionCallback |
+ assert_equals(ex.name, 'QuotaExceededError'); |
+ test.done(); |
+ }); |
+ }); |
+ }, 'Appending data repeatedly should fill up the buffer and throw a QuotaExceededError when buffer is full.', {timeout: 25000}); |
+ |
+ function createMediaXHR(test, onFinished) { |
+ var mediaURL = "/media/resources/media-source/webm/test-a-192k-44100Hz-1ch.webm"; |
+ var xhr = new XMLHttpRequest(); |
+ xhr.open('GET', mediaURL, true); |
+ 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.
|
+ test.failOnEvent(xhr, 'error'); |
+ xhr.onreadystatechange = function() { |
+ if (xhr.readyState == 4 && xhr.status == 200) { |
+ onFinished(); |
+ } |
+ }; |
+ return xhr; |
+ } |
+ |
+ mediasource_test(function(test, mediaElement, mediaSource) |
+ { |
+ var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_ONLY_TYPE); |
+ sourceBuffer.mode = 'sequence'; |
+ |
+ function onUpdateEnd() { |
+ var xhr = createMediaXHR(test, function() |
+ { |
+ // We are appending data repeatedly in sequence mode, there should be no gaps. |
+ assert_false(sourceBuffer.buffered.length > 1, "unexpected gap in buffered ranges."); |
+ try { |
+ 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
|
+ } catch(ex) { |
+ assert_equals(ex.name, 'QuotaExceededError'); |
+ test.done(); |
+ } |
+ test.expectEvent(sourceBuffer, "updateend", "Append ended."); |
+ test.waitForExpectedEvents(onUpdateEnd); |
+ }); |
+ xhr.send(); |
+ } |
+ // Start appending data |
+ onUpdateEnd(); |
+ }, 'Calling appendStream repeatedly should fill up the buffer and throw a QuotaExceededError when buffer is full.', {timeout: 45000}); |
+ </script> |
+ </body> |
+</html> |