Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /dom/nodes/moveBefore/tentative/css-transition-to-disconnected-document.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<title>Node.moveBefore should act like insertBefore when moving to a disconnected document</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<section id="old-parent">
<div id="item"></div>
</section>
<section id="new-parent">
</section>
<style>
#item {
width: 100px;
height: 100px;
background: green;
transition: left 10s;
position: absolute;
left: 0;
}
section {
position: relative;
}
body {
margin-left: 0;
}
</style>
<script>
promise_test(async t => {
const item = document.querySelector("#item");
assert_equals(item.getBoundingClientRect().x, 0);
item.style.left = "400px";
await new Promise(resolve => item.addEventListener("transitionstart", resolve));
const doc = document.implementation.createHTMLDocument();
// Calling `moveBefore()` on a cross-document element undergoing a
// transition does not move the element, nor alter the transition.
assert_throws_dom("HIERARCHY_REQUEST_ERR", () => {
doc.body.moveBefore(item, null);
});
await new Promise(resolve => requestAnimationFrame(() => resolve()));
assert_between_inclusive(item.getBoundingClientRect().x, 0, 20);
}, "Moving an element with a transition to a disconnected document should reset the transitionm state");
</script>
</body>