Commit 9f335772 authored by Chromium WPT Sync's avatar Chromium WPT Sync Committed by Commit Bot

Import wpt@5fd4ca1bceac025e60648e559116cbe5abbb5de8

Using wpt-import in Chromium e680714f.
With Chromium commits locally applied on WPT:
f79c6fe7 "Reimplementing getDatabaseNames() as databases() for indexeddb."


Build: https://ci.chromium.org/buildbot/chromium.infra.cron/wpt-importer/26605

Note to sheriffs: This CL imports external tests and adds
expectations for those tests; if this CL is large and causes
a few new failures, please fix the failures by adding new
lines to TestExpectations rather than reverting. See:
https://chromium.googlesource.com/chromium/src/+/master/docs/testing/web_platform_tests.md

NOAUTOREVERT=true
TBR=markdittmer

No-Export: true
Change-Id: Ibfd8e1c24df1f008382c275654664dbfed11c7c7
Reviewed-on: https://chromium-review.googlesource.com/c/1296056
Commit-Queue: Blink WPT Bot <blink-w3c-test-autoroller@chromium.org>
Reviewed-by: default avatarBlink WPT Bot <blink-w3c-test-autoroller@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601881}
parent a73f01f8
...@@ -3,6 +3,12 @@ ...@@ -3,6 +3,12 @@
<script src="/resources/testharness.js"></script> <script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<div id="log"></div> <div id="log"></div>
<!-- First test shared pre-insertion checks that work similarly for replaceChild
and insertBefore -->
<script>
var insertFunc = Node.prototype.insertBefore;
</script>
<script src="pre-insertion-checks.js"></script>
<script> <script>
function testLeafNode(nodeName, createNodeFunction) { function testLeafNode(nodeName, createNodeFunction) {
test(function() { test(function() {
......
...@@ -5,6 +5,12 @@ ...@@ -5,6 +5,12 @@
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<body><a><b></b><c></c></a> <body><a><b></b><c></c></a>
<div id="log"></div> <div id="log"></div>
<!-- First test shared pre-insertion checks that work similarly for replaceChild
and insertBefore -->
<script>
var insertFunc = Node.prototype.replaceChild;
</script>
<script src="pre-insertion-checks.js"></script>
<script> <script>
// IDL. // IDL.
test(function() { test(function() {
...@@ -22,7 +28,7 @@ test(function() { ...@@ -22,7 +28,7 @@ test(function() {
}); });
}, "Passing null to replaceChild should throw a TypeError.") }, "Passing null to replaceChild should throw a TypeError.")
// Step 1. // Step 3.
test(function() { test(function() {
var a = document.createElement("div"); var a = document.createElement("div");
var b = document.createElement("div"); var b = document.createElement("div");
...@@ -39,14 +45,11 @@ test(function() { ...@@ -39,14 +45,11 @@ test(function() {
assert_throws("NotFoundError", function() { assert_throws("NotFoundError", function() {
a.replaceChild(b, a); a.replaceChild(b, a);
}); });
}, "If child's parent is not the context node, a NotFoundError exception should be thrown") }, "If child's parent is not the context node, a NotFoundError exception should be thrown");
// Step 1.
test(function() { test(function() {
var nodes = [ var nodes = getNonParentNodes();
document.implementation.createDocumentType("html", "", ""),
document.createTextNode("text"),
document.implementation.createDocument(null, "foo", null).createProcessingInstruction("foo", "bar"),
document.createComment("comment")
];
var a = document.createElement("div"); var a = document.createElement("div");
var b = document.createElement("div"); var b = document.createElement("div");
...@@ -55,7 +58,7 @@ test(function() { ...@@ -55,7 +58,7 @@ test(function() {
node.replaceChild(a, b); node.replaceChild(a, b);
}); });
}); });
}, "If the context node is not a node that can contain children, a NotFoundError exception should be thrown") }, "If the context node is not a node that can contain children, a HierarchyRequestError exception should be thrown")
// Step 2. // Step 2.
test(function() { test(function() {
...@@ -78,7 +81,7 @@ test(function() { ...@@ -78,7 +81,7 @@ test(function() {
}); });
}, "If node is an inclusive ancestor of the context node, a HierarchyRequestError should be thrown.") }, "If node is an inclusive ancestor of the context node, a HierarchyRequestError should be thrown.")
// Step 3.1. // Steps 4/5.
test(function() { test(function() {
var doc = document.implementation.createHTMLDocument("title"); var doc = document.implementation.createHTMLDocument("title");
var doc2 = document.implementation.createHTMLDocument("title2"); var doc2 = document.implementation.createHTMLDocument("title2");
...@@ -91,7 +94,7 @@ test(function() { ...@@ -91,7 +94,7 @@ test(function() {
}); });
}, "If the context node is a document, inserting a document or text node should throw a HierarchyRequestError.") }, "If the context node is a document, inserting a document or text node should throw a HierarchyRequestError.")
// Step 3.2.1. // Step 6.1.
test(function() { test(function() {
var doc = document.implementation.createHTMLDocument("title"); var doc = document.implementation.createHTMLDocument("title");
...@@ -127,7 +130,7 @@ test(function() { ...@@ -127,7 +130,7 @@ test(function() {
}); });
}, "If the context node is a document (without element children), inserting a DocumentFragment that contains multiple elements should throw a HierarchyRequestError.") }, "If the context node is a document (without element children), inserting a DocumentFragment that contains multiple elements should throw a HierarchyRequestError.")
// Step 3.2.2. // Step 6.1.
test(function() { test(function() {
// The context node has an element child that is not /child/. // The context node has an element child that is not /child/.
var doc = document.implementation.createHTMLDocument("title"); var doc = document.implementation.createHTMLDocument("title");
...@@ -157,7 +160,7 @@ test(function() { ...@@ -157,7 +160,7 @@ test(function() {
}); });
}, "If the context node is a document, inserting a DocumentFragment with an element before the doctype should throw a HierarchyRequestError.") }, "If the context node is a document, inserting a DocumentFragment with an element before the doctype should throw a HierarchyRequestError.")
// Step 3.3. // Step 6.2.
test(function() { test(function() {
var doc = document.implementation.createHTMLDocument("title"); var doc = document.implementation.createHTMLDocument("title");
var comment = doc.appendChild(doc.createComment("foo")); var comment = doc.appendChild(doc.createComment("foo"));
...@@ -183,7 +186,7 @@ test(function() { ...@@ -183,7 +186,7 @@ test(function() {
}); });
}, "If the context node is a document, inserting an element before the doctype should throw a HierarchyRequestError.") }, "If the context node is a document, inserting an element before the doctype should throw a HierarchyRequestError.")
// Step 3.4. // Step 6.3.
test(function() { test(function() {
var doc = document.implementation.createHTMLDocument("title"); var doc = document.implementation.createHTMLDocument("title");
var comment = doc.insertBefore(doc.createComment("foo"), doc.firstChild); var comment = doc.insertBefore(doc.createComment("foo"), doc.firstChild);
...@@ -209,7 +212,7 @@ test(function() { ...@@ -209,7 +212,7 @@ test(function() {
}); });
}, "If the context node is a document, inserting a doctype after the document element should throw a HierarchyRequestError.") }, "If the context node is a document, inserting a doctype after the document element should throw a HierarchyRequestError.")
// Step 4. // Steps 4/5.
test(function() { test(function() {
var df = document.createDocumentFragment(); var df = document.createDocumentFragment();
var a = df.appendChild(document.createElement("a")); var a = df.appendChild(document.createElement("a"));
...@@ -342,4 +345,5 @@ test(function() { ...@@ -342,4 +345,5 @@ test(function() {
parent.replaceChild(df, child); parent.replaceChild(df, child);
assert_equals(document.getElementById(TEST_ID), fragChild, "should not be null"); assert_equals(document.getElementById(TEST_ID), fragChild, "should not be null");
}, "Replacing an element with a DocumentFragment should allow a child of the DocumentFragment to be found by Id.") }, "Replacing an element with a DocumentFragment should allow a child of the DocumentFragment to be found by Id.")
</script> </script>
function getNonParentNodes() {
return [
document.implementation.createDocumentType("html", "", ""),
document.createTextNode("text"),
document.implementation.createDocument(null, "foo", null).createProcessingInstruction("foo", "bar"),
document.createComment("comment"),
document.implementation.createDocument(null, "foo", null).createCDATASection("data"),
];
}
function getNonInsertableNodes() {
return [
document.implementation.createHTMLDocument("title")
];
}
function getNonDocumentParentNodes() {
return [
document.createElement("div"),
document.createDocumentFragment(),
];
}
// Test that the steps happen in the right order, to the extent that it's
// observable. The variable names "parent", "child", and "node" match the
// corresponding variables in the replaceChild algorithm in these tests.
// Step 1 happens before step 3.
test(function() {
var illegalParents = getNonParentNodes();
var child = document.createElement("div");
var node = document.createElement("div");
illegalParents.forEach(function (parent) {
assert_throws("HierarchyRequestError", function() {
insertFunc.call(parent, node, child);
});
});
}, "Should check the 'parent' type before checking whether 'child' is a child of 'parent'");
// Step 2 happens before step 3.
test(function() {
var parent = document.createElement("div");
var child = document.createElement("div");
var node = document.createElement("div");
node.appendChild(parent);
assert_throws("HierarchyRequestError", function() {
insertFunc.call(parent, node, child);
});
}, "Should check that 'node' is not an ancestor of 'parent' before checking whether 'child' is a child of 'parent'");
// Step 3 happens before step 4.
test(function() {
var parent = document.createElement("div");
var child = document.createElement("div");
var illegalChildren = getNonInsertableNodes();
illegalChildren.forEach(function (node) {
assert_throws("NotFoundError", function() {
insertFunc.call(parent, node, child);
});
});
}, "Should check whether 'child' is a child of 'parent' before checking whether 'node' is of a type that can have a parent.");
// Step 3 happens before step 5.
test(function() {
var child = document.createElement("div");
var node = document.createTextNode("");
var parent = document.implementation.createDocument(null, "foo", null);
assert_throws("NotFoundError", function() {
insertFunc.call(parent, node, child);
});
node = document.implementation.createDocumentType("html", "", "");
getNonDocumentParentNodes().forEach(function (parent) {
assert_throws("NotFoundError", function() {
insertFunc.call(parent, node, child);
});
});
}, "Should check whether 'child' is a child of 'parent' before checking whether 'node' is of a type that can have a parent of the type that 'parent' is.");
// Step 3 happens before step 6.
test(function() {
var child = document.createElement("div");
var parent = document.implementation.createDocument(null, null, null);
var node = document.createDocumentFragment();
node.appendChild(document.createElement("div"));
node.appendChild(document.createElement("div"));
assert_throws("NotFoundError", function() {
insertFunc.call(parent, node, child);
});
node = document.createElement("div");
parent.appendChild(document.createElement("div"));
assert_throws("NotFoundError", function() {
insertFunc.call(parent, node, child);
});
parent.firstChild.remove();
parent.appendChild(document.implementation.createDocumentType("html", "", ""));
node = document.implementation.createDocumentType("html", "", "")
assert_throws("NotFoundError", function() {
insertFunc.call(parent, node, child);
});
}, "Should check whether 'child' is a child of 'parent' before checking whether 'node' can be inserted into the document given the kids the document has right now.");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment