Bug 1191093 - Hide ruleview autocomplete popup on page navigation;r=bgrins
authorJulian Descottes <julian.descottes@gmail.com>
Fri, 07 Aug 2015 20:31:13 +0200
changeset 288575 785195348eb8b66916f3157f768f3dcfe886ab79
parent 288574 be6e180ce0962c9248d5e1650ed2f53c9f6639f9
child 288576 2e9102e4b0a6b9004a9c7ff44191216df8777e97
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgrins
bugs1191093
milestone42.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1191093 - Hide ruleview autocomplete popup on page navigation;r=bgrins In ruleview #selectElement, if the autocomplete popup is opened, hide it. Added one mochitest to verify the popup is properly hidden after navigation.
browser/devtools/styleinspector/rule-view.js
browser/devtools/styleinspector/test/browser.ini
browser/devtools/styleinspector/test/browser_ruleview_completion-popup-hidden-after-navigation.js
--- a/browser/devtools/styleinspector/rule-view.js
+++ b/browser/devtools/styleinspector/rule-view.js
@@ -1701,16 +1701,20 @@ CssRuleView.prototype = {
    * @param {NodeActor} aElement
    *        The node whose style rules we'll inspect.
    */
   selectElement: function(aElement) {
     if (this._viewedElement === aElement) {
       return promise.resolve(undefined);
     }
 
+    if (this.popup.isOpen) {
+      this.popup.hidePopup();
+    }
+
     this.clear();
     this.clearPseudoClassPanel();
 
     this._viewedElement = aElement;
     this.refreshAddRuleButtonState();
 
     if (!this._viewedElement) {
       this._showEmpty();
--- a/browser/devtools/styleinspector/test/browser.ini
+++ b/browser/devtools/styleinspector/test/browser.ini
@@ -69,16 +69,17 @@ support-files =
 [browser_ruleview_colorpicker-multiple-changes.js]
 [browser_ruleview_colorpicker-release-outside-frame.js]
 [browser_ruleview_colorpicker-revert-on-ESC.js]
 [browser_ruleview_colorpicker-swatch-displayed.js]
 [browser_ruleview_completion-existing-property_01.js]
 [browser_ruleview_completion-existing-property_02.js]
 [browser_ruleview_completion-new-property_01.js]
 [browser_ruleview_completion-new-property_02.js]
+[browser_ruleview_completion-popup-hidden-after-navigation.js]
 [browser_ruleview_content_01.js]
 [browser_ruleview_content_02.js]
 skip-if = e10s # Bug 1039528: "inspect element" contextual-menu doesn't work with e10s
 [browser_ruleview_context-menu-show-mdn-docs-01.js]
 [browser_ruleview_context-menu-show-mdn-docs-02.js]
 [browser_ruleview_context-menu-show-mdn-docs-03.js]
 [browser_ruleview_copy_styles.js]
 [browser_ruleview_cubicbezier-appears-on-swatch-click.js]
new file mode 100644
--- /dev/null
+++ b/browser/devtools/styleinspector/test/browser_ruleview_completion-popup-hidden-after-navigation.js
@@ -0,0 +1,38 @@
+/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// Test that the ruleview autocomplete popup is hidden after page navigation
+
+let TEST_URL = "data:text/html;charset=utf-8,<h1 style='font: 24px serif'></h1>";
+
+add_task(function*() {
+  yield addTab(TEST_URL);
+  let {inspector, view} = yield openRuleView();
+
+  info("Test autocompletion popup is hidden after page navigation");
+
+  info("Selecting the test node");
+  yield selectNode("h1", inspector);
+
+  info("Focusing the css property editable field");
+  let propertyName = view.styleDocument.querySelectorAll(".ruleview-propertyname")[0];
+  let editor = yield focusEditableField(view, propertyName);
+
+  info("Pressing key VK_DOWN");
+  let onSuggest = once(editor.input, "keypress");
+  EventUtils.synthesizeKey("VK_DOWN", {}, view.styleWindow);
+
+  info("Waiting for autocomplete popup to be displayed");
+  yield onSuggest;
+  yield wait(1);
+
+  ok(view.popup && view.popup.isOpen, "Popup should be opened");
+
+  info("Reloading the page");
+  yield reloadPage(inspector);
+
+  ok(!(view.popup && view.popup.isOpen), "Popup should be closed");
+});