tor-browser

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

browser_dbg-pretty-print-breakpoints-columns.js (3429B)


      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 that breakpoints set in the pretty printed files display and paused
      6 // correctly.
      7 
      8 "use strict";
      9 
     10 add_task(async function () {
     11  const dbg = await initDebugger("doc-pretty.html", "pretty.js");
     12 
     13  await selectSource(dbg, "pretty.js");
     14  await togglePrettyPrint(dbg);
     15 
     16  info(
     17    "Add breakpoint in funcWithMultipleBreakableColumns, on the for-loop line"
     18  );
     19  const LINE_INDEX_TO_BREAK_ON = 15;
     20  const prettySourceFileName = "pretty.js:formatted";
     21  await addBreakpoint(dbg, prettySourceFileName, LINE_INDEX_TO_BREAK_ON);
     22  const prettySource = findSource(dbg, prettySourceFileName);
     23 
     24  info("Check that multiple column breakpoints can be set");
     25  const columnBreakpointMarkers = await waitForAllElements(
     26    dbg,
     27    "columnBreakpoints"
     28  );
     29  /*
     30   * We're pausing on the following line, which should have those breakpoints (marked with ➤)
     31   *
     32   * for( ➤let i=0; ➤i < items.length; ➤i++ ) {
     33   *
     34   */
     35  is(
     36    columnBreakpointMarkers.length,
     37    3,
     38    "We have the expected numbers of possible column breakpoints"
     39  );
     40 
     41  info("Enable the second column breakpoint");
     42  columnBreakpointMarkers[1].click();
     43  await waitForBreakpointCount(dbg, 2);
     44  await waitForAllElements(dbg, "breakpointItems", 2);
     45 
     46  info("Check that we do pause at expected locations");
     47  invokeInTab("funcWithMultipleBreakableColumns");
     48 
     49  info("We pause on the first column breakpoint (before `i` init)");
     50  await waitForPaused(dbg);
     51  await waitForInlinePreviews(dbg);
     52  await assertPausedAtSourceAndLine(
     53    dbg,
     54    prettySource.id,
     55    LINE_INDEX_TO_BREAK_ON,
     56    16
     57  );
     58  await resume(dbg);
     59 
     60  info(
     61    "We pause at the second column breakpoint, before the first loop iteration"
     62  );
     63  await waitForPaused(dbg);
     64  await waitForInlinePreviews(dbg);
     65  await assertPausedAtSourceAndLine(
     66    dbg,
     67    prettySource.id,
     68    LINE_INDEX_TO_BREAK_ON,
     69    19
     70  );
     71  const assertScopesForSecondColumnBreakpoint = topBlockItems =>
     72    assertScopes(dbg, [
     73      "Block",
     74      ["<this>", "Window"],
     75      ...topBlockItems,
     76      "funcWithMultipleBreakableColumns",
     77      ["arguments", "Arguments"],
     78      ["items", "(2) […]"],
     79    ]);
     80  await assertScopesForSecondColumnBreakpoint([["i", "0"]]);
     81  await resume(dbg);
     82 
     83  info(
     84    "We pause at the second column breakpoint, before the second loop iteration"
     85  );
     86  await waitForPaused(dbg);
     87  await waitForInlinePreviews(dbg);
     88  await assertPausedAtSourceAndLine(
     89    dbg,
     90    prettySource.id,
     91    LINE_INDEX_TO_BREAK_ON,
     92    19
     93  );
     94  await assertScopesForSecondColumnBreakpoint([["i", "1"]]);
     95  await resume(dbg);
     96 
     97  info(
     98    "We pause at the second column breakpoint, before we exit the loop (`items.length` is 2, so the condition will fail)"
     99  );
    100  await waitForPaused(dbg);
    101  await waitForInlinePreviews(dbg);
    102  await assertPausedAtSourceAndLine(
    103    dbg,
    104    prettySource.id,
    105    LINE_INDEX_TO_BREAK_ON,
    106    19
    107  );
    108  await assertScopesForSecondColumnBreakpoint([["i", "2"]]);
    109  await resume(dbg);
    110 
    111  info("Remove all breakpoints");
    112  await clickGutter(dbg, LINE_INDEX_TO_BREAK_ON);
    113  await waitForBreakpointCount(dbg, 0);
    114 
    115  ok(
    116    !findAllElements(dbg, "columnBreakpoints").length,
    117    "There is no column breakpoints anymore after clicking on the gutter"
    118  );
    119 });