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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/web-platform-tests/dom/nodes/Node-replaceChild.html

Issue 1854003004: Import web-platform-tests@5a8700479d98852455bee6117558897867eb278a (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 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
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <meta charset=utf-8> 2 <meta charset=utf-8>
3 <title>Node.replaceChild</title> 3 <title>Node.replaceChild</title>
4 <script src="../../../../resources/testharness.js"></script> 4 <script src="../../../../resources/testharness.js"></script>
5 <script src="../../../../resources/testharnessreport.js"></script> 5 <script src="../../../../resources/testharnessreport.js"></script>
6 <body><a><b></b><c></c></a> 6 <body><a><b></b><c></c></a>
7 <div id="log"></div> 7 <div id="log"></div>
8 <script> 8 <script>
9 // IDL. 9 // IDL.
10 test(function() { 10 test(function() {
(...skipping 19 matching lines...) Expand all
30 assert_throws("NotFoundError", function() { 30 assert_throws("NotFoundError", function() {
31 a.replaceChild(b, c); 31 a.replaceChild(b, c);
32 }); 32 });
33 33
34 var d = document.createElement("div"); 34 var d = document.createElement("div");
35 d.appendChild(b); 35 d.appendChild(b);
36 assert_throws("NotFoundError", function() { 36 assert_throws("NotFoundError", function() {
37 a.replaceChild(b, c); 37 a.replaceChild(b, c);
38 }); 38 });
39 assert_throws("NotFoundError", function() { 39 assert_throws("NotFoundError", function() {
40 a.replaceChild(a, c);
41 });
42 assert_throws("NotFoundError", function() {
43 a.replaceChild(b, a); 40 a.replaceChild(b, a);
44 }); 41 });
45 assert_throws("NotFoundError", function() {
46 a.replaceChild(a, a);
47 });
48 }, "If child's parent is not the context node, a NotFoundError exception should be thrown") 42 }, "If child's parent is not the context node, a NotFoundError exception should be thrown")
49 test(function() { 43 test(function() {
50 var nodes = [ 44 var nodes = [
51 document.implementation.createDocumentType("html", "", ""), 45 document.implementation.createDocumentType("html", "", ""),
52 document.createTextNode("text"), 46 document.createTextNode("text"),
53 document.implementation.createDocument(null, "foo", null).createProcessingIn struction("foo", "bar"), 47 document.implementation.createDocument(null, "foo", null).createProcessingIn struction("foo", "bar"),
54 document.createComment("comment") 48 document.createComment("comment")
55 ]; 49 ];
56 50
57 var a = document.createElement("div"); 51 var a = document.createElement("div");
58 var b = document.createElement("div"); 52 var b = document.createElement("div");
59 nodes.forEach(function(node) { 53 nodes.forEach(function(node) {
60 assert_throws("HierarchyRequestError", function() { 54 assert_throws("HierarchyRequestError", function() {
61 node.replaceChild(a, b); 55 node.replaceChild(a, b);
62 }); 56 });
63 }); 57 });
64 }, "If the context node is not a node that can contain children, a NotFoundError exception should be thrown") 58 }, "If the context node is not a node that can contain children, a NotFoundError exception should be thrown")
65 59
66 // Step 2. 60 // Step 2.
67 test(function() { 61 test(function() {
68 var a = document.createElement("div"); 62 var a = document.createElement("div");
69 var b = document.createElement("div"); 63 var b = document.createElement("div");
64
65 assert_throws("HierarchyRequestError", function() {
66 a.replaceChild(a, a);
67 });
68
70 a.appendChild(b); 69 a.appendChild(b);
71 assert_throws("HierarchyRequestError", function() { 70 assert_throws("HierarchyRequestError", function() {
72 a.replaceChild(a, b); 71 a.replaceChild(a, b);
73 }); 72 });
74 73
75 var c = document.createElement("div"); 74 var c = document.createElement("div");
76 c.appendChild(a); 75 c.appendChild(a);
77 assert_throws("HierarchyRequestError", function() { 76 assert_throws("HierarchyRequestError", function() {
78 a.replaceChild(c, b); 77 a.replaceChild(c, b);
79 }); 78 });
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 gBody.appendChild(parent); 336 gBody.appendChild(parent);
338 var child = document.createElement("div"); 337 var child = document.createElement("div");
339 parent.appendChild(child); 338 parent.appendChild(child);
340 var df = document.createDocumentFragment(); 339 var df = document.createDocumentFragment();
341 var fragChild = df.appendChild(document.createElement("div")); 340 var fragChild = df.appendChild(document.createElement("div"));
342 fragChild.setAttribute("id", TEST_ID); 341 fragChild.setAttribute("id", TEST_ID);
343 parent.replaceChild(df, child); 342 parent.replaceChild(df, child);
344 assert_equals(document.getElementById(TEST_ID), fragChild, "should not be null "); 343 assert_equals(document.getElementById(TEST_ID), fragChild, "should not be null ");
345 }, "Replacing an element with a DocumentFragment should allow a child of the Doc umentFragment to be found by Id.") 344 }, "Replacing an element with a DocumentFragment should allow a child of the Doc umentFragment to be found by Id.")
346 </script> 345 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698