tor-browser

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

browser_aboutdebugging_devtoolstoolbox_breakpoint.js (3084B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 Services.scriptloader.loadSubScript(
      7  "chrome://mochitests/content/browser/devtools/client/debugger/test/mochitest/shared-head.js",
      8  this
      9 );
     10 
     11 const SCRIPT_FILE = "script_aboutdebugging_devtoolstoolbox_breakpoint.js";
     12 const TAB_URL =
     13  "https://example.com/browser/devtools/client/aboutdebugging/" +
     14  "test/browser/resources/doc_aboutdebugging_devtoolstoolbox_breakpoint.html";
     15 
     16 /* import-globals-from helper-collapsibilities.js */
     17 Services.scriptloader.loadSubScript(
     18  CHROME_URL_ROOT + "helper-collapsibilities.js",
     19  this
     20 );
     21 
     22 /**
     23 * Test breakpoints in about:devtools-toolbox tabs (ie non localTab tab target).
     24 */
     25 add_task(async function () {
     26  const testTab = await addTab(TAB_URL);
     27 
     28  info("Force all debug target panes to be expanded");
     29  prepareCollapsibilitiesTest();
     30 
     31  const { document, tab, window } = await openAboutDebugging();
     32  await selectThisFirefoxPage(document, window.AboutDebugging.store);
     33  const { devtoolsTab, devtoolsWindow } = await openAboutDevtoolsToolbox(
     34    document,
     35    tab,
     36    window,
     37    TAB_URL
     38  );
     39  info("Select performance panel");
     40  const toolbox = getToolbox(devtoolsWindow);
     41  await toolbox.selectTool("jsdebugger");
     42 
     43  info("Add a breakpoint at line 10 in the test script");
     44  const debuggerContext = createDebuggerContext(toolbox);
     45  await selectSource(debuggerContext, SCRIPT_FILE);
     46  await addBreakpoint(debuggerContext, SCRIPT_FILE, 10);
     47 
     48  is(
     49    gBrowser.selectedTab,
     50    devtoolsTab,
     51    "Selected tab should already be the devtools tab"
     52  );
     53 
     54  info("Invoke testMethod, expect the script to pause on line 10");
     55  let onContentTaskDone = invokeTestMethod(testTab);
     56 
     57  info("Wait for the debugger to pause");
     58  await waitForPaused(debuggerContext);
     59  const script = findSource(debuggerContext, SCRIPT_FILE);
     60  await assertPausedAtSourceAndLine(debuggerContext, script.id, 10);
     61  is(
     62    gBrowser.selectedTab,
     63    devtoolsTab,
     64    "Selected tab should still be the devtools tab"
     65  );
     66 
     67  info("Resume");
     68  await resume(debuggerContext);
     69 
     70  info("Wait for the paused content task to also resolve");
     71  await onContentTaskDone;
     72 
     73  info("Select another tab, and check that breaking focuses the toolbox tab");
     74  gBrowser.selectedTab = testTab;
     75  onContentTaskDone = invokeTestMethod(testTab);
     76 
     77  info("Wait for the debugger to pause, and check the selected tab");
     78  await waitForPaused(debuggerContext);
     79  is(
     80    gBrowser.selectedTab,
     81    devtoolsTab,
     82    "Selected tab should be back to the devtools tab"
     83  );
     84 
     85  info("Resume");
     86  await resume(debuggerContext);
     87 
     88  info("Wait for the paused content task to also resolve");
     89  await onContentTaskDone;
     90 
     91  info("Remove breakpoint");
     92  await removeBreakpoint(debuggerContext, script.id, 10);
     93 
     94  await closeAboutDevtoolsToolbox(document, devtoolsTab, window);
     95  await removeTab(testTab);
     96  await removeTab(tab);
     97 });
     98 
     99 function invokeTestMethod(tab) {
    100  return ContentTask.spawn(tab.linkedBrowser, {}, function () {
    101    content.wrappedJSObject.testMethod();
    102  });
    103 }