https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 0cdeea831cad1521409387c055d5f2c702a1dd88 authored by Ian Clelland on 11 April 2018, 02:30:42 UTC
Make DOMTokenList.supports() case-insensitive
Tip revision: 0cdeea8
Element-interface-shadowRoot-attribute.html
<!DOCTYPE html>
<html>
<head>
<title>Shadow DOM: Element interface shadowRoot attribute</title>
<meta name="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org">
<meta name="assert" content="shadowRoot attribute on Element interface must return the associated open shadow tree if there is one">
<link rel="help" href="https://w3c.github.io/webcomponents/spec/shadow/#the-shadowroot-interface">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
<script>

test(function () {
    assert_true('shadowRoot' in Element.prototype, 'shadowRoot must be defined on Element prototype');
    assert_true('shadowRoot' in document.createElement('div'), 'shadowRoot must be defined on an instance of div element');
    assert_false('shadowRoot' in Node.prototype, 'shadowRoot must not be defined on Node prototype');
    assert_false('shadowRoot' in Text.prototype, 'shadowRoot must not be defined on Text prototype');
    assert_false('shadowRoot' in document.createTextNode(''), 'shadowRoot must not be defined on an instance of Text node');
    assert_false('shadowRoot' in Comment.prototype, 'shadowRoot must not be defined on Comment prototype');
    assert_false('shadowRoot' in document.createComment(''), 'shadowRoot must not be defined on an instance of Comment node');
    assert_false('shadowRoot' in Document.prototype, 'shadowRoot must not be defined on Document prototype');
    assert_false('shadowRoot' in document, 'shadowRoot must not be defined on an instance of Document');
    assert_false('shadowRoot' in DocumentFragment.prototype, 'shadowRoot must not be defined on DocumentFragment prototype');
    assert_false('shadowRoot' in (new DOMParser).parseFromString('', 'text/html'), 'shadowRoot must not be defined on an instance of DocumentFragment node');
}, 'shadowRoot must be defined on Element prototype');

test(function () {
    var host = document.createElement('div');
    assert_equals(host.shadowRoot, null, 'shadowRoot must return null when the host does not have a shadow tree attached to it');

    var openShadowRoot = host.attachShadow({mode: 'open'});
    assert_equals(host.shadowRoot, openShadowRoot, 'shadowRoot must return the open shadow root attachShadow attached');
}, 'shadowRoot attribute must return the open shadow root associated with the element');

test(function () {
    var host = document.createElement('div');
    host.attachShadow({mode: 'closed'});
    assert_equals(host.shadowRoot, null);
}, 'shadowRoot attribute must return null if the shadow root attached to the element is closed');

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