File: mediasource-appendbuffer-quota-exceeded.html

package info (click to toggle)
firefox-esr 68.10.0esr-1~deb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 3,143,932 kB
  • sloc: cpp: 5,227,879; javascript: 4,315,531; ansic: 2,467,042; python: 794,975; java: 349,993; asm: 232,034; xml: 228,320; sh: 82,008; lisp: 41,202; makefile: 22,347; perl: 15,555; objc: 5,277; cs: 4,725; yacc: 1,778; ada: 1,681; pascal: 1,673; lex: 1,417; exp: 527; php: 436; ruby: 225; awk: 162; sed: 53; csh: 44
file content (43 lines) | stat: -rw-r--r-- 2,238 bytes parent folder | download | duplicates (16)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE html>
<!-- Copyright © 2016 Chromium authors and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). -->
<meta charset="utf-8">
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="mediasource-util.js"></script>
<script>
    var subType = MediaSourceUtil.getSubType(MediaSourceUtil.AUDIO_ONLY_TYPE);
    var manifestFilenameAudio = subType + "/test-a-128k-44100Hz-1ch-manifest.json";

    // 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)
    {
        mediaElement.addEventListener("error", test.unreached_func("Unexpected event 'error'"));
        MediaSourceUtil.fetchManifestAndData(test, manifestFilenameAudio, function(typeAudio, dataAudio)
        {
            var sourceBuffer = mediaSource.addSourceBuffer(typeAudio);
            sourceBuffer.mode = 'sequence';
            fillUpSourceBuffer(test, sourceBuffer,
                function () { // doAppendDataFunc
                    sourceBuffer.appendBuffer(dataAudio);
                },
                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.');
</script>