File: track-element-src-change.html

package info (click to toggle)
thunderbird 1%3A60.9.0-1~deb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,339,424 kB
  • sloc: cpp: 5,457,040; ansic: 2,360,385; python: 596,167; asm: 340,963; java: 326,296; xml: 258,830; sh: 84,445; makefile: 23,701; perl: 17,317; objc: 3,768; yacc: 1,766; ada: 1,681; lex: 1,364; pascal: 1,264; cs: 879; exp: 527; php: 436; lisp: 258; ruby: 153; awk: 152; sed: 53; csh: 27
file content (57 lines) | stat: -rw-r--r-- 3,480 bytes parent folder | download | duplicates (4)
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
<!DOCTYPE html>
<title>HTMLTrackElement 'src' attribute mutations</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<video>
    <track src="resources/settings.vtt" default>
    <script>
    async_test(function(t) {
        var cues = null;
        var testTrack = document.querySelector("track");
        var stage = 0;
        function step_onLoad() {
            switch (stage) {
                case 0:
                    cues = testTrack.track.cues;
                    assert_equals(testTrack.readyState, HTMLTrackElement.LOADED, "readyState after first loading of the track");
                    assert_equals(cues.length, 4, "Number of cues after first loading of the track");
                    assert_equals(cues[cues.length-1].text, 'I said Bear is coming now!!!! Tab separators.', "Last cue content check");
                    ++stage;
                    testTrack.src = "resources/entities.vtt";
                    // CuesList will be cleared in a microtask. Spec claims that this should happen immediately,
                    // but all known implementations are doing this asynchronously.
                    assert_equals(cues.length, 4, "Number of cues immediately after 'src' mutation with the new URL");
                    break;
                case 1:
                    assert_equals(testTrack.readyState, HTMLTrackElement.LOADED), "readyState after loading of the second track";
                    assert_equals(cues, testTrack.track.cues, ".cues object are the same after 'src' attr mutation");
                    assert_equals(cues.length, 7, "Number of cues after loading of the second track");
                    assert_equals(cues[cues.length-1].text, 'This & is parsed to the same as &amp;.', "Last cue content check");
                    ++stage;
                    testTrack.src = "resources/settings.vtt";
                    break;
                case 2:
                    assert_equals(testTrack.readyState, HTMLTrackElement.LOADED, "readyState after after loading of the first track again");
                    assert_equals(cues[cues.length-1].text, 'I said Bear is coming now!!!! Tab separators.', "Last cue content check");
                    assert_equals(cues, testTrack.track.cues, ".cues object are the same after 'src' attr mutation");
                    assert_equals(cues.length, 4, "Number of cues after loading of the first track");
                    ++stage;
                    testTrack.src = "resources/settings.vtt";
                    // This should not raise onLoad or onError event, so we'll wait for it for some time
                    t.step_timeout(t.step_func_done(function() {
                        assert_equals(testTrack.readyState, HTMLTrackElement.LOADED, "readyState after changing 'src' to the same value");
                        assert_equals(cues, testTrack.track.cues, ".cues object are the same after 'src' attr mutation");
                        assert_equals(cues.length, 4, "Number of cues after changing 'src' to the same value");
                    }, 100));
                    break;
                case 3:
                    assert_unreached("'load' event should not fire, stage = " + stage);
                    break;
            }
        }

        testTrack.onload = t.step_func(step_onLoad);
        testTrack.onerror = t.unreached_func("'error' event should not fire");
    });
    </script>
</video>