summaryrefslogtreecommitdiffstats
path: root/devtools/client/webconsole/test/browser/browser_webconsole_eval_in_debugger_stackframe2.js
blob: 9583202c241ab7d7c767444d3d946123b3bda36c (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
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

// Test to make sure that web console commands can fire while paused at a
// breakpoint that was triggered from a JS call.  Relies on asynchronous js
// evaluation over the protocol - see Bug 1088861.

"use strict";

const TEST_URI =
  "http://example.com/browser/devtools/client/webconsole/" +
  "test/browser/test-eval-in-stackframe.html";

add_task(async function () {
  // TODO: Remove this pref change when middleware for terminating requests
  // when closing a panel is implemented
  await pushPref("devtools.debugger.features.inline-preview", false);

  info("open the console");
  const hud = await openNewTabAndConsole(TEST_URI);

  info("open the debugger");
  await openDebugger();

  const toolbox = hud.toolbox;
  const dbg = createDebuggerContext(toolbox);

  // firstCall calls secondCall, which has a debugger statement, so we'll be paused.
  const onFirstCallMessageReceived = waitForMessageByType(
    hud,
    "undefined",
    ".result"
  );

  const unresolvedSymbol = Symbol();
  let firstCallEvaluationResult = unresolvedSymbol;
  onFirstCallMessageReceived.then(message => {
    firstCallEvaluationResult = message;
  });
  execute(hud, "firstCall()");

  info("Waiting for a frame to be added");
  await waitForPaused(dbg);

  info("frames added, select the console again");
  await openConsole();

  info("Executing basic command while paused");
  await executeAndWaitForResultMessage(hud, "1 + 2", "3");
  ok(true, "`1 + 2` was evaluated whith debugger paused");

  info("Executing command using scoped variables while paused");
  await executeAndWaitForResultMessage(
    hud,
    "foo + foo2",
    `"globalFooBug783499foo2SecondCall"`
  );
  ok(true, "`foo + foo2` was evaluated as expected with debugger paused");

  info(
    "Checking the first command, which is the last to resolve since it paused"
  );
  Assert.strictEqual(
    firstCallEvaluationResult,
    unresolvedSymbol,
    "firstCall was not evaluated yet"
  );

  info("Resuming the thread");
  dbg.actions.resume();

  await onFirstCallMessageReceived;
  Assert.notStrictEqual(
    firstCallEvaluationResult,
    unresolvedSymbol,
    "firstCall() returned correct value"
  );
});