Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-util.js |
| diff --git a/third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-util.js b/third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-util.js |
| index 4b18a74f8554c1185c1dd2357d730e28c0fb14bf..02ed2f21a907986f9bcf0d35f3b182934bda929e 100644 |
| --- a/third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-util.js |
| +++ b/third_party/WebKit/LayoutTests/http/tests/media/media-source/mediasource-util.js |
| @@ -126,12 +126,12 @@ |
| return expectations; |
| }; |
| - function loadData_(test, url, callback, isBinary) |
| + function loadData_(test, url, callback, responseType) |
| { |
| var request = new XMLHttpRequest(); |
| request.open("GET", url, true); |
| - if (isBinary) { |
| - request.responseType = 'arraybuffer'; |
| + if (responseType !== undefined) { |
| + request.responseType = responseType; |
| } |
| request.onload = test.step_func(function(event) |
| { |
| @@ -140,7 +140,7 @@ |
| return; |
| } |
| var response = request.response; |
| - if (isBinary) { |
| + if (responseType !== undefined && responseType == 'arraybuffer') { |
| response = new Uint8Array(response); |
| } |
| callback(response); |
| @@ -173,12 +173,17 @@ |
| MediaSourceUtil.loadTextData = function(test, url, callback) |
| { |
| - loadData_(test, url, callback, false); |
| + loadData_(test, url, callback); |
| }; |
| MediaSourceUtil.loadBinaryData = function(test, url, callback) |
| { |
| - loadData_(test, url, callback, true); |
| + loadData_(test, url, callback, 'arraybuffer'); |
| + }; |
| + |
| + MediaSourceUtil.loadDataStream = function(test, url, callback) |
| + { |
| + loadData_(test, url, callback, 'legacystream'); |
| }; |
| MediaSourceUtil.fetchManifestAndData = function(test, manifestFilename, callback) |
| @@ -221,6 +226,71 @@ |
| return mediaData.subarray(start, numBytes + start); |
| } |
| + // Fills up the sourceBuffer by repeatedly calling doAppendDataFunc, which is expected to append some data |
| + // to the sourceBuffer, until a QuotaExceeded exception is thrown. Then it calls the onCaughtQuotaExceeded callback. |
| + MediaSourceUtil.fillUpSourceBufferHelper = function(test, sourceBuffer, doAppendDataFunc, onCaughtQuotaExceeded) |
| + { |
| + // We are appending data repeatedly in sequence mode, there should be no gaps. |
| + assert_equals(sourceBuffer.mode, 'sequence'); |
| + assert_false(sourceBuffer.buffered.length > 1, 'unexpected gap in buffered ranges.'); |
| + try { |
| + doAppendDataFunc(); |
| + } catch(ex) { |
| + assert_equals(ex.name, 'QuotaExceededError'); |
| + onCaughtQuotaExceeded(); |
| + } |
| + test.expectEvent(sourceBuffer, 'updateend', 'append ended.'); |
| + test.waitForExpectedEvents(function() { MediaSourceUtil.fillUpSourceBufferHelper(test, sourceBuffer, doAppendDataFunc, onCaughtQuotaExceeded); }); |
| + }; |
| + |
| + MediaSourceUtil.fillUpSourceBuffer = function(test, mediaSource, onBufferFull) |
| + { |
| + MediaSourceUtil.fetchManifestAndData(test, 'webm/test-a-5min-44100Hz-1ch-manifest.json', function(type, mediaData) |
|
wolenetz
2016/08/02 21:56:36
nit: (not a regression, and certainly not a strong
servolk
2016/08/02 22:59:15
Sure we can easily pass in the manifest/stream URL
|
| + { |
| + var sourceBuffer = mediaSource.addSourceBuffer(MediaSourceUtil.AUDIO_ONLY_TYPE); |
| + sourceBuffer.mode = 'sequence'; |
| + |
| + var appendedDataSize = 0; |
| + MediaSourceUtil.fillUpSourceBufferHelper(test, sourceBuffer, |
| + function () { // doAppendDataFunc |
| + appendedDataSize += mediaData.length; |
| + sourceBuffer.appendBuffer(mediaData); |
| + }, |
| + function () { // onCaughtQuotaExceeded |
| + onBufferFull(appendedDataSize); |
| + }); |
| + }); |
| + }; |
| + |
| + MediaSourceUtil.fillUpSourceBufferViaAppendStream = function (test, mediaSource, sourceBuffer, onBufferFull, appendSize) |
| + { |
| + var mediaURL = "/media/resources/media-source/webm/test-a-5min-44100Hz-1ch.webm"; |
| + var appendedDataSize = 0; |
| + function appendStreamData() { |
| + MediaSourceUtil.loadDataStream(test, mediaURL, function(response) |
| + { |
| + // 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 { |
| + if (appendSize !== undefined) { |
| + appendedDataSize += appendSize; |
| + sourceBuffer.appendStream(response, appendSize); |
| + } else { |
| + sourceBuffer.appendStream(response); |
| + } |
| + } catch(ex) { |
| + assert_equals(ex.name, 'QuotaExceededError'); |
| + onBufferFull(appendedDataSize); |
| + } |
| + test.expectEvent(sourceBuffer, "updateend", "Append ended."); |
| + test.waitForExpectedEvents(appendStreamData); |
| + }); |
| + } |
| + // Start appending data |
| + appendStreamData(); |
| + }; |
| + |
| + |
| function getFirstSupportedType(typeList) |
| { |
| for (var i = 0; i < typeList.length; ++i) { |