tor-browser

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

browser_dbg-event-breakpoints-unsupported.js (2215B)


      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 early event breakpoints and event breakpoints in a remote frame.
      6 
      7 "use strict";
      8 
      9 const BAD_EVENT_ID = "event.dom-mutation.DOMSubtreeModified";
     10 
     11 add_task(async function () {
     12  info(
     13    "Open and close the debugger a first time to prime the preferences and async storage"
     14  );
     15  let dbg = await initDebugger("doc-event-breakpoints.html");
     16  await dbg.toolbox.closeToolbox();
     17 
     18  info("Update the event listeners breakpoint data with an invalid event id");
     19  const staleEventListenerBreakpointsState = {
     20    categories: [],
     21    byPanel: {
     22      breakpoint: {
     23        active: [BAD_EVENT_ID],
     24        expanded: [],
     25      },
     26      tracer: { expanded: [] },
     27    },
     28    logEventBreakpoints: false,
     29    active: [],
     30    expanded: [],
     31  };
     32  await asyncStorage.setItem(
     33    "debugger.event-listener-breakpoints",
     34    staleEventListenerBreakpointsState
     35  );
     36 
     37  // Note: DO NOT use initDebugger here, as it would clear storage and
     38  // preferences.
     39  info("Reopen the debugger without resetting preferences");
     40  const toolbox = await openNewTabAndToolbox(
     41    EXAMPLE_URL + "doc-event-breakpoints.html",
     42    "jsdebugger"
     43  );
     44  dbg = createDebuggerContext(toolbox);
     45  await waitForSources(dbg, "event-breakpoints.js");
     46 
     47  await selectSource(dbg, "event-breakpoints.js");
     48  await waitForSelectedSource(dbg, "event-breakpoints.js");
     49  const eventBreakpointsSource = findSource(dbg, "event-breakpoints.js");
     50 
     51  info("Check that an event breakpoint can still be set");
     52  await toggleEventBreakpoint(dbg, "Mouse", "event.mouse.click");
     53 
     54  invokeInTab("clickHandler");
     55  await waitForPaused(dbg);
     56  await assertPausedAtSourceAndLine(dbg, eventBreakpointsSource.id, 12);
     57 
     58  const sanitizedEventListenerBreakpointsState = await asyncStorage.getItem(
     59    "debugger.event-listener-breakpoints"
     60  );
     61  const sanitizedActive =
     62    sanitizedEventListenerBreakpointsState.byPanel.breakpoint.active;
     63  ok(!sanitizedActive.includes(BAD_EVENT_ID));
     64  ok(sanitizedActive.includes("event.mouse.click"));
     65 
     66  await resume(dbg);
     67 });