summaryrefslogtreecommitdiffstats
path: root/devtools/client/debugger/test/mochitest/browser_dbg-console-eval.js
blob: 0e4cf793ecb726dd62fd19cf26430b8b48883720 (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
/* 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/>. */

// Tests that clicking the DOM node button in any ObjectInspect
// opens the Inspector panel

"use strict";

add_task(async function () {
  const dbg = await initDebugger("doc-scripts.html", "simple2.js");

  await selectSource(dbg, "simple2.js", 1);

  clickElement(dbg, "CodeMirrorLines");
  await waitForElementWithSelector(dbg, ".CodeMirror-code");

  getCM(dbg).setSelection({ line: 0, ch: 0 }, { line: 8, ch: 0 });

  rightClickElement(dbg, "CodeMirrorLines");
  await waitForContextMenu(dbg);
  selectContextMenuItem(dbg, "#node-menu-evaluate-in-console");

  await waitForConsolePanelChange(dbg);
  await hasConsoleMessage(dbg, "undefined");
});

function waitForConsolePanelChange(dbg) {
  const { toolbox } = dbg;

  return new Promise(resolve => {
    toolbox.getPanelWhenReady("webconsole").then(() => {
      ok(toolbox.webconsolePanel, "Console is shown.");
      resolve(toolbox.webconsolePanel);
    });
  });
}