tor-browser

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

browser_dbg-breakpoints-actions.js (3054B)


      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 "use strict";
      6 
      7 // Tests to see if we can trigger a breakpoint action via the context menu
      8 add_task(async function () {
      9  const dbg = await initDebugger("doc-scripts.html", "simple2.js");
     10  await selectSource(dbg, "simple2.js");
     11  await waitForSelectedSource(dbg, "simple2.js");
     12 
     13  await addBreakpoint(dbg, "simple2.js", 3);
     14 
     15  await openFirstBreakpointContextMenu(dbg);
     16  // select "Remove breakpoint"
     17  selectContextMenuItem(dbg, selectors.breakpointContextMenu.remove);
     18 
     19  await waitForState(dbg, () => dbg.selectors.getBreakpointCount() === 0);
     20  ok(true, "successfully removed the breakpoint");
     21 });
     22 
     23 // Tests "disable others", "enable others" and "remove others" context actions
     24 add_task(async function () {
     25  const dbg = await initDebugger("doc-scripts.html");
     26  await selectSource(dbg, "simple1.js");
     27  await waitForSelectedSource(dbg, "simple1.js");
     28 
     29  await addBreakpoint(dbg, "simple1.js", 4);
     30  await addBreakpoint(dbg, "simple1.js", 5);
     31  await addBreakpoint(dbg, "simple1.js", 6);
     32 
     33  await openFirstBreakpointContextMenu(dbg);
     34  // select "Disable Others"
     35  let dispatched = waitForDispatch(dbg.store, "SET_BREAKPOINT", 2);
     36  selectContextMenuItem(dbg, selectors.breakpointContextMenu.disableOthers);
     37  await waitForState(dbg, () =>
     38    dbg.selectors
     39      .getBreakpointsList()
     40      .every(bp => (bp.location.line !== 4) === bp.disabled)
     41  );
     42  await dispatched;
     43  ok(true, "breakpoint at 4 is the only enabled breakpoint");
     44 
     45  await openFirstBreakpointContextMenu(dbg);
     46  // select "Disable All"
     47  dispatched = waitForDispatch(dbg.store, "SET_BREAKPOINT");
     48  selectContextMenuItem(dbg, selectors.breakpointContextMenu.disableAll);
     49  await waitForState(dbg, () =>
     50    dbg.selectors.getBreakpointsList().every(bp => bp.disabled)
     51  );
     52  await dispatched;
     53  ok(true, "all breakpoints are disabled");
     54 
     55  await openFirstBreakpointContextMenu(dbg);
     56  // select "Enable Others"
     57  dispatched = waitForDispatch(dbg.store, "SET_BREAKPOINT", 2);
     58  selectContextMenuItem(dbg, selectors.breakpointContextMenu.enableOthers);
     59  await waitForState(dbg, () =>
     60    dbg.selectors
     61      .getBreakpointsList()
     62      .every(bp => (bp.location.line === 4) === bp.disabled)
     63  );
     64  await dispatched;
     65  ok(true, "all breakpoints except line 1 are enabled");
     66 
     67  await openFirstBreakpointContextMenu(dbg);
     68  // select "Remove Others"
     69  dispatched = waitForDispatch(dbg.store, "REMOVE_BREAKPOINT", 2);
     70  selectContextMenuItem(dbg, selectors.breakpointContextMenu.removeOthers);
     71  await waitForState(
     72    dbg,
     73    () =>
     74      dbg.selectors.getBreakpointsList().length === 1 &&
     75      dbg.selectors.getBreakpointsList()[0].location.line === 4
     76  );
     77  await dispatched;
     78  ok(true, "remaining breakpoint should be on line 4");
     79 });
     80 
     81 async function openFirstBreakpointContextMenu(dbg) {
     82  rightClickElement(dbg, "breakpointItem", 2);
     83  await waitForContextMenu(dbg);
     84 }