tor-browser

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

browser_dbg-sources-tree.js (1737B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
      4 
      5 // Tests how directories that contain only one child which is a directory
      6 // are merged with their child in the sources tree and separated again
      7 // when another child is added (Bug 1967248).
      8 
      9 "use strict";
     10 
     11 add_task(async function () {
     12  const dbg = await initDebugger("doc-nested-sources.html");
     13 
     14  await waitForSources(dbg, "deep-nested-source.js");
     15  await selectSource(dbg, "deep-nested-source.js");
     16 
     17  checkSourceTree(dbg, [
     18    ["Main Thread", 1],
     19    ["example.com", 2],
     20    ["browser/devtools/client/debugger/test/mochitest/examples", 3],
     21    ["nested/deep", 4],
     22    ["deep-nested-source.js", 5],
     23    ["doc-nested-sources.html", 4],
     24  ]);
     25 
     26  invokeInTab("loadScript");
     27  await waitForSources(dbg, "nested-source.js");
     28 
     29  checkSourceTree(dbg, [
     30    ["Main Thread", 1],
     31    ["example.com", 2],
     32    ["browser/devtools/client/debugger/test/mochitest/examples", 3],
     33    ["nested", 4],
     34    ["deep", 5],
     35    ["deep-nested-source.js", 6],
     36    ["nested-source.js", 5],
     37    ["doc-nested-sources.html", 4],
     38  ]);
     39 });
     40 
     41 function checkSourceTree(dbg, expected) {
     42  const treeNodes = getDisplayedSourceTree(dbg);
     43  is(
     44    expected.length,
     45    treeNodes.length,
     46    "The source tree has the expected number of nodes"
     47  );
     48 
     49  for (let i = 0; i < expected.length; i++) {
     50    const node = treeNodes[i];
     51    const [label, level] = expected[i];
     52    is(
     53      node.querySelector(".label").textContent,
     54      label,
     55      `The node has the expected label`
     56    );
     57    is(Number(node.ariaLevel), level, `The node has the expected level`);
     58  }
     59 }