Avoid a race in CodeMirror initialization when setting breakpoints and don't let ESC stop navigation if the debugger is paused (bug 957174). r=vporof

--HG--
extra : rebase_source : 475e7969d92e237c7b38713cab8feb6d6464bb70
This commit is contained in:
Panos Astithas 2014-06-19 10:15:14 +03:00
Родитель 9187c08427
Коммит 5eae5f5f2d
5 изменённых файлов: 73 добавлений и 2 удалений

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

@ -10,6 +10,7 @@ const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
const DBG_STRINGS_URI = "chrome://browser/locale/devtools/debugger.properties";
const NEW_SOURCE_IGNORED_URLS = ["debugger eval code", "self-hosted", "XStringBundle"];
const NEW_SOURCE_DISPLAY_DELAY = 200; // ms
const EDITOR_BREAKPOINTS_UPDATE_DELAY = 200; // ms
const FETCH_SOURCE_RESPONSE_DELAY = 200; // ms
const FETCH_EVENT_LISTENERS_DELAY = 200; // ms
const FRAME_STEP_CLEAR_DELAY = 100; // ms
@ -1167,8 +1168,10 @@ SourceScripts.prototype = {
// If there are any stored breakpoints for this source, display them again,
// both in the editor and the breakpoints pane.
DebuggerController.Breakpoints.updateEditorBreakpoints();
DebuggerController.Breakpoints.updatePaneBreakpoints();
setNamedTimeout("update-editor-bp", EDITOR_BREAKPOINTS_UPDATE_DELAY, () => {
DebuggerController.Breakpoints.updateEditorBreakpoints();
});
// Make sure the events listeners are up to date.
if (DebuggerView.instrumentsPaneTab == "events-tab") {
@ -1219,8 +1222,8 @@ SourceScripts.prototype = {
// If there are any stored breakpoints for the sources, display them again,
// both in the editor and the breakpoints pane.
DebuggerController.Breakpoints.updateEditorBreakpoints();
DebuggerController.Breakpoints.updatePaneBreakpoints();
DebuggerController.Breakpoints.updateEditorBreakpoints();
// Signal that sources have been added.
window.emit(EVENTS.SOURCES_ADDED);

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

@ -78,6 +78,7 @@ support-files =
doc_scope-variable-4.html
doc_script-switching-01.html
doc_script-switching-02.html
doc_split-console-paused-reload.html
doc_step-out.html
doc_terminate-on-tab-close.html
doc_tracing-01.html
@ -237,6 +238,7 @@ skip-if = os == "linux" || e10s # Bug 888811 & bug 891176
[browser_dbg_sources-cache.js]
[browser_dbg_sources-labels.js]
[browser_dbg_sources-sorting.js]
[browser_dbg_split-console-paused-reload.js]
[browser_dbg_stack-01.js]
[browser_dbg_stack-02.js]
[browser_dbg_stack-03.js]

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

@ -0,0 +1,40 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Hitting ESC to open the split console when paused on reload should not stop
* the pending navigation.
*/
function test() {
Task.spawn(runTests);
}
function* runTests() {
const TAB_URL = EXAMPLE_URL + "doc_split-console-paused-reload.html";
let [,, panel] = yield initDebugger(TAB_URL);
let dbgWin = panel.panelWin;
let frames = dbgWin.DebuggerView.StackFrames;
let toolbox = gDevTools.getToolbox(panel.target);
yield panel.addBreakpoint({ url: TAB_URL, line: 16 });
info("Breakpoint was set.");
dbgWin.DebuggerController._target.activeTab.reload();
info("Page reloaded.");
yield waitForSourceAndCaretAndScopes(panel, ".html", 16);
yield ensureThreadClientState(panel, "paused");
info("Breakpoint was hit.");
EventUtils.sendMouseEvent({ type: "mousedown" },
frames.selectedItem.target,
dbgWin);
info("The breadcrumb received focus.");
// This is the meat of the test.
let result = toolbox.once("webconsole-ready", () => {
ok(toolbox.splitConsole, "Split console is shown.");
is(dbgWin.gThreadClient.state, "paused", "Execution is still paused.");
});
EventUtils.synthesizeKey("VK_ESCAPE", {}, dbgWin);
yield result;
yield resumeDebuggerThenCloseAndFinish(panel);
}

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

@ -0,0 +1,20 @@
<!-- Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ -->
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>Test page for opening a split-console when execution is paused</title>
</head>
<body>
<script type="text/javascript">
function runDebuggerStatement() {
debugger;
}
window.foobar = 1;
</script>
</body>
</html>

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

@ -294,6 +294,12 @@ Toolbox.prototype = {
let responsiveModeActive = this._isResponsiveModeActive();
if (e.keyCode === e.DOM_VK_ESCAPE && !responsiveModeActive) {
this.toggleSplitConsole();
// If the debugger is paused, don't let the ESC key stop any pending
// navigation.
let jsdebugger = this.getPanel("jsdebugger");
if (jsdebugger && jsdebugger.panelWin.gThreadClient.state == "paused") {
e.preventDefault();
}
}
},