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

Unified Diff: LayoutTests/http/tests/media/media-source/mediasource-appendstream-quota-exceeded.html

Issue 1304953002: LayoutTests for the new MSE GC behavior. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@mse-gc5
Patch Set: New test case for error event sent from async appendStream Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/http/tests/media/media-source/mediasource-appendstream-quota-exceeded.html
diff --git a/LayoutTests/http/tests/media/media-source/mediasource-appendstream-quota-exceeded.html b/LayoutTests/http/tests/media/media-source/mediasource-appendstream-quota-exceeded.html
new file mode 100644
index 0000000000000000000000000000000000000000..644f3fdb33063f257c6d2284e476f989df8f308a
--- /dev/null
+++ b/LayoutTests/http/tests/media/media-source/mediasource-appendstream-quota-exceeded.html
@@ -0,0 +1,78 @@
+<!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>
+ function createMediaXHR(test, onFinished) {
+ var mediaURL = "/media/resources/media-source/webm/test-a-5min-44100Hz-1ch.webm";
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET', mediaURL, true);
+ xhr.responseType = 'legacystream';
+ 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, 551 * 1024);
+ } 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 (with size parameter) should fill up the buffer and throw a QuotaExceededError when buffer is full.');
+
+ mediasource_test(function(test, mediaElement, mediaSource)
+ {
+ var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_ONLY_TYPE);
+ sourceBuffer.mode = 'sequence';
+
+ sourceBuffer.addEventListener('error', function() {
+ // Ok, we got error message as expected. This error notifies us that the async
+ // appendStream has failed due to buffer being full.
+ test.done();
+ });
+
+ 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.");
+ sourceBuffer.appendStream(xhr.response);
+ test.expectEvent(sourceBuffer, "updateend", "Append ended.");
+ test.waitForExpectedEvents(onUpdateEnd);
+ });
+ xhr.send();
+ }
+ // Start appending data
+ onUpdateEnd();
+ }, 'Calling appendStream repeatedly (without size parameter) should fill up the buffer and send an error event when buffer is full.');
+ </script>
+ </body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698