Files
firefox/devtools/client/webconsole/test/browser_eval_in_debugger_stackframe2.js
T
Alexandre Poirot 3d76320218 Bug 1387123 - Replace all usages of require(promise).defer by require(devtools/shared/defer).defer. r=tromey
In prevision of Promise.jsm removal, use defer helper module instead of Promise.jsm
as that's the only one feature that DOM Promise don't support.

PART2: Substitutes promise.defer usages with defer
$ sed -i 's/promise.defer/defer/gI' $(egrep -lir "promise.defer\(\)" devtools)
  Reset modification to the following files as they are using deprecated syncable promises as we don't want to touch them.
  http://searchfox.org/mozilla-central/search?q=deprecated-sync-thenables&case=true&regexp=false&path=
$ git checkout devtools/client/debugger/test/mochitest/
$ git checkout devtools/shared/client/main.js
$ git checkout devtools/client/debugger/
$ git checkout devtools/server/main.js

MozReview-Commit-ID: DGN5ae68wtn
2017-08-08 15:24:04 +02:00

72 lines
2.3 KiB
JavaScript

/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* 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/test-eval-in-stackframe.html";
// Force the old debugger UI since it's directly used (see Bug 1301705)
Services.prefs.setBoolPref("devtools.debugger.new-debugger-frontend", false);
registerCleanupFunction(function* () {
Services.prefs.clearUserPref("devtools.debugger.new-debugger-frontend");
});
add_task(function* () {
yield loadTab(TEST_URI);
info("open the web console");
let hud = yield openConsole();
let {jsterm} = hud;
info("open the debugger");
let {panelWin} = yield openDebugger();
let {DebuggerController} = panelWin;
let {activeThread} = DebuggerController;
let firstCall = defer();
let frameAdded = defer();
executeSoon(() => {
info("Executing firstCall");
activeThread.addOneTimeListener("framesadded", () => {
executeSoon(frameAdded.resolve);
});
jsterm.execute("firstCall()").then(firstCall.resolve);
});
info("Waiting for a frame to be added");
yield frameAdded.promise;
info("Executing basic command while paused");
yield executeAndConfirm(jsterm, "1 + 2", "3");
info("Executing command using scoped variables while paused");
yield executeAndConfirm(jsterm, "foo + foo2",
'"globalFooBug783499foo2SecondCall"');
info("Resuming the thread");
activeThread.resume();
info("Checking the first command, which is the last to resolve since it " +
"paused");
let node = yield firstCall.promise;
is(node.querySelector(".message-body").textContent,
"undefined",
"firstCall() returned correct value");
});
function* executeAndConfirm(jsterm, input, output) {
info("Executing command `" + input + "`");
let node = yield jsterm.execute(input);
is(node.querySelector(".message-body").textContent, output,
"Expected result from call to " + input);
}