tor-browser

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

browser_dbg-browser-toolbox-unselected-pause.js (2336B)


      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 // Test that the debugger pauses in the multiprocess browser toolbox even when
      6 // it hasn't been opened.
      7 
      8 "use strict";
      9 
     10 requestLongerTimeout(4);
     11 
     12 Services.scriptloader.loadSubScript(
     13  "chrome://mochitests/content/browser/devtools/client/framework/browser-toolbox/test/helpers-browser-toolbox.js",
     14  this
     15 );
     16 
     17 add_task(async function () {
     18  await pushPref("devtools.browsertoolbox.scope", "everything");
     19 
     20  // Make sure the toolbox opens with the webconsole initially selected.
     21  await pushPref("devtools.browsertoolbox.panel", "webconsole");
     22 
     23  const ToolboxTask = await initBrowserToolboxTask();
     24  await ToolboxTask.importFunctions({
     25    createDebuggerContext,
     26    waitUntil,
     27    waitForPaused,
     28    isPaused,
     29    waitForState,
     30    waitForSelectedSource,
     31    //waitForElementWithSelector,
     32    waitForLoadedScopes,
     33    waitForInlinePreviews,
     34    waitForElement,
     35    findElement,
     36    getSelector,
     37    findElementWithSelector,
     38    createLocation,
     39    getEditorContent,
     40    getCMEditor,
     41  });
     42  // ToolboxTask.spawn pass input arguments by stringify them via string concatenation.
     43  // This mean we have to stringify the input object, but don't have to parse it from the task.
     44  await ToolboxTask.spawn(selectors, async _selectors => {
     45    this.selectors = _selectors;
     46  });
     47 
     48  const onTabOpened = addTab("data:text/html,<script>debugger;</script>");
     49 
     50  // The debugger should automatically be selected.
     51  await ToolboxTask.spawn(null, async () => {
     52    /* global gToolbox */
     53    await waitUntil(() => gToolbox.currentToolId == "jsdebugger");
     54  });
     55  ok(true, "Debugger selected");
     56 
     57  // The debugger should pause.
     58  await ToolboxTask.spawn(null, async () => {
     59    // Wait for the debugger to finish loading.
     60    await gToolbox.getPanelWhenReady("jsdebugger");
     61 
     62    const dbg = createDebuggerContext(gToolbox);
     63    await waitForPaused(dbg);
     64    if (!gToolbox.isHighlighted("jsdebugger")) {
     65      throw new Error("Debugger not highlighted");
     66    }
     67  });
     68  ok(true, "Paused in new tab");
     69 
     70  await ToolboxTask.destroy();
     71 
     72  // Wait for the tab to resume and finish loading after the browser toolbox is closed
     73  await onTabOpened;
     74 });