blob: 92cdddfa74ce2f5f5d3f71a4341411d610a257f1 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script>
if (!window.internals)
debug("windows.internals not found!");
else if (!window.internals.hasShadowInsertionPoint)
debug("windows.internals.hasShadowInsertionPoint not found!");
</script>
</head>
<body>
<p>Test for Bug <a href="https://bugs.webkit.org/show_bug.cgi?id=97184">97184</a> and <a href="https://bugs.webkit.org/show_bug.cgi?id=104346">104346</a> : HTMLShadowElement should be registered correctly.</p>
<div id="wrapper"></div>
<pre id="console"></pre>
<script>
function doTest() {
shouldBeFalse("internals.hasShadowInsertionPoint(shadowRoot)");
var div = document.createElement("div");
div.appendChild(document.createElement("shadow"));
shadowRoot.appendChild(div);
shouldBeTrue("internals.hasShadowInsertionPoint(shadowRoot)");
shadowRoot.removeChild(div);
shouldBeFalse("internals.hasShadowInsertionPoint(shadowRoot)");
shadowRoot.innerHTML = "<div>No Insertion Points</div>";
shouldBeFalse("internals.hasShadowInsertionPoint(shadowRoot)");
shadowRoot.innerHTML = "<content></content>";
shouldBeFalse("internals.hasShadowInsertionPoint(shadowRoot)");
shadowRoot.innerHTML = "<shadow></shadow>";
shouldBeTrue("internals.hasShadowInsertionPoint(shadowRoot)");
shadowRoot.innerHTML = "<div><div><div><shadow></shadow></div></div></div>";
shouldBeTrue("internals.hasShadowInsertionPoint(shadowRoot)");
youngerShadowRoot = host.createShadowRoot(host);
// Modifying older shadow root or younger shadow root doesn't affect the other.
shouldBeTrue("internals.hasShadowInsertionPoint(shadowRoot)");
shouldBeFalse("internals.hasShadowInsertionPoint(youngerShadowRoot)");
shadowRoot.innerHTML = "<content></content>";
shouldBeFalse("internals.hasShadowInsertionPoint(shadowRoot)");
shouldBeFalse("internals.hasShadowInsertionPoint(youngerShadowRoot)");
youngerShadowRoot.innerHTML = "<shadow></shadow>";
shouldBeFalse("internals.hasShadowInsertionPoint(shadowRoot)");
shouldBeTrue("internals.hasShadowInsertionPoint(youngerShadowRoot)");
}
debug('In the case host is in document');
host = document.createElement('div');
wrapper.appendChild(host);
shadowRoot = host.createShadowRoot();
doTest();
wrapper.innerHTML = "";
debug('In the case host is not in document');
host = document.createElement('div');
shadowRoot = host.createShadowRoot();
doTest();
wrapper.innerHTML = "";
debug('insertedInto/removedFrom can be called several times.');
var host = document.createElement('div');
var shadow = document.createElement('shadow');
var div1 = document.createElement('div');
var div2 = document.createElement('div');
var shadowRoot = host.createShadowRoot();
div1.appendChild(shadow);
shouldBeFalse('internals.hasShadowInsertionPoint(shadowRoot)');
shadowRoot.appendChild(div1);
shouldBeTrue('internals.hasShadowInsertionPoint(shadowRoot)');
div2.appendChild(host);
shouldBeTrue('internals.hasShadowInsertionPoint(shadowRoot)');
div2.removeChild(host);
shouldBeTrue('internals.hasShadowInsertionPoint(shadowRoot)');
shadowRoot.removeChild(div1);
shouldBeFalse('internals.hasShadowInsertionPoint(shadowRoot)');
div1.removeChild(shadow);
</script>
</body>
</html>