blob: 8533cc94f4a7a74252f8c32fc002b1eca9f88142 [file] [log] [blame]
<!DOCTYPE html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<script src="resources/shadow-dom.js"></script>
<div id="targets">
<div id="T0">
<div id="normal-target">Normal</div>
</div>
<div id="T1">
<template><div id="target">Shadow</div></template>
</div>
<div id="T2">
<template>
<div id="H">
<template><div id="target">Shadow in shadow</div></template>
</div>
</template>
</div>
<details id="T3"><div id="details-target">P3</div></details>
</div>
<script>
convertTemplatesToShadowRootsWithin(targets);
testSurroundContents("Normal", "normal-target", T0);
testSurroundContents("Shadow", "T1/target", T1);
testSurroundContents("Multi-level shadow", "T2/H/target", T2);
testSurroundContents("<details>", "details-target", T3);
function testSurroundContents(description, targetPath, newParent) {
test(function () {
var target = getNodeInComposedTree(targetPath);
var range = document.createRange();
range.selectNode(target);
assert_throws("HierarchyRequestError", function () {
range.surroundContents(newParent);
});
var targetAfter = getNodeInComposedTree(targetPath);
assert_equals(targetAfter, target, "DOM should not change after HierarchyRequestError");
}, description);
}
if (window.testRunner)
targets.style.display = "none";
</script>