Bug 1211038 - Fix focus issue with debugger searchbox using CodeMirror upstream patch;r=jryans

--HG--
extra : commitid : DKG9VrpGIyG
This commit is contained in:
Brian Grinstead 2015-10-27 12:59:45 -07:00
Родитель 9475037ade
Коммит 99dff533b4
3 изменённых файлов: 38 добавлений и 3 удалений

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

@ -25,8 +25,15 @@ function test() {
} }
function performTest() { function performTest() {
// Make sure that the search box becomes focused when pressing ctrl+f - Bug 1211038
gEditor.focus();
synthesizeKeyFromKeyTag(gDebugger.document.getElementById("tokenSearchKey"));
let focusedEl = Services.focus.focusedElement;
focusedEl = focusedEl.ownerDocument.getBindingParent(focusedEl) || focusedEl;
is(focusedEl, gDebugger.document.getElementById("searchbox"), "Searchbox is focused");
setText(gSearchBox, "#html"); setText(gSearchBox, "#html");
EventUtils.synthesizeKey("VK_RETURN", { shiftKey: true }, gDebugger); EventUtils.synthesizeKey("VK_RETURN", { shiftKey: true }, gDebugger);
is(gFiltering.searchData.toSource(), '["#", ["", "html"]]', is(gFiltering.searchData.toSource(), '["#", ["", "html"]]',
"The searchbox data wasn't parsed correctly."); "The searchbox data wasn't parsed correctly.");
@ -44,7 +51,7 @@ function performTest() {
"The searchbox data wasn't parsed correctly."); "The searchbox data wasn't parsed correctly.");
ok(isCaretPos(gPanel, 3, 15), ok(isCaretPos(gPanel, 3, 15),
"The editor didn't jump to the correct line."); "The editor didn't jump to the correct line.");
setText(gSearchBox, ":12"); setText(gSearchBox, ":12");
is(gFiltering.searchData.toSource(), '[":", ["", 12]]', is(gFiltering.searchData.toSource(), '[":", ["", 12]]',
"The searchbox data wasn't parsed correctly."); "The searchbox data wasn't parsed correctly.");

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

@ -1215,3 +1215,30 @@ function getSplitConsole(toolbox, win) {
}); });
}); });
} }
// This can be removed once debugger uses shared-head.js (bug 1181838)
function synthesizeKeyFromKeyTag(key) {
is(key && key.tagName, "key", "Successfully retrieved the <key> node");
let modifiersAttr = key.getAttribute("modifiers");
let name = null;
if (key.getAttribute("keycode"))
name = key.getAttribute("keycode");
else if (key.getAttribute("key"))
name = key.getAttribute("key");
isnot(name, null, "Successfully retrieved keycode/key");
let modifiers = {
shiftKey: !!modifiersAttr.match("shift"),
ctrlKey: !!modifiersAttr.match("control"),
altKey: !!modifiersAttr.match("alt"),
metaKey: !!modifiersAttr.match("meta"),
accelKey: !!modifiersAttr.match("accel")
};
info("Synthesizing key " + name + " " + JSON.stringify(modifiers));
EventUtils.synthesizeKey(name, modifiers);
}

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

@ -3091,7 +3091,8 @@
if (cm.state.focused && op.updateInput) if (cm.state.focused && op.updateInput)
cm.display.input.reset(op.typing); cm.display.input.reset(op.typing);
if (op.focus && op.focus == activeElt()) ensureFocus(op.cm); if (op.focus && op.focus == activeElt() && (!document.hasFocus || document.hasFocus()))
ensureFocus(op.cm);
} }
function endOperation_finish(op) { function endOperation_finish(op) {