tor-browser

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

browser_dbg-event-breakpoints-fission.js (2222B)


      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 add_task(async function () {
     10  const dbg = await initDebugger(
     11    "doc-event-breakpoints-fission.html",
     12    "event-breakpoints.js"
     13  );
     14 
     15  await selectSource(dbg, "event-breakpoints.js");
     16  await waitForSelectedSource(dbg, "event-breakpoints.js");
     17 
     18  await dbg.actions.addEventListenerBreakpoints("breakpoint", [
     19    "event.mouse.click",
     20    "event.xhr.load",
     21    "timer.timeout.set",
     22  ]);
     23 
     24  info("Assert early timeout event breakpoint gets hit");
     25  const waitForReload = reloadBrowser();
     26 
     27  await waitForPaused(dbg);
     28  await assertPausedAtSourceAndLine(
     29    dbg,
     30    findSource(dbg, "doc-event-breakpoints-fission.html").id,
     31    17
     32  );
     33  await resume(dbg);
     34 
     35  await waitForReload;
     36 
     37  info("Assert event breakpoints work in remote frame");
     38  await invokeAndAssertBreakpoints(dbg);
     39 
     40  info("reload the iframe");
     41  await SpecialPowers.spawn(gBrowser.selectedBrowser, [], () =>
     42    content.wrappedJSObject.reloadIframe()
     43  );
     44  info("Assert event breakpoints work in remote frame after reload");
     45  await invokeAndAssertBreakpoints(dbg);
     46 });
     47 
     48 async function invokeAndAssertBreakpoints(dbg) {
     49  invokeInTabRemoteFrame("clickHandler");
     50  await waitForPaused(dbg);
     51  await assertPausedAtSourceAndLine(
     52    dbg,
     53    findSource(dbg, "event-breakpoints.js").id,
     54    12
     55  );
     56  await resume(dbg);
     57 
     58  invokeInTabRemoteFrame("xhrHandler");
     59  await waitForPaused(dbg);
     60  await assertPausedAtSourceAndLine(
     61    dbg,
     62    findSource(dbg, "event-breakpoints.js").id,
     63    24
     64  );
     65  await resume(dbg);
     66 }
     67 
     68 async function invokeInTabRemoteFrame(fnc, ...args) {
     69  info(`Invoking in tab remote frame: ${fnc}(${args.map(uneval).join(",")})`);
     70  await SpecialPowers.spawn(
     71    gBrowser.selectedBrowser,
     72    [fnc, args],
     73    function (_fnc, _args) {
     74      return SpecialPowers.spawn(
     75        content.document.querySelector("iframe"),
     76        [_fnc, _args],
     77        (__fnc, __args) => content.wrappedJSObject[__fnc](...__args)
     78      );
     79    }
     80  );
     81 }