Bug 1611905 - Autocompletion suggestion for `debugger` in Console stops JS execution. r=nchevobbe

Differential Revision: https://phabricator.services.mozilla.com/D61211

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jason Laster 2020-02-04 16:40:46 +00:00
Родитель ed6568381e
Коммит 8402efc937
7 изменённых файлов: 61 добавлений и 29 удалений

Просмотреть файл

@ -64,6 +64,7 @@ skip-if = (os == "win" && ccov) # Bug 1424154
[browser_dbg-debug-line.js]
[browser_dbg-debugger-buttons.js]
[browser_dbg-editor-gutter.js]
[browser_dbg-eager-eval-skip-pause.js]
[browser_dbg-editor-scroll.js]
[browser_dbg-editor-select.js]
[browser_dbg-editor-highlight.js]

Просмотреть файл

@ -1,25 +1,6 @@
// Return a promise with a reference to jsterm, opening the split
// console if necessary. This cleans up the split console pref so
// it won't pollute other tests.
function getSplitConsole(dbg) {
const { toolbox, win } = dbg;
if (!win) {
win = toolbox.win;
}
if (!toolbox.splitConsole) {
pressKey(dbg, "Escape");
}
return new Promise(resolve => {
toolbox.getPanelWhenReady("webconsole").then(() => {
ok(toolbox.splitConsole, "Split console is shown.");
let jsterm = toolbox.getPanel("webconsole").hud.jsterm;
resolve(jsterm);
});
});
}
function findMessages(win, query) {
return Array.prototype.filter.call(
@ -47,7 +28,7 @@ add_task(async function() {
await selectSource(dbg, "switching-01");
// open the console
await getSplitConsole(dbg);
await getDebuggerSplitConsole(dbg);
ok(dbg.toolbox.splitConsole, "Split console is shown.");
const webConsole = await dbg.toolbox.getPanel("webconsole");

Просмотреть файл

@ -0,0 +1,24 @@
/* 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/. */
"use strict";
// Test that eager evaluation skips breakpoints and debugger statements
add_task(async function() {
await pushPref("devtools.webconsole.input.eagerEvaluation", true);
const dbg = await initDebugger("doc-strict.html");
const { hud } = await getDebuggerSplitConsole(dbg);
const target = await TargetFactory.forTab(gBrowser.selectedTab);
const toolbox = gDevTools.getToolbox(target);
await addBreakpoint(dbg, "doc-strict.html", 15);
setInputValue(hud, "strict()");
await waitForEagerEvaluationResult(hud, `3`);
setInputValue(hud, "debugger; 2");
await waitForEagerEvaluationResult(hud, `2`);
});

Просмотреть файл

@ -1,19 +1,20 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
<!-- 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/. -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta charset="utf-8" />
<title>Debugger test page</title>
</head>
<body>
<script>
function strict(a) {
"use strict"
"use strict";
var b = 2;
debugger;
return 3;
}
</script>
</body>

Просмотреть файл

@ -1089,9 +1089,7 @@ function invokeInTab(fnc, ...args) {
return ContentTask.spawn(
gBrowser.selectedBrowser,
{ fnc, args },
function({ fnc, args }) {
return content.wrappedJSObject[fnc](...args);
}
({ fnc, args }) => content.wrappedJSObject[fnc](...args)
);
}
@ -1938,6 +1936,30 @@ function waitForInspectorPanelChange(dbg) {
return dbg.toolbox.getPanelWhenReady("inspector");
}
function getEagerEvaluationElement(hud) {
return hud.ui.outputNode.querySelector(".eager-evaluation-result");
}
async function waitForEagerEvaluationResult(hud, text) {
await waitUntil(() => {
const elem = getEagerEvaluationElement(hud);
if (elem) {
if (text instanceof RegExp) {
return text.test(elem.innerText);
}
return elem.innerText == text;
}
return false;
});
ok(true, `Got eager evaluation result ${text}`);
}
function setInputValue(hud, value) {
const onValueSet = hud.jsterm.once("set-input-value");
hud.jsterm._setValue(value);
return onValueSet;
}
const { PromiseTestUtils } = ChromeUtils.import(
"resource://testing-common/PromiseTestUtils.jsm"
);

Просмотреть файл

@ -234,7 +234,10 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
},
get skipBreakpoints() {
return this._options.skipBreakpoints;
return (
this._options.skipBreakpoints ||
(this.insideClientEvaluation && this.insideClientEvaluation.eager)
);
},
/**

Просмотреть файл

@ -1177,11 +1177,11 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, {
// Set a flag on the thread actor which indicates an evaluation is being
// done for the client. This can affect how debugger handlers behave.
this.parentActor.threadActor.insideClientEvaluation = true;
this.parentActor.threadActor.insideClientEvaluation = evalOptions;
const evalInfo = evalWithDebugger(input, evalOptions, this);
this.parentActor.threadActor.insideClientEvaluation = false;
this.parentActor.threadActor.insideClientEvaluation = null;
const evalResult = evalInfo.result;
const helperResult = evalInfo.helperResult;