File: track-element-src-change.html

package info (click to toggle)
firefox-esr 91.13.0esr-1~deb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 3,375,652 kB
  • sloc: cpp: 5,762,054; javascript: 5,481,714; ansic: 3,121,191; python: 851,492; asm: 331,172; xml: 178,949; java: 155,554; sh: 63,704; makefile: 20,127; perl: 12,825; yacc: 4,583; cs: 3,846; objc: 3,026; lex: 1,720; exp: 762; pascal: 635; php: 436; lisp: 260; awk: 231; ruby: 103; sed: 53; sql: 46; csh: 45
file content (55 lines) | stat: -rw-r--r-- 3,288 bytes parent folder | download | duplicates (26)
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
<!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";
                    assert_equals(cues.length, 0, "cues list is reset 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>