tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

Element-interface-shadowRoot-attribute.html (2658B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4 <title>Shadow DOM: Element interface shadowRoot attribute</title>
      5 <meta name="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org">
      6 <meta name="assert" content="shadowRoot attribute on Element interface must return the associated open shadow tree if there is one">
      7 <link rel="help" href="https://w3c.github.io/webcomponents/spec/shadow/#the-shadowroot-interface">
      8 <script src="/resources/testharness.js"></script>
      9 <script src="/resources/testharnessreport.js"></script>
     10 </head>
     11 <body>
     12 <div id="log"></div>
     13 <script>
     14 
     15 test(function () {
     16    assert_true('shadowRoot' in Element.prototype, 'shadowRoot must be defined on Element prototype');
     17    assert_true('shadowRoot' in document.createElement('div'), 'shadowRoot must be defined on an instance of div element');
     18    assert_false('shadowRoot' in Node.prototype, 'shadowRoot must not be defined on Node prototype');
     19    assert_false('shadowRoot' in Text.prototype, 'shadowRoot must not be defined on Text prototype');
     20    assert_false('shadowRoot' in document.createTextNode(''), 'shadowRoot must not be defined on an instance of Text node');
     21    assert_false('shadowRoot' in Comment.prototype, 'shadowRoot must not be defined on Comment prototype');
     22    assert_false('shadowRoot' in document.createComment(''), 'shadowRoot must not be defined on an instance of Comment node');
     23    assert_false('shadowRoot' in Document.prototype, 'shadowRoot must not be defined on Document prototype');
     24    assert_false('shadowRoot' in document, 'shadowRoot must not be defined on an instance of Document');
     25    assert_false('shadowRoot' in DocumentFragment.prototype, 'shadowRoot must not be defined on DocumentFragment prototype');
     26    assert_false('shadowRoot' in (new DOMParser).parseFromString('', 'text/html'), 'shadowRoot must not be defined on an instance of DocumentFragment node');
     27 }, 'shadowRoot must be defined on Element prototype');
     28 
     29 test(function () {
     30    var host = document.createElement('div');
     31    assert_equals(host.shadowRoot, null, 'shadowRoot must return null when the host does not have a shadow tree attached to it');
     32 
     33    var openShadowRoot = host.attachShadow({mode: 'open'});
     34    assert_equals(host.shadowRoot, openShadowRoot, 'shadowRoot must return the open shadow root attachShadow attached');
     35 }, 'shadowRoot attribute must return the open shadow root associated with the element');
     36 
     37 test(function () {
     38    var host = document.createElement('div');
     39    host.attachShadow({mode: 'closed'});
     40    assert_equals(host.shadowRoot, null);
     41 }, 'shadowRoot attribute must return null if the shadow root attached to the element is closed');
     42 
     43 </script>
     44 </body>
     45 </html>