tor-browser

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

browser_dbg-fission-frame-breakpoint.js (3083B)


      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 "use strict";
      6 
      7 const TEST_COM_URI = `${URL_ROOT_COM_SSL}examples/doc_dbg-fission-frame-sources.html`;
      8 
      9 add_task(async function () {
     10  // Load a test page with a remote frame:
     11  // simple1.js is imported by the main page. simple2.js comes from the remote frame.
     12  const dbg = await initDebuggerWithAbsoluteURL(
     13    TEST_COM_URI,
     14    "simple1.js",
     15    "simple2.js"
     16  );
     17  const {
     18    selectors: { getSelectedSource },
     19  } = dbg;
     20 
     21  // Check threads
     22  await waitForElement(dbg, "threadsPaneItems");
     23  let threadsEl = findAllElements(dbg, "threadsPaneItems");
     24  is(threadsEl.length, 2, "There are two threads in the thread panel");
     25  ok(
     26    Array.from(threadsEl).every(
     27      el => !isThreadElementPaused(el) && !getThreadElementPausedBadge(el)
     28    ),
     29    "No threads are paused"
     30  );
     31 
     32  // Add breakpoint within the iframe, which is hit early on load
     33  await selectSource(dbg, "simple2.js");
     34  await addBreakpoint(dbg, "simple2.js", 7);
     35 
     36  const onBreakpoint = waitForDispatch(dbg.store, "SET_BREAKPOINT");
     37  info("Reload the page to hit the breakpoint on load");
     38  const onReloaded = reload(dbg);
     39  await onBreakpoint;
     40  await waitForSelectedSource(dbg, "simple2.js");
     41 
     42  ok(
     43    getSelectedSource().url.includes("simple2.js"),
     44    "Selected source is simple2.js"
     45  );
     46  await waitForPaused(dbg);
     47  await assertPausedAtSourceAndLine(dbg, findSource(dbg, "simple2.js").id, 7);
     48 
     49  await waitForElement(dbg, "threadsPaneItems");
     50  threadsEl = findAllElements(dbg, "threadsPaneItems");
     51  is(threadsEl.length, 2, "There are two threads in the thread panel");
     52  const [mainThreadEl, remoteThreadEl] = threadsEl;
     53  is(
     54    mainThreadEl.textContent,
     55    "Main Thread",
     56    "first thread displayed is the main thread"
     57  );
     58  ok(
     59    !isThreadElementPaused(mainThreadEl),
     60    "Main Thread does not have the paused styling"
     61  );
     62  ok(
     63    !getThreadElementPausedBadge(mainThreadEl),
     64    "Main Thread does not have a paused badge"
     65  );
     66 
     67  ok(
     68    remoteThreadEl.textContent.startsWith(URL_ROOT_ORG_SSL),
     69    "second thread displayed is the remote thread"
     70  );
     71  ok(
     72    isThreadElementPaused(remoteThreadEl),
     73    "paused thread has the paused styling"
     74  );
     75  is(
     76    getThreadElementPausedBadge(remoteThreadEl).textContent,
     77    "paused",
     78    "paused badge is displayed in the remote thread item"
     79  );
     80 
     81  await stepIn(dbg);
     82  await assertPausedAtSourceAndLine(dbg, findSource(dbg, "simple2.js").id, 7);
     83 
     84  // We can't used `stepIn` helper as this last step will resume
     85  // and the helper is expecting to pause again
     86  await dbg.actions.stepIn();
     87  assertNotPaused(dbg, "Stepping in two times resumes");
     88 
     89  info("Wait for reload to complete after resume");
     90  await onReloaded;
     91 
     92  await dbg.toolbox.closeToolbox();
     93 });
     94 
     95 function isThreadElementPaused(el) {
     96  return el.classList.contains("paused");
     97 }
     98 
     99 function getThreadElementPausedBadge(el) {
    100  return el.querySelector(".pause-badge");
    101 }