File: cloneNode.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 (87 lines) | stat: -rw-r--r-- 4,608 bytes parent folder | download | duplicates (30)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!doctype html>
<title>track element cloneNode</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id=log></div>
<script>
test(function() {
    var elm = document.createElement('track');
    assert_equals(elm.readyState, elm.NONE, 'elm.readyState after element creation');
    var clone = elm.cloneNode(true);
    assert_equals(clone.readyState, clone.NONE, 'clone.readyState after element creation');
    assert_not_equals(clone.track, elm.track, 'clone.track and elm.track');
}, document.title+', not loaded');

async_test(function(t) {
    var elm = document.createElement('track');
    var video = document.createElement('video');
    video.appendChild(elm);
    elm.track.mode = 'showing';
    assert_equals(elm.readyState, elm.NONE, 'elm.readyState after appening to video setting mode');
    elm.src = 'resources/track.vtt?pipe=trickle(d1)';
    assert_equals(elm.readyState, elm.NONE, 'elm.readyState after setting src');
    t.step_timeout(function() {
      assert_equals(elm.readyState, elm.LOADING, 'elm.readyState in setTimeout');
      var clone = elm.cloneNode(true);
      assert_equals(clone.readyState, clone.NONE, 'clone.readyState after element creation');
      video.appendChild(clone);
      clone.track.mode = 'showing';
      assert_equals(clone.readyState, clone.NONE, 'clone.readyState after appending to video and setting mode');
      assert_not_equals(clone.track, elm.track, 'clone.track and elm.track');
      t.done();
    }, 0);
}, document.title+', loading');

async_test(function(t) {
    var elm = document.createElement('track');
    var video = document.createElement('video');
    video.appendChild(elm);
    elm.track.mode = 'showing';
    elm.src = 'data:text/vtt,'+encodeURIComponent('WEBVTT\n\n00:00:00.000 --> 00:00:01.000\nfoo');
    assert_equals(elm.readyState, elm.NONE, 'elm.readyState after setting src');
    elm.onload = this.step_func(function() {
        assert_equals(elm.readyState, elm.LOADED, 'elm.readyState');
        assert_equals(elm.track.cues.length, 1, 'elm.track.cues.length');
        assert_equals(elm.track.cues[0].startTime, 0, 'elm.track.cues[0].startTime');
        assert_equals(elm.track.cues[0].endTime, 1, 'elm.track.cues[0].endTime');
        assert_equals(elm.track.cues[0].text, 'foo', 'elm.track.cues[0].text');
        var clone = elm.cloneNode(true);
        assert_equals(clone.readyState, clone.NONE, 'clone.readyState after element creation');
        video.appendChild(clone);
        clone.track.mode = 'showing';
        assert_equals(clone.readyState, clone.NONE, 'clone.readyState after appending to video and setting mode');
        assert_not_equals(clone.track, elm.track, 'clone.track and elm.track');
        clone.onload = this.step_func(function(){
            assert_equals(clone.readyState, clone.LOADED, 'clone.readyState');
            assert_not_equals(clone.track, elm.track, 'clone.track and elm.track');
            assert_not_equals(clone.track.cues, elm.track.cues, 'clone.track.cues and elm.track.cues');
            assert_equals(clone.track.cues.length, 1, 'clone.track.cues.length');
            assert_not_equals(clone.track.cues[0], elm.track.cues[0], 'cues[0]');
            assert_equals(clone.track.cues[0].startTime, 0, 'clone.track.cues[0].startTime');
            assert_equals(clone.track.cues[0].endTime, 1, 'clone.track.cues[0].endTime');
            assert_equals(clone.track.cues[0].text, 'foo', 'clone.track.cues[0].text');
            this.done();
        });
        clone.onerror = this.step_func(function() { assert_unreached('clone got error'); });
    });
    elm.onerror = this.step_func(function() { assert_unreached('elm got error'); });
}, document.title+', loaded');

async_test(function(t) {
    var elm = document.createElement('track');
    var video = document.createElement('video');
    video.appendChild(elm);
    elm.track.mode = 'showing';
    elm.onerror = t.step_func(function() {
      assert_equals(elm.readyState, elm.ERROR, 'elm.readyState in onerror');
      var clone = elm.cloneNode(true);
      assert_equals(clone.readyState, clone.NONE, 'clone.readyState after element creation');
      video.appendChild(clone);
      clone.track.mode = 'showing';
      assert_equals(clone.readyState, clone.NONE, 'clone.readyState after appending to video and setting mode');
      assert_not_equals(clone.track, elm.track, 'clone.track and elm.track');
      clone.onerror = t.step_func_done();
    });
    elm.src = 'javascript:"network error"';
}, document.title+', failed to load');
</script>