File: mediasource-trackdefaultlist.html

package info (click to toggle)
firefox 147.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,683,320 kB
  • sloc: cpp: 7,607,359; javascript: 6,533,295; ansic: 3,775,223; python: 1,415,500; xml: 634,561; asm: 438,949; java: 186,241; sh: 62,752; makefile: 18,079; objc: 13,092; perl: 12,808; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; php: 436; lisp: 258; awk: 247; sql: 66; sed: 54; csh: 10; exp: 6
file content (60 lines) | stat: -rw-r--r-- 3,956 bytes parent folder | download | duplicates (25)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<!DOCTYPE html>
<!-- Copyright © 2016 Chromium authors and World Wide Web Consortium, (Massachusetts Institute of Technology, ERCIM, Keio University, Beihang). -->
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
    test(function()
    {
        var originalTrackDefaults = [
            // Same everything, but different byteStreamTrackID, should be allowed by the constructor.
            new TrackDefault("audio", "en-US", "label", ["main"], ""),
            new TrackDefault("audio", "en-US", "label", ["main"], "1"),
            new TrackDefault("audio", "en-US", "label", ["main"], "2"),
            new TrackDefault("audio", "en-US", "label", [""], "3"),

            // Same everything, but different type, should be allowed by the constructor.
            new TrackDefault("video", "en-US", "label", ["main"], ""),
            new TrackDefault("video", "en-US", "label", ["main"], "1"),
            new TrackDefault("video", "en-US", "label", ["main"], "2"),
            new TrackDefault("video", "en-US", "label", [""], "3")
        ];

        // Get a new array containing the same objects as |originalTrackDefaults|.
        var trackDefaults = originalTrackDefaults.slice();

        var trackDefaultList = new TrackDefaultList(trackDefaults);
        assert_array_equals(trackDefaultList, originalTrackDefaults, "construction and read-back succeeded");
        assert_equals(trackDefaultList[trackDefaultList.length], undefined, "out of range indexed property getter result is undefined");
        assert_equals(trackDefaultList[trackDefaultList.length + 1], undefined, "out of range indexed property getter result is undefined");

        // Introduce same-type, same-empty-string-byteStreamTrackId conflict in trackDefaults[0 vs 4].
        trackDefaults[4] = new TrackDefault("audio", "en-US", "label", ["main"], "");
        assert_equals(trackDefaults[0].type, trackDefaults[4].type, "same-type conflict setup");
        assert_equals(trackDefaults[0].byteStreamTrackID, trackDefaults[4].byteStreamTrackID, "same-byteStreamTrackID conflict setup");
        assert_throws_dom("InvalidAccessError",
            function() { new TrackDefaultList(trackDefaults); },
            "TrackDefaultList construction should throw exception due to same type and byteStreamTrackID across at least 2 items in trackDefaults");

        // Introduce same-type, same-non-empty-string-byteStreamTrackId conflict in trackDefaults[4 vs 5].
        trackDefaults[4] = new TrackDefault("video", "en-US", "label", ["main"], "1");
        assert_equals(trackDefaults[4].type, trackDefaults[5].type, "same-type conflict setup");
        assert_equals(trackDefaults[4].byteStreamTrackID, trackDefaults[5].byteStreamTrackID, "same-byteStreamTrackID conflict setup");
        assert_throws_dom("InvalidAccessError",
            function() { new TrackDefaultList(trackDefaults); },
            "TrackDefaultList construction should throw exception due to same type and byteStreamTrackID across at least 2 items in trackDefaults");

        // Confirm the constructed TrackDefaultList makes a shallow copy of the supplied TrackDefault sequence.
        assert_array_equals(trackDefaultList, originalTrackDefaults, "read-back of original trackDefaultList unchanged");

    }, "Test track default list construction, length, and indexed property getter");

    test(function()
    {
        var trackDefaultList = new TrackDefaultList();
        assert_array_equals(trackDefaultList, [], "empty list constructable without supplying optional trackDefaults parameter");

        trackDefaultList = new TrackDefaultList([]);
        assert_array_equals(trackDefaultList, [], "empty list constructable by supplying empty sequence as optional trackDefaults parameter");
    }, "Test empty track default list construction with and without optional trackDefaults parameter");
</script>