Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/ParentNode/append.html

Issue 2783813003: Move tests for ChildNode and ParentNode to dom/child_node/ and dom/parent_node/. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../../../resources/testharness.js"></script>
3 <script src="../../../resources/testharnessreport.js"></script>
4 <script>
5
6 test(function () {
7 var node = document.createElement('div');
8 assert_true('append' in node);
9 var append = 'mine';
10 var getAttribute = 'mine';
11 with (node) {
12 assert_true(append === 'mine');
13 assert_false(getAttribute === 'mine');
14 }
15 assert_true('Symbol' in window);
16 var unscopables = Object.getPrototypeOf(node)[Symbol.unscopables];
17 assert_true(unscopables.append);
18 }, 'ChildNode.append() unscopable');
19
20 function test_append(node, nodeName) {
21
22 test(function() {
23 var parent = node.cloneNode();
24 parent.append();
25 assert_array_equals(parent.childNodes, []);
26 }, nodeName + '.append() without any argument, on a parent having no child.' );
27
28 test(function() {
29 var parent = node.cloneNode();
30 parent.append(null);
31 assert_equals(parent.childNodes[0].textContent, 'null');
32 }, nodeName + '.append() with null as an argument, on a parent having no chi ld.');
33
34 test(function() {
35 var parent = node.cloneNode();
36 parent.append(undefined);
37 assert_equals(parent.childNodes[0].textContent, 'undefined');
38 }, nodeName + '.append() with undefined as an argument, on a parent having n o child.');
39
40 test(function() {
41 var parent = node.cloneNode();
42 parent.append('text');
43 assert_equals(parent.childNodes[0].textContent, 'text');
44 }, nodeName + '.append() with only text as an argument, on a parent having n o child.');
45
46 test(function() {
47 var parent = node.cloneNode();
48 var x = document.createElement('x');
49 parent.append(x);
50 assert_array_equals(parent.childNodes, [x]);
51 }, nodeName + '.append() with only one element as an argument, on a parent h aving no child.');
52
53 test(function() {
54 var parent = node.cloneNode();
55 var child = document.createElement('test');
56 parent.appendChild(child);
57 parent.append(null);
58 assert_equals(parent.childNodes[0], child);
59 assert_equals(parent.childNodes[1].textContent, 'null');
60 }, nodeName + '.append() with null as an argument, on a parent having a chil d.');
61
62 test(function() {
63 var parent = node.cloneNode();
64 var x = document.createElement('x');
65 var child = document.createElement('test');
66 parent.appendChild(x);
67 parent.appendChild(child);
68 parent.append(child, x);
69 assert_array_equals(parent.childNodes, [child, x]);
70 }, nodeName + '.append() with all children as arguments, on a parent having two children.');
71
72 test(function() {
73 var parent = node.cloneNode();
74 var x = document.createElement('x');
75 var child = document.createElement('test');
76 parent.appendChild(child);
77 parent.append(x, 'text');
78 assert_equals(parent.childNodes[0], child);
79 assert_equals(parent.childNodes[1], x);
80 assert_equals(parent.childNodes[2].textContent, 'text');
81 }, nodeName + '.append() with one element and text as argument, on a parent having a child.');
82
83 test(function() {
84 var parent = node.cloneNode();
85 var doc2 = document.implementation.createDocument("http://www.w3.org/199 9/xhtml", "html");
86 assert_throws('HierarchyRequestError', () => { parent.append(doc2, "foo" ) });
87 assert_equals(parent.firstChild, null);
88 }, nodeName + '.append() with a Document as an argument should throw.');
89 }
90
91 test_append(document.createElement('div'), 'Element');
92 test_append(document.createDocumentFragment(), 'DocumentFrgment');
93 </script>
94 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698