tor-browser

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

browser_dbg-pretty-print-flow.js (2539B)


      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 loader and new tab appear when pretty printing,
      6 // and the selected location is mapped afterwards
      7 
      8 "use strict";
      9 
     10 add_task(async function () {
     11  const dbg = await initDebugger("doc-pretty.html", "pretty.js");
     12 
     13  SpecialPowers.spawn(gBrowser.selectedBrowser, [], () => {
     14    const scriptEl = content.document.createElement("script");
     15    scriptEl.innerText = `(function callInPretty() { debugger; funcWithMultipleBreakableColumns() })()`;
     16    content.document.body.append(scriptEl);
     17  });
     18 
     19  await waitForPaused(dbg);
     20  const scriptSource = dbg.selectors.getSelectedSource();
     21 
     22  info(
     23    "Step-in to navigate to pretty.js `funcWithMultipleBreakableColumns` function"
     24  );
     25  await stepOver(dbg);
     26  await stepIn(dbg);
     27  await waitForSelectedSource(dbg, "pretty.js");
     28  await waitForSelectedLocation(dbg, 9);
     29 
     30  is(
     31    countTabs(dbg),
     32    2,
     33    "Two tabs are opened, one for the dynamically inserted script and one for minified pretty.js"
     34  );
     35  is(
     36    dbg.selectors.getSourceCount(),
     37    2,
     38    "There are 2 sources before pretty printing"
     39  );
     40  await togglePrettyPrint(dbg);
     41 
     42  info("Wait for the pretty printed source to be selected on a different line");
     43  await waitForSelectedLocation(dbg, 11);
     44 
     45  is(countTabs(dbg), 2, "Pretty printing did not open any new tab");
     46  is(
     47    dbg.selectors.getSourceCount(),
     48    3,
     49    "There are three sources after pretty printing"
     50  );
     51 
     52  info("Navigate to previous frame in call stack");
     53  clickElement(dbg, "frame", 2);
     54  await waitForPaused(dbg, scriptSource);
     55 
     56  info("Navigate back to `funcWithMultipleBreakableColumns` frame");
     57  clickElement(dbg, "frame", 1);
     58  await waitForPaused(dbg, "pretty.js:formatted");
     59  await waitForSelectedLocation(dbg, 11, 17);
     60  ok(true, "pretty-printed source was selected");
     61 
     62  await resume(dbg);
     63 
     64  info("Re select the minified version");
     65  await togglePrettyPrint(dbg);
     66  await waitForSelectedLocation(dbg, 9, 17);
     67 
     68  info("Re toggle pretty print from the minified source");
     69  await togglePrettyPrint(dbg);
     70  is(countTabs(dbg), 2, "There are still two tabs");
     71  info(
     72    "Wait for re-selecting the mapped location in the pretty printed source"
     73  );
     74  await waitForSelectedLocation(dbg, 11, 17);
     75  is(
     76    dbg.selectors.getSourceCount(),
     77    3,
     78    "There are still 3 sources after retrying to pretty print the same source"
     79  );
     80 });