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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/dom/nodes/Node-isConnected.html

Issue 2086283003: Update web-platform-tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge branch 'master' into wpt_import Created 4 years, 5 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 <meta charset="utf-8">
3 <head>
4 <title>Node.prototype.isConnected</title>
5 <link rel=help href="https://dom.spec.whatwg.org/#dom-node-isconnected">
6 <script src="/resources/testharness.js"></script>
7 <script src="/resources/testharnessreport.js"></script>
8 </head>
9 <body>
10 <script>
11
12 "use strict";
13
14 test(function() {
15 var nodes = [document.createElement("div"),
16 document.createElement("div"),
17 document.createElement("div")];
18 checkNodes([], nodes);
19
20 // Append nodes[0].
21 document.body.appendChild(nodes[0]);
22 checkNodes([nodes[0]],
23 [nodes[1], nodes[2]]);
24
25 // Append nodes[1] and nodes[2] together.
26 nodes[1].appendChild(nodes[2]);
27 checkNodes([nodes[0]],
28 [nodes[1], nodes[2]]);
29
30 nodes[0].appendChild(nodes[1]);
31 checkNodes(nodes, []);
32
33 // Remove nodes[2].
34 nodes[2].remove();
35 checkNodes([nodes[0], nodes[1]],
36 [nodes[2]]);
37
38 // Remove nodes[0] and nodes[1] together.
39 nodes[0].remove();
40 checkNodes([], nodes);
41 }, "Test with ordinary child nodes");
42
43 test(function() {
44 var nodes = [document.createElement("iframe"),
45 document.createElement("iframe"),
46 document.createElement("iframe"),
47 document.createElement("iframe"),
48 document.createElement("div")];
49 var frames = [nodes[0],
50 nodes[1],
51 nodes[2],
52 nodes[3]];
53 checkNodes([], nodes);
54
55 // Since we cannot append anything to the contentWindow of an iframe before it
56 // is appended to the main DOM tree, we append the iframes one after another.
57 document.body.appendChild(nodes[0]);
58 checkNodes([nodes[0]],
59 [nodes[1], nodes[2], nodes[3], nodes[4]]);
60
61 frames[0].contentDocument.body.appendChild(nodes[1]);
62 checkNodes([nodes[0], nodes[1]],
63 [nodes[2], nodes[3], nodes[4]]);
64
65 frames[1].contentDocument.body.appendChild(nodes[2]);
66 checkNodes([nodes[0], nodes[1], nodes[2]],
67 [nodes[3], nodes[4]]);
68
69 frames[2].contentDocument.body.appendChild(nodes[3]);
70 checkNodes([nodes[0], nodes[1], nodes[2], nodes[3]],
71 [nodes[4]]);
72
73 frames[3].contentDocument.body.appendChild(nodes[4]);
74 checkNodes(nodes, []);
75
76 frames[3].remove();
77 // Since node[4] is still under the doument of frame[3], it's still connected.
78 checkNodes([nodes[0], nodes[1], nodes[2], nodes[4]],
79 [nodes[3]]);
80
81 frames[0].remove();
82 // Since node[1] and node[2] are still under the doument of frame[0], they are
83 // still connected.
84 checkNodes([nodes[1], nodes[2], nodes[4]],
85 [nodes[0], nodes[3]]);
86 }, "Test with iframes");
87
88 // This helper function is used to check whether nodes should be connected.
89 function checkNodes(aConnectedNodes, aDisconnectedNodes) {
90 aConnectedNodes.forEach(node => assert_true(node.isConnected));
91 aDisconnectedNodes.forEach(node => assert_false(node.isConnected));
92 }
93
94 </script>
95 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698