Bug 1191093 - Add panelId for markup-view autocomplete popup, r=bgrins

When creating the AutocompletePopup for the markup view, use a custom panelId.
This forces the AutocompletePopup to use separate XUL elements.

Otherwise, the markupview popup and the ruleview popup were sharing the same
XUL elements. When the markup-view was destroyed (ie on each page navigation),
the autocomplete popup in the rule view was no longer working.

- added panelId option in markup-view.js
- modified autocompletion tests in styleinspector/test
  to verify the autocomplete popup is still working
  after page navigation
This commit is contained in:
Julian Descottes 2015-08-05 23:36:05 +02:00
parent 76a9f9935a
commit ae0b8f8fb0
7 changed files with 61 additions and 14 deletions

View File

@ -18,6 +18,7 @@ const GRAB_DELAY = 400;
const DRAG_DROP_AUTOSCROLL_EDGE_DISTANCE = 50;
const DRAG_DROP_MIN_AUTOSCROLL_SPEED = 5;
const DRAG_DROP_MAX_AUTOSCROLL_SPEED = 15;
const AUTOCOMPLETE_POPUP_PANEL_ID = "markupview_autoCompletePopup";
const {UndoStack} = require("devtools/shared/undo");
const {editableField, InplaceEditor} = require("devtools/shared/inplace-editor");
@ -85,7 +86,10 @@ function MarkupView(aInspector, aFrame, aControllerWindow) {
// Creating the popup to be used to show CSS suggestions.
let options = {
autoSelect: true,
theme: "auto"
theme: "auto",
// panelId option prevents the markupView autocomplete popup from
// sharing XUL elements with other views, such as ruleView (see Bug 1191093)
panelId: AUTOCOMPLETE_POPUP_PANEL_ID
};
this.popup = new AutocompletePopup(this.doc.defaultView.parent.document, options);

View File

@ -61,6 +61,15 @@ add_task(function*() {
yield addTab(TEST_URL);
let {toolbox, inspector, view} = yield openRuleView();
info("Test autocompletion after 1st page load");
yield runAutocompletionTest(toolbox, inspector, view);
info("Test autocompletion after page navigation");
yield reloadPage(inspector);
yield runAutocompletionTest(toolbox, inspector, view);
});
function* runAutocompletionTest(toolbox, inspector, view) {
info("Selecting the test node");
yield selectNode("h1", inspector);
@ -69,10 +78,10 @@ add_task(function*() {
let editor = yield focusEditableField(view, propertyName);
info("Starting to test for css property completion");
for (let i = 0; i < testData.length; i ++) {
for (let i = 0; i < testData.length; i++) {
yield testCompletion(testData[i], editor, view);
}
});
}
function* testCompletion([key, completion, index, total], editor, view) {
info("Pressing key " + key);

View File

@ -43,6 +43,15 @@ add_task(function*() {
yield addTab(TEST_URL);
let {toolbox, inspector, view} = yield openRuleView();
info("Test autocompletion after 1st page load");
yield runAutocompletionTest(toolbox, inspector, view);
info("Test autocompletion after page navigation");
yield reloadPage(inspector);
yield runAutocompletionTest(toolbox, inspector, view);
});
function* runAutocompletionTest(toolbox, inspector, view) {
info("Selecting the test node");
yield selectNode("h1", inspector);
@ -51,13 +60,13 @@ add_task(function*() {
let editor = yield focusEditableField(view, value);
info("Starting to test for css property completion");
for (let i = 0; i < testData.length; i ++) {
for (let i = 0; i < testData.length; i++) {
// Re-define the editor at each iteration, because the focus may have moved
// from property to value and back
editor = inplaceEditor(view.styleDocument.activeElement);
yield testCompletion(testData[i], editor, view);
}
});
}
function* testCompletion([key, modifiers, completion, index, total], editor, view) {
info("Pressing key " + key);

View File

@ -44,6 +44,15 @@ add_task(function*() {
yield addTab(TEST_URL);
let {toolbox, inspector, view} = yield openRuleView();
info("Test autocompletion after 1st page load");
yield runAutocompletionTest(toolbox, inspector, view);
info("Test autocompletion after page navigation");
yield reloadPage(inspector);
yield runAutocompletionTest(toolbox, inspector, view);
});
function* runAutocompletionTest(toolbox, inspector, view) {
info("Selecting the test node");
yield selectNode("h1", inspector);
@ -52,10 +61,10 @@ add_task(function*() {
let editor = yield focusEditableField(view, brace);
info("Starting to test for css property completion");
for (let i = 0; i < testData.length; i ++) {
for (let i = 0; i < testData.length; i++) {
yield testCompletion(testData[i], editor, view);
}
});
}
function* testCompletion([key, completion, index, total], editor, view) {
info("Pressing key " + key);

View File

@ -46,6 +46,15 @@ add_task(function*() {
yield addTab(TEST_URL);
let {toolbox, inspector, view} = yield openRuleView();
info("Test autocompletion after 1st page load");
yield runAutocompletionTest(toolbox, inspector, view);
info("Test autocompletion after page navigation");
yield reloadPage(inspector);
yield runAutocompletionTest(toolbox, inspector, view);
});
function* runAutocompletionTest(toolbox, inspector, view) {
info("Selecting the test node");
yield selectNode("h1", inspector);
@ -60,7 +69,7 @@ add_task(function*() {
editor = inplaceEditor(view.styleDocument.activeElement);
yield testCompletion(testData[i], editor, view);
}
});
}
function* testCompletion([key, modifiers, completion, index, total], editor, view) {
info("Pressing key " + key);

View File

@ -82,9 +82,3 @@ function* assertRuleAndMarkupViewWidth(id, value, ruleView, inspector) {
let attr = yield getContainerStyleAttrValue(id, inspector);
is(attr.textContent.replace(/\s/g, ""), "width:" + value + ";", "Markup-view style attribute width is " + value);
}
function reloadPage(inspector) {
let onNewRoot = inspector.once("new-root");
content.location.reload();
return onNewRoot.then(inspector.markup._waitForChildren);
}

View File

@ -999,3 +999,16 @@ function waitForStyleEditor(toolbox, href) {
return def.promise;
}
/**
* Reload the current page and wait for the inspector to be initialized after
* the navigation
* @param {InspectorPanel} inspector
* The instance of InspectorPanel currently loaded in the toolbox
* @return a promise that resolves after page reload and inspector initialization
*/
function reloadPage(inspector) {
let onNewRoot = inspector.once("new-root");
content.location.reload();
return onNewRoot.then(inspector.markup._waitForChildren);
}