Skip to content

Commit

Permalink
Bug 1936153 [wpt PR 49603] - DOM: Enable moveBefore() into Document n…
Browse files Browse the repository at this point in the history
…odes, a=testonly

Automatic update from web-platform-tests
DOM: Enable moveBefore() into Document nodes

See
whatwg/dom#1307 (review).

[email protected]

Bug: 40150299
Change-Id: I01b148f65c9e9c2545e7287ae38eb0e39f57d3d3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6081493
Commit-Queue: Dominic Farolino <[email protected]>
Reviewed-by: Noam Rosenthal <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1394297}

--

wpt-commits: 64e219541d6cf8165e11c2625bba82381044075f
wpt-pr: 49603
  • Loading branch information
domfarolino authored and moz-wptsync-bot committed Dec 13, 2024
1 parent 6a3486b commit 7e1b7a8
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@
}, "moveBefore() on a cross-document target node throws a HierarchyRequestError");

// Pre-move validity, step 3:
// "If parent is not an Element node, then throw a "HierarchyRequestError"
// DOMException."
// "If parent is not a Document, DocumentFragment, or Element node, then throw a
// "HierarchyRequestError" DOMException."
//
// https://whatpr.org/dom/1307.html#concept-node-ensure-pre-move-validity
test(t => {
Expand All @@ -97,10 +97,20 @@

assert_throws_dom("HIERARCHY_REQUEST_ERR", iframe.contentWindow.DOMException, () => {
// Moving the body into the same place that it already is, which is a valid
// action in the normal case, when moving a node into an Element.
// action in the normal case, when moving an Element directly under the
// document. This is not `moveBefore()`-specific behavior; it is consistent
// with traditional Document insertion rules, just like `insertBefore()`.
iframe.contentDocument.moveBefore(innerBody, null);
});
}, "moveBefore() into a Document throws a HierarchyRequestError");
test(t => {
const iframe = document.body.appendChild(document.createElement('iframe'));
const comment = iframe.contentDocument.createComment("comment");
iframe.contentDocument.body.append(comment);

iframe.contentDocument.moveBefore(comment, null);
assert_equals(comment.parentNode, iframe.contentDocument);
}, "moveBefore() CharacterData into a Document");
test(t => {
const comment = document.body.appendChild(document.createComment("comment"));
const child = document.body.appendChild(document.createElement('p'));
Expand Down

0 comments on commit 7e1b7a8

Please sign in to comment.