tor-browser

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

browser_inspector-release.js (2032B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 Services.scriptloader.loadSubScript(
      7  "chrome://mochitests/content/browser/devtools/server/tests/browser/inspector-helpers.js",
      8  this
      9 );
     10 
     11 add_task(async function loadNewChild() {
     12  const { target, walker } = await initInspectorFront(
     13    MAIN_DOMAIN + "inspector-traversal-data.html"
     14  );
     15 
     16  let originalOwnershipSize = 0;
     17  let longlist = null;
     18  let firstChild = null;
     19  const list = await walker.querySelectorAll(walker.rootNode, "#longlist div");
     20  // Make sure we have the 26 children of longlist in our ownership tree.
     21  is(list.length, 26, "Expect 26 div children.");
     22  // Make sure we've read in all those children and incorporated them
     23  // in our ownership tree.
     24  const items = await list.items();
     25  originalOwnershipSize = await assertOwnershipTrees(walker);
     26 
     27  // Here is how the ownership tree is summed up:
     28  // #document                      1
     29  //   <html>                       1
     30  //     <body>                     1
     31  //       <div id=longlist>        1
     32  //         <div id=a>a</div>   26*2 (each child plus it's singleTextChild)
     33  //         ...
     34  //         <div id=z>z</div>
     35  //                             -----
     36  //                               56
     37  is(originalOwnershipSize, 56, "Correct number of items in ownership tree");
     38  firstChild = items[0].actorID;
     39  // Now get the longlist and release it from the ownership tree.
     40  const node = await walker.querySelector(walker.rootNode, "#longlist");
     41  longlist = node.actorID;
     42  await walker.releaseNode(node);
     43  // Our ownership size should now be 53 fewer
     44  // (we forgot about #longlist + 26 children + 26 singleTextChild nodes)
     45  const newOwnershipSize = await assertOwnershipTrees(walker);
     46  is(
     47    newOwnershipSize,
     48    originalOwnershipSize - 53,
     49    "Ownership tree should be lower"
     50  );
     51  // Now verify that some nodes have gone away
     52  await checkMissing(target, longlist);
     53  await checkMissing(target, firstChild);
     54 });