https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 6f869cd68557949f12ca6b640ddbd8c505a4decb authored by L. David Baron on 09 April 2018, 04:44:44 UTC
Sync Mozilla tests as of https://hg.mozilla.org/mozilla-central/rev/b4bc6b2401738b78fd47127a4c716bb9178e1a09 .
Tip revision: 6f869cd
Document-prototype-adoptNode.html
<!DOCTYPE html>
<html>
<head>
<title>DOM and Shadow DOM: Document.prototype.adoptNode</title>
<meta name="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org">
<meta name="assert" content="The adoptNode(node) method must throw a HierarchyRequestError exception if node is a shadow root.">
<link rel="help" href="https://dom.spec.whatwg.org/#dom-document-adoptnode">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
<script>

function testAdoptNode(mode) {
    test(function () {
        var newDocument = document.implementation.createHTMLDocument();
        assert_throws({'name': 'HierarchyRequestError'}, function () {
            var element = document.createElement('div');
            var shadowRoot = element.attachShadow({mode: mode});
            newDocument.adoptNode(shadowRoot);
        });
    }, 'adoptNode on a shadow root in ' + mode + ' mode must throw a HierarchyRequestError');
}

testAdoptNode('open');
testAdoptNode('closed');

</script>
</body>
</html>
back to top