| 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"> |
| 4 | <script src="/resources/testharness.js"></script> |
| 5 | <script src="/resources/testharnessreport.js"></script> |
| 6 | <script src="mediasource-util.js"></script> |
| 7 | <script> |
| 8 | // Fill up a given SourceBuffer by appending data repeatedly via doAppendDataFunc until |
| 9 | // an exception is thrown. The thrown exception is passed to onCaughtExceptionCallback. |
| 10 | function fillUpSourceBuffer(test, sourceBuffer, doAppendDataFunc, onCaughtExceptionCallback) { |
| 11 | // We are appending data repeatedly in sequence mode, there should be no gaps. |
| 12 | assert_false(sourceBuffer.buffered.length > 1, "unexpected gap in buffered ranges."); |
| 13 | try { |
| 14 | doAppendDataFunc(); |
| 15 | } catch(ex) { |
| 16 | onCaughtExceptionCallback(ex); |
| 17 | } |
| 18 | test.expectEvent(sourceBuffer, 'updateend', 'append ended.'); |
| 19 | test.waitForExpectedEvents(function() { fillUpSourceBuffer(test, sourceBuffer, doAppendDataFunc, onCaughtExceptionCallback); }); |
| 20 | } |
| 21 | |
| 22 | mediasource_testafterdataloaded(function(test, mediaElement, mediaSource, segmentInfo, sourceBuffer, mediaData) |
| 23 | { |
| 24 | sourceBuffer.mode = 'sequence'; |
| 25 | fillUpSourceBuffer(test, sourceBuffer, |
| 26 | function () { // doAppendDataFunc |
| 27 | sourceBuffer.appendBuffer(mediaData); |
| 28 | }, |
| 29 | function (ex) { // onCaughtExceptionCallback |
| 30 | assert_equals(ex.name, 'QuotaExceededError'); |
| 31 | test.done(); |
| 32 | }); |
| 33 | }, '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^] | 34 | </script> |