File: rootNode.html

package info (click to toggle)
firefox-esr 52.8.1esr-1~deb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 1,983,244 kB
  • sloc: cpp: 4,810,275; ansic: 2,004,548; python: 451,282; java: 241,615; asm: 178,649; xml: 136,302; sh: 82,207; makefile: 22,575; perl: 15,783; objc: 4,389; yacc: 1,816; ada: 1,697; pascal: 1,519; lex: 1,257; cs: 879; exp: 499; php: 436; lisp: 258; awk: 152; sed: 51; ruby: 47; csh: 27
file content (82 lines) | stat: -rw-r--r-- 3,975 bytes parent folder | download | duplicates (6)
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
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<title>Node.prototype.getRootNode()</title>
<link rel="help" href="https://dom.spec.whatwg.org/#dom-node-getrootnode">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>

test(function () {
    var element = document.createElement('div');
    assert_equals(element.getRootNode(), element, 'getRootNode() on an element without a parent must return the element itself');

    var text = document.createTextNode('');
    assert_equals(text.getRootNode(), text, 'getRootNode() on a text node without a parent must return the text node itself');

    var processingInstruction = document.createProcessingInstruction('target', 'data');
    assert_equals(processingInstruction.getRootNode(), processingInstruction, 'getRootNode() on a processing instruction node without a parent must return the processing instruction node itself');

    assert_equals(document.getRootNode(), document, 'getRootNode() on a document node must return the document itself');

}, 'getRootNode() must return the context object when it does not have any parent');

test(function () {
    var parent = document.createElement('div');

    var element = document.createElement('div');
    parent.appendChild(element);
    assert_equals(element.getRootNode(), parent, 'getRootNode() on an element with a single ancestor must return the parent node');

    var text = document.createTextNode('');
    parent.appendChild(text);
    assert_equals(text.getRootNode(), parent, 'getRootNode() on a text node with a single ancestor must return the parent node');

    var processingInstruction = document.createProcessingInstruction('target', 'data');
    parent.appendChild(processingInstruction)
    assert_equals(processingInstruction.getRootNode(), parent, 'getRootNode() on a processing instruction node with a single ancestor must return the parent node');

}, 'getRootNode() must return the parent node of the context object when the context object has a single ancestor not in a document');

test(function () {
    var parent = document.createElement('div');
    document.body.appendChild(parent);

    var element = document.createElement('div');
    parent.appendChild(element);
    assert_equals(element.getRootNode(), document, 'getRootNode() on an element inside a document must return the document');

    var text = document.createTextNode('');
    parent.appendChild(text);
    assert_equals(text.getRootNode(), document, 'getRootNode() on a text node inside a document must return the document');

    var processingInstruction = document.createProcessingInstruction('target', 'data');
    parent.appendChild(processingInstruction)
    assert_equals(processingInstruction.getRootNode(), document, 'getRootNode() on a processing instruction node inside a document must return the document');
}, 'getRootNode() must return the document when a node is in document');

test(function () {
    var fragment = document.createDocumentFragment();
    var parent = document.createElement('div');
    fragment.appendChild(parent);

    var element = document.createElement('div');
    parent.appendChild(element);
    assert_equals(element.getRootNode(), fragment, 'getRootNode() on an element inside a document fragment must return the fragment');

    var text = document.createTextNode('');
    parent.appendChild(text);
    assert_equals(text.getRootNode(), fragment, 'getRootNode() on a text node inside a document fragment must return the fragment');

    var processingInstruction = document.createProcessingInstruction('target', 'data');
    parent.appendChild(processingInstruction)
    assert_equals(processingInstruction.getRootNode(), fragment,
        'getRootNode() on a processing instruction node inside a document fragment must return the fragment');
}, 'getRootNode() must return a document fragment when a node is in the fragment');

</script>
</body>
</html>