tor-browser

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

browser_dbg-debugger-buttons.js (2867B)


      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 /**
      6 * Test debugger buttons
      7 *  1. resume
      8 *  2. stepOver
      9 *  3. stepIn
     10 *  4. stepOver to the end of a function
     11 *  5. stepUp at the end of a function
     12 */
     13 
     14 "use strict";
     15 
     16 add_task(async function () {
     17  const dbg = await initDebugger("doc-debugger-statements.html");
     18 
     19  let onReloaded = reload(dbg, "doc-debugger-statements.html");
     20  await waitForPaused(dbg);
     21  await assertPausedAtSourceAndLine(
     22    dbg,
     23    findSource(dbg, "doc-debugger-statements.html").id,
     24    11
     25  );
     26 
     27  info("resume");
     28  await clickResume(dbg);
     29  await waitForPaused(dbg);
     30  await assertPausedAtSourceAndLine(
     31    dbg,
     32    findSource(dbg, "doc-debugger-statements.html").id,
     33    16
     34  );
     35 
     36  info("step over");
     37  await clickStepOver(dbg);
     38  await assertPausedAtSourceAndLine(
     39    dbg,
     40    findSource(dbg, "doc-debugger-statements.html").id,
     41    17
     42  );
     43 
     44  info("step into");
     45  await clickStepIn(dbg);
     46  await assertPausedAtSourceAndLine(
     47    dbg,
     48    findSource(dbg, "doc-debugger-statements.html").id,
     49    22
     50  );
     51 
     52  info("step over");
     53  await clickStepOver(dbg);
     54  await assertPausedAtSourceAndLine(
     55    dbg,
     56    findSource(dbg, "doc-debugger-statements.html").id,
     57    24
     58  );
     59 
     60  info("step out");
     61  await clickStepOut(dbg);
     62  await assertPausedAtSourceAndLine(
     63    dbg,
     64    findSource(dbg, "doc-debugger-statements.html").id,
     65    18
     66  );
     67 
     68  await resume(dbg);
     69 
     70  info("Wait for reload to complete after resume");
     71  await onReloaded;
     72 
     73  info("Toggle debugger statement off");
     74  const toggleCheckbox = findElementWithSelector(
     75    dbg,
     76    ".breakpoints-debugger-statement input"
     77  );
     78  toggleCheckbox.click();
     79  await waitFor(() => !toggleCheckbox.checked);
     80 
     81  await reload(dbg, "doc-debugger-statements.html");
     82  assertNotPaused(dbg);
     83 
     84  info("Re-enable debugger statement");
     85  toggleCheckbox.click();
     86  await waitFor(() => toggleCheckbox.checked);
     87 
     88  onReloaded = reload(dbg, "doc-debugger-statements.html");
     89  await waitForPaused(dbg);
     90  await assertPausedAtSourceAndLine(
     91    dbg,
     92    findSource(dbg, "doc-debugger-statements.html").id,
     93    11
     94  );
     95  await resume(dbg);
     96  await waitForPaused(dbg);
     97  await resume(dbg);
     98  await onReloaded;
     99 });
    100 
    101 function clickButton(dbg, button) {
    102  const resumeFired = waitForDispatch(dbg.store, "COMMAND");
    103  clickElement(dbg, button);
    104  return resumeFired;
    105 }
    106 
    107 async function clickStepOver(dbg) {
    108  await clickButton(dbg, "stepOver");
    109  return waitForPaused(dbg);
    110 }
    111 
    112 async function clickStepIn(dbg) {
    113  await clickButton(dbg, "stepIn");
    114  return waitForPaused(dbg);
    115 }
    116 
    117 async function clickStepOut(dbg) {
    118  await clickButton(dbg, "stepOut");
    119  return waitForPaused(dbg);
    120 }
    121 
    122 async function clickResume(dbg) {
    123  return clickButton(dbg, "resume");
    124 }