Bug 988278 - Fixes ESCape keypress mess in the inspector to make sure the split console opens; r=miker

This fixes 2 problems related to the split console not opening when it should.
1 - After the inspector selection mode (pick mode) was canceled with ESC, pressing ESC once
again did not open the split console, because the toolbox did not have the focus.
2 - The markup-view tooltip (used to preview images) was eating the first ESC keypress when
the markup-view was focused, even though the tooltip was hidden. This was forcing users to
press ESC twice to open the split console.

--HG--
extra : rebase_source : 503e6f0a8fa2ef153f714af1361e85ad844a49d2
This commit is contained in:
Patrick Brosset 2015-04-13 10:51:49 +02:00
Родитель e6e0278825
Коммит fd53c00637
6 изменённых файлов: 82 добавлений и 2 удалений

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

@ -181,10 +181,12 @@ exports.getHighlighterUtils = function(toolbox) {
}
/**
* When the picker is canceled
* When the picker is canceled, stop the picker, and make sure the toolbox
* gets the focus.
*/
function onPickerNodeCanceled() {
stopPicker();
toolbox.frame.focus();
}
/**

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

@ -58,6 +58,7 @@ skip-if = e10s # GCLI isn't e10s compatible. See bug 1128988.
[browser_inspector_highlighter-keybinding_01.js]
[browser_inspector_highlighter-keybinding_02.js]
[browser_inspector_highlighter-keybinding_03.js]
[browser_inspector_highlighter-keybinding_04.js]
[browser_inspector_highlighter-options.js]
[browser_inspector_highlighter-rect_01.js]
[browser_inspector_highlighter-rect_02.js]

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

@ -0,0 +1,45 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Tests that pressing ESC twice while in picker mode first stops the picker and
// then opens the split-console (see bug 988278).
const TEST_URL = "data:text/html;charset=utf8,<div></div>";
add_task(function*() {
let {inspector, toolbox} = yield openInspectorForURL(TEST_URL);
info("Start the element picker");
yield toolbox.highlighterUtils.startPicker();
info("Start using the picker by hovering over nodes");
let onHover = toolbox.once("picker-node-hovered");
executeInContent("Test:SynthesizeMouse", {
options: {type: "mousemove"},
center: true,
selector: "div"
}, null, false);
yield onHover;
info("Press escape and wait for the picker to stop");
let onPickerStopped = toolbox.once("picker-stopped");
executeInContent("Test:SynthesizeKey", {
key: "VK_ESCAPE",
options: {}
}, null, false);
yield onPickerStopped;
info("Press escape again and wait for the split console to open");
let onSplitConsole = toolbox.once("split-console");
// The escape key is synthesized in the main process, which is where the focus
// should be after the picker was stopped.
EventUtils.synthesizeKey("VK_ESCAPE", {});
yield onSplitConsole;
ok(toolbox.splitConsole, "The split console is shown.");
// Hide the split console.
yield toolbox.toggleSplitConsole();
});

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

@ -73,6 +73,7 @@ skip-if = e10s # Bug 1040751 - CodeMirror editor.destroy() isn't e10s compatible
[browser_markupview_html_edit_03.js]
[browser_markupview_image_tooltip.js]
[browser_markupview_keybindings_01.js]
[browser_markupview_keybindings_02.js]
[browser_markupview_mutation_01.js]
[browser_markupview_mutation_02.js]
[browser_markupview_navigation.js]

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

@ -0,0 +1,30 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Tests that pressing ESC when a node in the markup-view is focused toggles
// the split-console (see bug 988278)
const TEST_URL = "data:text/html;charset=utf8,<div></div>";
add_task(function*() {
let {inspector, toolbox} = yield addTab(TEST_URL).then(openInspector);
info("Focusing the tag editor of the test element");
let {editor} = yield getContainerForSelector("div", inspector);
editor.tag.focus();
info("Pressing ESC and wait for the split-console to open");
let onSplitConsole = toolbox.once("split-console");
EventUtils.synthesizeKey("VK_ESCAPE", {}, inspector.panelWin);
yield onSplitConsole;
ok(toolbox.splitConsole, "The split console is shown.");
info("Pressing ESC again and wait for the split-console to close");
onSplitConsole = toolbox.once("split-console");
EventUtils.synthesizeKey("VK_ESCAPE", {}, inspector.panelWin);
yield onSplitConsole;
ok(!toolbox.splitConsole, "The split console is hidden.");
});

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

@ -212,7 +212,8 @@ function Tooltip(doc, options) {
}
this.emit("keypress", event.keyCode);
if (this.options.get("closeOnKeys").indexOf(event.keyCode) !== -1) {
if (this.options.get("closeOnKeys").indexOf(event.keyCode) !== -1 &&
this.isShown()) {
event.stopPropagation();
this.hide();
}