tor-browser

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

browser_dbg-breakpoints-same-file-per-target.js (3206B)


      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 shows that breakpoints per url feature works in the debugger.
      6 
      7 "use strict";
      8 
      9 add_task(async function () {
     10  const dbg = await initDebugger(
     11    "doc_dbg-same-source-distinct-threads.html",
     12    "same-script.js"
     13  );
     14 
     15  // There is one source but 3 source actors. One per same-script.js instance,
     16  // one <script> tag, one worker and one <script> tag in the iframe.
     17  const source = findSource(dbg, "same-script.js");
     18  await waitUntil(
     19    () => dbg.selectors.getSourceActorsForSource(source.id).length == 3
     20  );
     21 
     22  info("Add a breakpoint to the same-script.js from the iframe");
     23  await selectSource(dbg, source);
     24  await addBreakpoint(dbg, source, 5);
     25 
     26  info("Click in the page of the top-level document");
     27  BrowserTestUtils.synthesizeMouseAtCenter(
     28    "body",
     29    {},
     30    gBrowser.selectedBrowser
     31  );
     32 
     33  await waitForPaused(dbg);
     34 
     35  is(
     36    dbg.selectors.getSelectedSource().id,
     37    source.id,
     38    "The current selected source is the `same-script.js` from the main thread"
     39  );
     40 
     41  info("Assert that the breakpoint pauses on line 5");
     42  await assertPausedAtSourceAndLine(dbg, source.id, 5);
     43 
     44  // This fails at the moment as there is no visible breakpoint on this line
     45  info("Assert that there is a breakpoint displayed on line 5");
     46  await assertBreakpoint(dbg, 5);
     47 
     48  info("Check that only one breakpoint currently exists");
     49  is(dbg.selectors.getBreakpointCount(), 1, "One breakpoint exists");
     50 
     51  await resume(dbg);
     52 
     53  info(
     54    "Trigger the breakpoint in the worker thread to make sure it hit the breakpoint"
     55  );
     56 
     57  invokeInTab("postMessageToWorker");
     58  await waitForPaused(dbg);
     59 
     60  is(
     61    dbg.selectors.getSelectedSource().id,
     62    source.id,
     63    "The current selected source is the `same-script.js` from the worker thread"
     64  );
     65 
     66  info("Assert that the breakpoint pauses on line 5");
     67  await assertPausedAtSourceAndLine(dbg, source.id, 5);
     68 
     69  info("Assert that there is a breakpoint dispalyed on line 5");
     70  await assertBreakpoint(dbg, 5);
     71 
     72  info("Check that only one breakpoint still currently exists");
     73  is(dbg.selectors.getBreakpointCount(), 1, "One breakpoint exists");
     74 
     75  await resume(dbg);
     76 
     77  info("Trigger breakpoint in the iframe to make sure it hits the breakpoint");
     78 
     79  const iframeBrowsingContext = await SpecialPowers.spawn(
     80    gBrowser.selectedBrowser,
     81    [],
     82    async () => {
     83      return content.document.querySelector("iframe").browsingContext;
     84    }
     85  );
     86 
     87  BrowserTestUtils.synthesizeMouseAtCenter("body", {}, iframeBrowsingContext);
     88 
     89  await waitForPaused(dbg);
     90 
     91  is(
     92    dbg.selectors.getSelectedSource().id,
     93    source.id,
     94    "The current selected source is the `same-script.js` from the iframe"
     95  );
     96 
     97  info("Assert that the breakpoint pauses on line 5");
     98  await assertPausedAtSourceAndLine(dbg, source.id, 5);
     99 
    100  info("Assert that there is a breakpoint displayed on line 5");
    101  await assertBreakpoint(dbg, 5);
    102 
    103  await resume(dbg);
    104  assertNotPaused(dbg);
    105 
    106  await removeBreakpoint(dbg, source.id, 5);
    107 
    108  await dbg.toolbox.closeToolbox();
    109 });