tor-browser

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

ShadowRoot.html (2319B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4 <title>Custom Elements: CEReactions on ShadowRoot interface</title>
      5 <meta name="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org">
      6 <meta name="assert" content="innerHTML of ShadowRoot interface must have CEReactions">
      7 <meta name="help" content="https://dom.spec.whatwg.org/#node">
      8 <script src="/resources/testharness.js"></script>
      9 <script src="/resources/testharnessreport.js"></script>
     10 <script src="../resources/custom-elements-helpers.js"></script>
     11 <script src="./resources/reactions.js"></script>
     12 </head>
     13 <body>
     14 <div id="log"></div>
     15 <script>
     16 
     17 test_with_window(function (contentWindow, contentDocument) {
     18    const element = define_custom_element_in_window(contentWindow, 'custom-element', []);
     19    const host = contentDocument.createElement('div');
     20    const shadowRoot = host.attachShadow({mode: 'closed'});
     21    shadowRoot.innerHTML = '<custom-element></custom-element>';
     22 
     23    assert_array_equals(element.takeLog().types(), ['constructed']);
     24 }, 'innerHTML on ShadowRoot must upgrade a custom element');
     25 
     26 test_with_window(function (contentWindow, contentDocument) {
     27    const element = define_custom_element_in_window(contentWindow, 'custom-element', []);
     28    const host = contentDocument.createElement('div');
     29    contentDocument.body.appendChild(host);
     30    const shadowRoot = host.attachShadow({mode: 'closed'});
     31    shadowRoot.innerHTML = '<custom-element></custom-element>';
     32 
     33    assert_array_equals(element.takeLog().types(), ['constructed', 'connected']);
     34 }, 'innerHTML on ShadowRoot must enqueue connectedCallback on newly upgraded custom elements when the shadow root is connected');
     35 
     36 test_with_window(function (contentWindow, contentDocument) {
     37    const element = define_custom_element_in_window(contentWindow, 'custom-element', []);
     38    const host = contentDocument.createElement('div');
     39    contentDocument.body.appendChild(host);
     40 
     41    const shadowRoot = host.attachShadow({mode: 'closed'});
     42    shadowRoot.innerHTML = '<custom-element></custom-element>';
     43    assert_array_equals(element.takeLog().types(), ['constructed', 'connected']);
     44 
     45    shadowRoot.innerHTML = '';
     46    assert_array_equals(element.takeLog().types(), ['disconnected']);
     47 
     48 }, 'innerHTML on ShadowRoot must enqueue disconnectedCallback when removing a custom element');
     49 
     50 </script>
     51 </body>
     52 </html>