summaryrefslogtreecommitdiffstats
path: root/devtools/client/debugger/test/mochitest/browser_dbg-debugger-buttons.js
blob: 14c71bb4f904d645d631abb784267f871a1ea68b (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */

/**
 * Test debugger buttons
 *  1. resume
 *  2. stepOver
 *  3. stepIn
 *  4. stepOver to the end of a function
 *  5. stepUp at the end of a function
 */

"use strict";

add_task(async function () {
  const dbg = await initDebugger("doc-debugger-statements.html");

  let onReloaded = reload(dbg, "doc-debugger-statements.html");
  await waitForPaused(dbg);
  assertPausedAtSourceAndLine(
    dbg,
    findSource(dbg, "doc-debugger-statements.html").id,
    11
  );

  info("resume");
  await clickResume(dbg);
  await waitForPaused(dbg);
  assertPausedAtSourceAndLine(
    dbg,
    findSource(dbg, "doc-debugger-statements.html").id,
    16
  );

  info("step over");
  await clickStepOver(dbg);
  assertPausedAtSourceAndLine(
    dbg,
    findSource(dbg, "doc-debugger-statements.html").id,
    17
  );

  info("step into");
  await clickStepIn(dbg);
  assertPausedAtSourceAndLine(
    dbg,
    findSource(dbg, "doc-debugger-statements.html").id,
    22
  );

  info("step over");
  await clickStepOver(dbg);
  assertPausedAtSourceAndLine(
    dbg,
    findSource(dbg, "doc-debugger-statements.html").id,
    24
  );

  info("step out");
  await clickStepOut(dbg);
  assertPausedAtSourceAndLine(
    dbg,
    findSource(dbg, "doc-debugger-statements.html").id,
    18
  );

  await resume(dbg);

  info("Wait for reload to complete after resume");
  await onReloaded;

  info("Toggle debugger statement off");
  const toggleCheckbox = findElementWithSelector(
    dbg,
    ".breakpoints-debugger-statement input"
  );
  toggleCheckbox.click();
  await waitFor(() => !toggleCheckbox.checked);

  await reload(dbg, "doc-debugger-statements.html");
  assertNotPaused(dbg);

  info("Re-enable debugger statement");
  toggleCheckbox.click();
  await waitFor(() => toggleCheckbox.checked);

  onReloaded = reload(dbg, "doc-debugger-statements.html");
  await waitForPaused(dbg);
  assertPausedAtSourceAndLine(
    dbg,
    findSource(dbg, "doc-debugger-statements.html").id,
    11
  );
  await resume(dbg);
  await waitForPaused(dbg);
  await resume(dbg);
  await onReloaded;
});

function clickButton(dbg, button) {
  const resumeFired = waitForDispatch(dbg.store, "COMMAND");
  clickElement(dbg, button);
  return resumeFired;
}

async function clickStepOver(dbg) {
  await clickButton(dbg, "stepOver");
  return waitForPaused(dbg);
}

async function clickStepIn(dbg) {
  await clickButton(dbg, "stepIn");
  return waitForPaused(dbg);
}

async function clickStepOut(dbg) {
  await clickButton(dbg, "stepOut");
  return waitForPaused(dbg);
}

async function clickResume(dbg) {
  return clickButton(dbg, "resume");
}