mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 900448 - Close the webconsole autocomplete popup on tab switch; r=msucan
This commit is contained in:
parent
2532a744d1
commit
98bedf4757
@ -241,3 +241,4 @@ support-files =
|
||||
[browser_webconsole_log_file_filter.js]
|
||||
[browser_webconsole_expandable_timestamps.js]
|
||||
[browser_webconsole_autocomplete_in_debugger_stackframe.js]
|
||||
[browser_webconsole_autocomplete_popup_close_on_tab_switch.js]
|
||||
|
@ -0,0 +1,42 @@
|
||||
/* vim:set ts=2 sw=2 sts=2 et: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// Test that the autocomplete popup closes on switching tabs. See bug 900448.
|
||||
|
||||
const TEST_URI = "data:text/html;charset=utf-8,<p>bug 900448 - autocomplete popup closes on tab switch";
|
||||
|
||||
let popup = null;
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
popup = null;
|
||||
});
|
||||
|
||||
function test() {
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("load", function onLoad() {
|
||||
browser.removeEventListener("load", onLoad, true);
|
||||
openConsole(null, consoleOpened);
|
||||
}, true);
|
||||
}
|
||||
|
||||
function consoleOpened(HUD) {
|
||||
popup = HUD.jsterm.autocompletePopup;
|
||||
|
||||
popup._panel.addEventListener("popupshown", function popupOpened() {
|
||||
popup._panel.removeEventListener("popupshown", popupOpened, false);
|
||||
addTab("data:text/html;charset=utf-8,<p>testing autocomplete closes");
|
||||
gBrowser.selectedBrowser.addEventListener("load", tab2Loaded, true);
|
||||
}, false);
|
||||
|
||||
HUD.jsterm.setInputValue("sc");
|
||||
EventUtils.synthesizeKey("r", {});
|
||||
}
|
||||
|
||||
function tab2Loaded() {
|
||||
gBrowser.selectedBrowser.removeEventListener("load", tab2Loaded, true);
|
||||
ok(!popup.isOpen, "Popup closes on tab switch");
|
||||
gBrowser.removeCurrentTab();
|
||||
finishTest();
|
||||
}
|
@ -745,7 +745,7 @@ WebConsoleFrame.prototype = {
|
||||
* Calculates the width and height of a single character of the input box.
|
||||
* This will be used in opening the popup at the correct offset.
|
||||
*
|
||||
* @private
|
||||
* @private
|
||||
*/
|
||||
_updateCharSize: function WCF__updateCharSize()
|
||||
{
|
||||
@ -2912,6 +2912,7 @@ function JSTerm(aWebConsoleFrame)
|
||||
this._inputEventHandler = this._inputEventHandler.bind(this);
|
||||
this._focusEventHandler = this._focusEventHandler.bind(this);
|
||||
this._onKeypressInVariablesView = this._onKeypressInVariablesView.bind(this);
|
||||
this._blurEventHandler = this._blurEventHandler.bind(this);
|
||||
|
||||
EventEmitter.decorate(this);
|
||||
}
|
||||
@ -3033,7 +3034,6 @@ JSTerm.prototype = {
|
||||
*/
|
||||
init: function JST_init()
|
||||
{
|
||||
let chromeDocument = this.hud.owner.chromeWindow.document;
|
||||
let autocompleteOptions = {
|
||||
onSelect: this.onAutocompleteSelect.bind(this),
|
||||
onClick: this.acceptProposedCompletion.bind(this),
|
||||
@ -3044,7 +3044,7 @@ JSTerm.prototype = {
|
||||
direction: "ltr",
|
||||
autoSelect: true
|
||||
};
|
||||
this.autocompletePopup = new AutocompletePopup(chromeDocument,
|
||||
this.autocompletePopup = new AutocompletePopup(this.hud.document,
|
||||
autocompleteOptions);
|
||||
|
||||
let doc = this.hud.document;
|
||||
@ -3054,6 +3054,7 @@ JSTerm.prototype = {
|
||||
this.inputNode.addEventListener("input", this._inputEventHandler, false);
|
||||
this.inputNode.addEventListener("keyup", this._inputEventHandler, false);
|
||||
this.inputNode.addEventListener("focus", this._focusEventHandler, false);
|
||||
this.hud.window.addEventListener("blur", this._blurEventHandler, false);
|
||||
|
||||
this.lastInputValue && this.setInputValue(this.lastInputValue);
|
||||
},
|
||||
@ -3742,6 +3743,17 @@ JSTerm.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* The window "blur" event handler.
|
||||
* @private
|
||||
*/
|
||||
_blurEventHandler: function JST__blurEventHandler()
|
||||
{
|
||||
if (this.autocompletePopup) {
|
||||
this.clearCompletion();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* The inputNode "keypress" event handler.
|
||||
*
|
||||
@ -4373,6 +4385,7 @@ JSTerm.prototype = {
|
||||
this.inputNode.removeEventListener("input", this._inputEventHandler, false);
|
||||
this.inputNode.removeEventListener("keyup", this._inputEventHandler, false);
|
||||
this.inputNode.removeEventListener("focus", this._focusEventHandler, false);
|
||||
this.hud.window.removeEventListener("blur", this._blurEventHandler, false);
|
||||
|
||||
this.hud = null;
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user