tor-browser

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

browser_dbg-scopes-xrays.js (1937B)


      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 // Test that xrays do not interfere with examining objects in the scopes pane.
      6 
      7 "use strict";
      8 
      9 add_task(async function () {
     10  const dbg = await initDebugger("doc-scopes-xrays.html");
     11 
     12  invokeInTab("start");
     13  await waitForPaused(dbg, "doc-scopes-xrays.html");
     14 
     15  await toggleNode(dbg, "set");
     16  await toggleNode(dbg, "<entries>");
     17  await checkObjectNode(dbg, "0", "1");
     18  await toggleNode(dbg, "set");
     19 
     20  await toggleNode(dbg, "weakset");
     21  await toggleNode(dbg, "<entries>");
     22  await checkObjectNode(dbg, "0", "2");
     23  await toggleNode(dbg, "weakset");
     24 
     25  await toggleNode(dbg, "map");
     26  await toggleNode(dbg, "<entries>");
     27  await toggleNode(dbg, "0");
     28  await checkObjectNode(dbg, "<key>", "3");
     29  await toggleNode(dbg, "<key>");
     30  await checkObjectNode(dbg, "<value>", "4");
     31  await toggleNode(dbg, "map");
     32 
     33  await toggleNode(dbg, "weakmap");
     34  await toggleNode(dbg, "<entries>");
     35  await toggleNode(dbg, "0");
     36  await checkObjectNode(dbg, "<key>", "5");
     37  await toggleNode(dbg, "<key>");
     38  await checkObjectNode(dbg, "<value>", "6");
     39  await toggleNode(dbg, "weakmap");
     40 });
     41 
     42 function findNode(dbg, text) {
     43  for (let index = 0; ; index++) {
     44    const elem = findElement(dbg, "scopeNode", index);
     45    if (elem?.innerText == text) {
     46      return elem;
     47    }
     48  }
     49 }
     50 
     51 function toggleNode(dbg, text) {
     52  return toggleObjectInspectorNode(findNode(dbg, text));
     53 }
     54 
     55 function findNodeValue(dbg, text) {
     56  for (let index = 0; ; index++) {
     57    const elem = findElement(dbg, "scopeNode", index);
     58    if (elem?.innerText == text) {
     59      return getScopeNodeValue(dbg, index);
     60    }
     61  }
     62 }
     63 
     64 async function checkObjectNode(dbg, text, value) {
     65  await toggleNode(dbg, text);
     66  Assert.equal(findNodeValue(dbg, "a"), value, "object value");
     67 }