tor-browser

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

browser_dbg-many-breakpoints-same-line.js (2989B)


      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 settings multiple types of breakpoints on the same line
      6 // Only the last should be used
      7 
      8 "use strict";
      9 
     10 // Line where we set a breakpoint in simple2.js
     11 const BREAKPOINT_LINE = 5;
     12 
     13 add_task(async function () {
     14  const dbg = await initDebugger("doc-scripts.html", "simple2.js");
     15 
     16  await selectSource(dbg, "simple2.js");
     17  await waitForSelectedSource(dbg, "simple2.js");
     18 
     19  await testSimpleAndLog(dbg);
     20 
     21  await testLogUpdates(dbg);
     22 });
     23 
     24 async function testSimpleAndLog(dbg) {
     25  info("Add a simple breakpoint");
     26  await addBreakpoint(dbg, "simple2.js", BREAKPOINT_LINE);
     27 
     28  info("Add a log breakpoint, replacing the breakpoint into a logpoint");
     29  await setLogPoint(dbg, BREAKPOINT_LINE, "`log point ${x}`");
     30  await waitForLog(dbg, "`log point ${x}`");
     31  await assertLogBreakpoint(dbg, BREAKPOINT_LINE);
     32 
     33  const bp = findBreakpoint(dbg, "simple2.js", BREAKPOINT_LINE);
     34  is(
     35    bp.options.logValue,
     36    "`log point ${x}`",
     37    "log breakpoint value is correct"
     38  );
     39 
     40  info(
     41    "Eval foo() and trigger the breakpoints. If this freeze here, it means that the log point has been ignored."
     42  );
     43  await SpecialPowers.spawn(gBrowser.selectedBrowser, [], function () {
     44    content.wrappedJSObject.foo(42);
     45  });
     46 
     47  info(
     48    "Wait for the log-point message. Only log-point breakpoint should work."
     49  );
     50 
     51  await waitForMessageByType(dbg, "log point 42", ".logPoint");
     52 
     53  const source = findSource(dbg, "simple2.js");
     54  await removeBreakpoint(dbg, source.id, BREAKPOINT_LINE);
     55 }
     56 
     57 async function testLogUpdates(dbg) {
     58  info("Add a log breakpoint");
     59  await setLogPoint(dbg, BREAKPOINT_LINE, "`log point`");
     60  await waitForLog(dbg, "`log point`");
     61  await assertLogBreakpoint(dbg, BREAKPOINT_LINE);
     62 
     63  const bp = findBreakpoint(dbg, "simple2.js", BREAKPOINT_LINE);
     64  is(bp.options.logValue, "`log point`", "log breakpoint value is correct");
     65 
     66  info("Edit the log breakpoint");
     67  await setLogPoint(dbg, BREAKPOINT_LINE, " + ` edited`");
     68  await waitForLog(dbg, "`log point` + ` edited`");
     69  await assertLogBreakpoint(dbg, BREAKPOINT_LINE);
     70 
     71  const bp2 = findBreakpoint(dbg, "simple2.js", BREAKPOINT_LINE);
     72  is(
     73    bp2.options.logValue,
     74    "`log point` + ` edited`",
     75    "log breakpoint value is correct"
     76  );
     77 
     78  info("Eval foo() and trigger the breakpoints");
     79  await SpecialPowers.spawn(gBrowser.selectedBrowser, [], function () {
     80    content.wrappedJSObject.foo();
     81  });
     82 
     83  info("Wait for the log-point message. Only the edited one should appear");
     84  await waitForMessageByType(dbg, "log point edited", ".logPoint");
     85 }
     86 
     87 async function waitForMessageByType(dbg, msg, typeSelector) {
     88  const webConsolePanel = await getDebuggerSplitConsole(dbg);
     89  const hud = webConsolePanel.hud;
     90  return waitFor(
     91    async () => !!findMessagesByType(hud, msg, typeSelector).length
     92  );
     93 }