| François Daoust | ade80c4 | 2016-06-30 07:43:59 | [diff] [blame] | 1 | <!DOCTYPE html> |
| Matt Wolenetz | b255ded | 2016-08-30 19:39:41 | [diff] [blame] | 2 | <!-- Copyright © 2016 Chromium authors and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). --> |
| François Daoust | ade80c4 | 2016-06-30 07:43:59 | [diff] [blame] | 3 | <meta charset="utf-8"> |
| Matt Wolenetz | 362ea98 | 2016-09-09 00:36:20 | [diff] [blame] | 4 | <meta name="timeout" content="long"> |
| François Daoust | ade80c4 | 2016-06-30 07:43:59 | [diff] [blame] | 5 | <script src="/resources/testharness.js"></script> |
| 6 | <script src="/resources/testharnessreport.js"></script> |
| 7 | <script src="mediasource-util.js"></script> |
| 8 | <script> |
| Matt Wolenetz | da02eb3 | 2016-09-09 00:39:59 | [diff] [blame] | 9 | var subType = MediaSourceUtil.getSubType(MediaSourceUtil.AUDIO_ONLY_TYPE); |
| Matt Wolenetz | 362ea98 | 2016-09-09 00:36:20 | [diff] [blame] | 10 | var manifestFilenameAudio = subType + "/test-a-128k-44100Hz-1ch-manifest.json"; |
| 11 | |
| François Daoust | ade80c4 | 2016-06-30 07:43:59 | [diff] [blame] | 12 | // Fill up a given SourceBuffer by appending data repeatedly via doAppendDataFunc until |
| 13 | // an exception is thrown. The thrown exception is passed to onCaughtExceptionCallback. |
| 14 | function fillUpSourceBuffer(test, sourceBuffer, doAppendDataFunc, onCaughtExceptionCallback) { |
| 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, sourceBuffer, doAppendDataFunc, onCaughtExceptionCallback); }); |
| 24 | } |
| 25 | |
| Matt Wolenetz | 362ea98 | 2016-09-09 00:36:20 | [diff] [blame] | 26 | mediasource_test(function(test, mediaElement, mediaSource) |
| François Daoust | ade80c4 | 2016-06-30 07:43:59 | [diff] [blame] | 27 | { |
| Matt Wolenetz | 362ea98 | 2016-09-09 00:36:20 | [diff] [blame] | 28 | mediaElement.addEventListener("error", test.unreached_func("Unexpected event 'error'")); |
| 29 | MediaSourceUtil.fetchManifestAndData(test, manifestFilenameAudio, function(typeAudio, dataAudio) |
| 30 | { |
| 31 | var sourceBuffer = mediaSource.addSourceBuffer(typeAudio); |
| 32 | sourceBuffer.mode = 'sequence'; |
| 33 | fillUpSourceBuffer(test, sourceBuffer, |
| 34 | function () { // doAppendDataFunc |
| 35 | sourceBuffer.appendBuffer(dataAudio); |
| 36 | }, |
| 37 | function (ex) { // onCaughtExceptionCallback |
| 38 | assert_equals(ex.name, 'QuotaExceededError'); |
| 39 | test.done(); |
| 40 | }); |
| 41 | }); |
| François Daoust | ade80c4 | 2016-06-30 07:43:59 | [diff] [blame] | 42 | }, 'Appending data repeatedly should fill up the buffer and throw a QuotaExceededError when buffer is full.'); |
| Matt Wolenetz | b255ded | 2016-08-30 19:39:41 | [diff] [blame] | 43 | </script> |