Skip to content

Commit

Permalink
Bug 1936820 [wpt PR 49653] - moveBefore: fail when moving across root…
Browse files Browse the repository at this point in the history
…s, a=testonly

Automatic update from web-platform-tests
moveBefore: fail when moving across roots

This applies the recent spec conversation in
whatwg/dom#1307 (comment)
where the moved & parent node have to be in the same
shadow-including root, not only in the same document.

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

--

wpt-commits: e26600a08505dbdf907bce572f97c2f560b3bc29
wpt-pr: 49653
  • Loading branch information
noamr authored and moz-wptsync-bot committed Dec 16, 2024
1 parent c5be599 commit f3bf07b
Showing 1 changed file with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,34 @@
const disconnectedDestination = document.createElement('div');
const p = disconnectedOrigin.appendChild(document.createElement('p'));

assert_throws_dom("HIERARCHY_REQUEST_ERR", () => {
disconnectedDestination.moveBefore(p, null);
});
}, "Moving a node from a disconnected container to a disconnected new parent " +
"without a shared ancestor throws a HIERARCHY_REQUEST_ERR");

test(() => {
const disconnectedOrigin = document.createElement('div');
const disconnectedDestination = disconnectedOrigin.appendChild(document.createElement('div'));
const p = disconnectedOrigin.appendChild(document.createElement('p'));

disconnectedDestination.moveBefore(p, null);

assert_equals(disconnectedDestination.firstChild, p, "<p> Was successfully moved");
}, "Moving a node from a disconnected container to a disconnected new parent in the same tree succeeds");

test(() => {
const disconnectedOrigin = document.createElement('div');
const disconnectedHost = disconnectedOrigin.appendChild(document.createElement('div'));
const p = disconnectedOrigin.appendChild(document.createElement('p'));
const shadow = disconnectedHost.attachShadow({mode: "closed"});
const disconnectedDestination = shadow.appendChild(document.createElement('div'));

disconnectedDestination.moveBefore(p, null);

assert_equals(disconnectedDestination.firstChild, p, "<p> Was successfully moved");
}, "Moving a node from a disconnected container to a disconnected new parent succeeds");
}, "Moving a node from a disconnected container to a disconnected new parent in the same tree succeeds," +
"also across shadow-roots");

test(() => {
const disconnectedOrigin = document.createElement('div');
Expand Down Expand Up @@ -285,7 +309,7 @@
});

const oldParent = document.createElement('div');
const newParent = document.createElement('div');
const newParent = oldParent.appendChild(document.createElement('div'));
const element = oldParent.appendChild(document.createElement(element_name));
t.add_cleanup(() => {
element.remove();
Expand Down

0 comments on commit f3bf07b

Please sign in to comment.