tor-browser

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

ElementInternals-target-element-is-held-strongly.html (921B)


      1 <!DOCTYPE html>
      2 <title>Target element of ElementsInternals is held strongly and doesn't get GCed if there are no other references</title>
      3 <meta name="timeout" content="long">
      4 <body>
      5 <script src="/resources/testharness.js"></script>
      6 <script src="/resources/testharnessreport.js"></script>
      7 <script src="/common/gc.js"></script>
      8 
      9 <script>
     10 customElements.define("x-foo", class extends HTMLElement {});
     11 
     12 promise_test(async t => {
     13    const elementInternals = [];
     14 
     15    for (let i = 0; i < 1e5; i++) {
     16        const targetElement = document.createElement("x-foo");
     17        targetElement.attachShadow({ mode: "open" });
     18        elementInternals.push(targetElement.attachInternals());
     19    }
     20 
     21    await garbageCollect();
     22    await new Promise(r => t.step_timeout(r, 100));
     23 
     24    const allShadowRootsAreAlive = elementInternals.every(eI => eI.shadowRoot instanceof ShadowRoot);
     25    assert_true(allShadowRootsAreAlive);
     26 });
     27 </script>