Bug 696107 - HTML attribute editor in highlighter conflicts with new keyboard controls. r=dcamp

This commit is contained in:
Rob Campbell 2011-11-05 12:38:00 -07:00
parent 8bfa865042
commit 09b876ea07
2 changed files with 35 additions and 8 deletions

View File

@ -458,6 +458,9 @@ TreePanel.prototype = {
editorInput.value = aAttrVal;
editorInput.select();
// remove tree key navigation events
this.treeIFrame.removeEventListener("keypress", this.IUI, false);
// listen for editor specific events
this.bindEditorEvent(editor, "click", function(aEvent) {
aEvent.stopPropagation();
@ -515,8 +518,12 @@ TreePanel.prototype = {
{
if (aEvent.which == this.window.KeyEvent.DOM_VK_RETURN) {
this.saveEditor();
aEvent.preventDefault();
aEvent.stopPropagation();
} else if (aEvent.keyCode == this.window.KeyEvent.DOM_VK_ESCAPE) {
this.closeEditor();
aEvent.preventDefault();
aEvent.stopPropagation();
}
},
@ -546,6 +553,9 @@ TreePanel.prototype = {
this.editingContext = null;
this.editingEvents = {};
// re-add navigation listener
this.treeIFrame.addEventListener("keypress", this.IUI, false);
// event notification
Services.obs.notifyObservers(null, this.IUI.INSPECTOR_NOTIFICATIONS.EDITOR_CLOSED,
null);

View File

@ -34,13 +34,14 @@ function setupHTMLPanel()
{
Services.obs.removeObserver(setupHTMLPanel, InspectorUI.INSPECTOR_NOTIFICATIONS.OPENED);
Services.obs.addObserver(runEditorTests, InspectorUI.INSPECTOR_NOTIFICATIONS.TREEPANELREADY, false);
InspectorUI.treePanel.open();
InspectorUI.toolShow(InspectorUI.treePanel.registrationObject);
}
function runEditorTests()
{
Services.obs.removeObserver(runEditorTests, InspectorUI.INSPECTOR_NOTIFICATIONS.TREEPANELREADY);
InspectorUI.stopInspecting();
InspectorUI.inspectNode(doc.body, true);
// setup generator for async test steps
editorTestSteps = doEditorTestSteps();
@ -54,6 +55,14 @@ function runEditorTests()
doNextStep();
}
function highlighterTrap()
{
// bug 696107
Services.obs.removeObserver(highlighterTrap, InspectorUI.INSPECTOR_NOTIFICATIONS.HIGHLIGHTING);
ok(false, "Highlighter moved. Shouldn't be here!");
finishUp();
}
function doEditorTestSteps()
{
let treePanel = InspectorUI.treePanel;
@ -78,6 +87,9 @@ function doEditorTestSteps()
// Step 2: validate editing session, enter new attribute value into editor, and save input
ok(InspectorUI.treePanel.editingContext, "Step 2: editor session started");
let selection = InspectorUI.selection;
ok(selection, "Selection is: " + selection);
let editorVisible = editor.classList.contains("editing");
ok(editorVisible, "editor popup visible");
@ -103,8 +115,13 @@ function doEditorTestSteps()
editorInput.value = "Hello World";
editorInput.focus();
// hit <enter> to save the inputted value
Services.obs.addObserver(highlighterTrap,
InspectorUI.INSPECTOR_NOTIFICATIONS.HIGHLIGHTING, false);
// hit <enter> to save the textbox value
executeSoon(function() {
// Extra key to test that keyboard handlers have been removed. bug 696107.
EventUtils.synthesizeKey("VK_LEFT", {}, attrValNode_id.ownerDocument.defaultView);
EventUtils.synthesizeKey("VK_RETURN", {}, attrValNode_id.ownerDocument.defaultView);
});
@ -112,6 +129,8 @@ function doEditorTestSteps()
yield;
yield; // End of Step 2
// remove this from previous step
Services.obs.removeObserver(highlighterTrap, InspectorUI.INSPECTOR_NOTIFICATIONS.HIGHLIGHTING);
// Step 3: validate that the previous editing session saved correctly, then open editor on `class` attribute value
ok(!treePanel.editingContext, "Step 3: editor session ended");
@ -210,16 +229,14 @@ function doEditorTestSteps()
is(attrValNode_id.innerHTML, "Hello World", "attribute-value node in HTML panel *not* updated");
// End of Step 8
// end of all steps, so clean up
Services.obs.removeObserver(doNextStep, InspectorUI.INSPECTOR_NOTIFICATIONS.EDITOR_OPENED, false);
Services.obs.removeObserver(doNextStep, InspectorUI.INSPECTOR_NOTIFICATIONS.EDITOR_CLOSED, false);
Services.obs.removeObserver(doNextStep, InspectorUI.INSPECTOR_NOTIFICATIONS.EDITOR_SAVED, false);
executeSoon(finishUp);
}
function finishUp() {
// end of all steps, so clean up
Services.obs.removeObserver(doNextStep, InspectorUI.INSPECTOR_NOTIFICATIONS.EDITOR_OPENED, false);
Services.obs.removeObserver(doNextStep, InspectorUI.INSPECTOR_NOTIFICATIONS.EDITOR_CLOSED, false);
Services.obs.removeObserver(doNextStep, InspectorUI.INSPECTOR_NOTIFICATIONS.EDITOR_SAVED, false);
doc = div = null;
InspectorUI.closeInspectorUI();
gBrowser.removeCurrentTab();