From 7d20649f5d15c7b08cb3b46fd287b9070713e991 Mon Sep 17 00:00:00 2001 From: Julian Descottes Date: Fri, 7 Aug 2015 20:31:13 +0200 Subject: [PATCH] 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 | 4 ++ .../devtools/styleinspector/test/browser.ini | 1 + ...ompletion-popup-hidden-after-navigation.js | 38 +++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 browser/devtools/styleinspector/test/browser_ruleview_completion-popup-hidden-after-navigation.js diff --git a/browser/devtools/styleinspector/rule-view.js b/browser/devtools/styleinspector/rule-view.js index b9fcbd3ab67..7735e9decd4 100644 --- a/browser/devtools/styleinspector/rule-view.js +++ b/browser/devtools/styleinspector/rule-view.js @@ -1706,6 +1706,10 @@ CssRuleView.prototype = { return promise.resolve(undefined); } + if (this.popup.isOpen) { + this.popup.hidePopup(); + } + this.clear(); this.clearPseudoClassPanel(); diff --git a/browser/devtools/styleinspector/test/browser.ini b/browser/devtools/styleinspector/test/browser.ini index a9254765ef1..7a854722c8e 100644 --- a/browser/devtools/styleinspector/test/browser.ini +++ b/browser/devtools/styleinspector/test/browser.ini @@ -74,6 +74,7 @@ support-files = [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 diff --git a/browser/devtools/styleinspector/test/browser_ruleview_completion-popup-hidden-after-navigation.js b/browser/devtools/styleinspector/test/browser_ruleview_completion-popup-hidden-after-navigation.js new file mode 100644 index 00000000000..978df7c0492 --- /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,

"; + +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"); +});