summaryrefslogtreecommitdiffstats
path: root/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_devtoolstoolbox_breakpoint.js
blob: 925d40b643b9b8195f111bc681a4c8df717699a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

Services.scriptloader.loadSubScript(
  "chrome://mochitests/content/browser/devtools/client/debugger/test/mochitest/shared-head.js",
  this
);

const SCRIPT_FILE = "script_aboutdebugging_devtoolstoolbox_breakpoint.js";
const TAB_URL =
  "https://example.com/browser/devtools/client/aboutdebugging/" +
  "test/browser/resources/doc_aboutdebugging_devtoolstoolbox_breakpoint.html";

/* import-globals-from helper-collapsibilities.js */
Services.scriptloader.loadSubScript(
  CHROME_URL_ROOT + "helper-collapsibilities.js",
  this
);

/**
 * Test breakpoints in about:devtools-toolbox tabs (ie non localTab tab target).
 */
add_task(async function () {
  const testTab = await addTab(TAB_URL);

  info("Force all debug target panes to be expanded");
  prepareCollapsibilitiesTest();

  const { document, tab, window } = await openAboutDebugging();
  await selectThisFirefoxPage(document, window.AboutDebugging.store);
  const { devtoolsTab, devtoolsWindow } = await openAboutDevtoolsToolbox(
    document,
    tab,
    window,
    TAB_URL
  );
  info("Select performance panel");
  const toolbox = getToolbox(devtoolsWindow);
  await toolbox.selectTool("jsdebugger");

  info("Add a breakpoint at line 10 in the test script");
  const debuggerContext = createDebuggerContext(toolbox);
  await selectSource(debuggerContext, SCRIPT_FILE);
  await addBreakpoint(debuggerContext, SCRIPT_FILE, 10);

  info("Invoke testMethod, expect the script to pause on line 10");
  const onContentTaskDone = ContentTask.spawn(
    testTab.linkedBrowser,
    {},
    function () {
      content.wrappedJSObject.testMethod();
    }
  );

  info("Wait for the debugger to pause");
  await waitForPaused(debuggerContext);
  const script = findSource(debuggerContext, SCRIPT_FILE);
  assertPausedAtSourceAndLine(debuggerContext, script.id, 10);

  info("Resume");
  await resume(debuggerContext);

  info("Wait for the paused content task to also resolve");
  await onContentTaskDone;

  info("Remove breakpoint");
  await removeBreakpoint(debuggerContext, script.id, 10);

  await closeAboutDevtoolsToolbox(document, devtoolsTab, window);
  await removeTab(testTab);
  await removeTab(tab);
});