mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changeset 371cd4b623de (bug 901207) for m-bc orange
This commit is contained in:
parent
d670711ecf
commit
aa417eeb50
@ -2929,37 +2929,13 @@ const BrowserSearch = {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
let openSearchPageIfFieldIsNotActive = function(aSearchBar) {
|
||||
if (!aSearchBar || document.activeElement != aSearchBar.textbox.inputField)
|
||||
openUILinkIn(Services.search.defaultEngine.searchForm, "current");
|
||||
};
|
||||
|
||||
let searchBar = this.searchBar;
|
||||
let placement = CustomizableUI.getPlacementOfWidget("search-container");
|
||||
if (placement && placement.area == CustomizableUI.AREA_PANEL) {
|
||||
PanelUI.show().then(() => {
|
||||
// The panel is not constructed until the first time it is shown.
|
||||
searchBar = this.searchBar;
|
||||
searchBar.select();
|
||||
openSearchPageIfFieldIsNotActive(searchBar);
|
||||
});
|
||||
return;
|
||||
} else if (placement.area == CustomizableUI.AREA_NAVBAR && searchBar &&
|
||||
searchBar.parentNode.classList.contains("overflowedItem")) {
|
||||
let navBar = document.getElementById(CustomizableUI.AREA_NAVBAR);
|
||||
navBar.overflowable.show().then(() => {
|
||||
// The searchBar gets moved when the overflow panel opens.
|
||||
searchBar = this.searchBar;
|
||||
searchBar.select();
|
||||
openSearchPageIfFieldIsNotActive(searchBar);
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (searchBar && window.fullScreen) {
|
||||
var searchBar = this.searchBar;
|
||||
if (searchBar && window.fullScreen)
|
||||
FullScreen.mouseoverToggle(true);
|
||||
if (searchBar)
|
||||
searchBar.select();
|
||||
}
|
||||
openSearchPageIfFieldIsNotActive(searchBar);
|
||||
if (!searchBar || document.activeElement != searchBar.textbox.inputField)
|
||||
openUILinkIn(Services.search.defaultEngine.searchForm, "current");
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -6,8 +6,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "CustomizableUI",
|
||||
"resource:///modules/CustomizableUI.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "ScrollbarSampler",
|
||||
"resource:///modules/ScrollbarSampler.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Promise",
|
||||
"resource://gre/modules/Promise.jsm");
|
||||
/**
|
||||
* Maintains the state and dispatches events for the main menu panel.
|
||||
*/
|
||||
@ -118,11 +116,9 @@ const PanelUI = {
|
||||
* @param aEvent the event (if any) that triggers showing the menu.
|
||||
*/
|
||||
show: function(aEvent) {
|
||||
let deferred = Promise.defer();
|
||||
if (this.panel.state == "open" ||
|
||||
if (this.panel.state == "open" || this.panel.state == "showing" ||
|
||||
document.documentElement.hasAttribute("customizing")) {
|
||||
deferred.resolve();
|
||||
return deferred.promise;
|
||||
return;
|
||||
}
|
||||
|
||||
this.ensureReady().then(() => {
|
||||
@ -148,14 +144,7 @@ const PanelUI = {
|
||||
aEvent.sourceEvent.target.localName == "key";
|
||||
this.panel.setAttribute("noautofocus", !keyboardOpened);
|
||||
this.panel.openPopup(iconAnchor || anchor, "bottomcenter topright");
|
||||
|
||||
this.panel.addEventListener("popupshown", function onPopupShown() {
|
||||
this.removeEventListener("popupshown", onPopupShown);
|
||||
deferred.resolve();
|
||||
});
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -18,8 +18,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "DeferredTask",
|
||||
"resource://gre/modules/DeferredTask.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
|
||||
"resource://gre/modules/PrivateBrowsingUtils.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Promise",
|
||||
"resource://gre/modules/Promise.jsm");
|
||||
XPCOMUtils.defineLazyGetter(this, "gWidgetsBundle", function() {
|
||||
const kUrl = "chrome://browser/locale/customizableui/customizableWidgets.properties";
|
||||
return Services.strings.createBundle(kUrl);
|
||||
@ -3110,26 +3108,6 @@ OverflowableToolbar.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
show: function() {
|
||||
let deferred = Promise.defer();
|
||||
if (this._panel.state == "open") {
|
||||
deferred.resolve();
|
||||
return deferred.promise;
|
||||
}
|
||||
let doc = this._panel.ownerDocument;
|
||||
this._panel.hidden = false;
|
||||
let anchor = doc.getAnonymousElementByAttribute(this._chevron, "class", "toolbarbutton-icon");
|
||||
this._panel.openPopup(anchor || this._chevron, "bottomcenter topright");
|
||||
this._chevron.open = true;
|
||||
|
||||
this._panel.addEventListener("popupshown", function onPopupShown() {
|
||||
this.removeEventListener("popupshown", onPopupShown);
|
||||
deferred.resolve();
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
},
|
||||
|
||||
_onClickChevron: function(aEvent) {
|
||||
if (this._chevron.open)
|
||||
this._panel.hidePopup();
|
||||
|
@ -20,7 +20,6 @@ support-files =
|
||||
[browser_892955_isWidgetRemovable_for_removed_widgets.js]
|
||||
[browser_892956_destroyWidget_defaultPlacements.js]
|
||||
[browser_909779_overflow_toolbars_new_window.js]
|
||||
[browser_901207_searchbar_in_panel.js]
|
||||
[browser_913972_currentset_overflow.js]
|
||||
|
||||
[browser_914138_widget_API_overflowable_toolbar.js]
|
||||
|
@ -1,100 +0,0 @@
|
||||
/* 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/. */
|
||||
|
||||
let gTests = [
|
||||
{
|
||||
desc: "Ctrl+K should open the menu panel and focus the search bar if the search bar is in the panel.",
|
||||
run: function() {
|
||||
let searchbar = document.getElementById("searchbar");
|
||||
gCustomizeMode.addToPanel(searchbar);
|
||||
let placement = CustomizableUI.getPlacementOfWidget("search-container");
|
||||
is(placement.area, CustomizableUI.AREA_PANEL, "Should be in panel");
|
||||
|
||||
let shownPanelPromise = promisePanelShown(window);
|
||||
EventUtils.synthesizeKey("k", { ctrlKey: true });
|
||||
yield shownPanelPromise;
|
||||
|
||||
logActiveElement();
|
||||
is(document.activeElement, searchbar.textbox.inputField, "The searchbar should be focused");
|
||||
|
||||
let hiddenPanelPromise = promisePanelHidden(window);
|
||||
EventUtils.synthesizeKey("VK_ESCAPE", {});
|
||||
yield hiddenPanelPromise;
|
||||
},
|
||||
teardown: function() {
|
||||
CustomizableUI.reset();
|
||||
}
|
||||
},
|
||||
{
|
||||
desc: "Ctrl+K should give focus to the searchbar when the searchbar is in the menupanel and the panel is already opened.",
|
||||
run: function() {
|
||||
let searchbar = document.getElementById("searchbar");
|
||||
gCustomizeMode.addToPanel(searchbar);
|
||||
let placement = CustomizableUI.getPlacementOfWidget("search-container");
|
||||
is(placement.area, CustomizableUI.AREA_PANEL, "Should be in panel");
|
||||
|
||||
let shownPanelPromise = promisePanelShown(window);
|
||||
PanelUI.toggle({type: "command"});
|
||||
yield shownPanelPromise;
|
||||
|
||||
EventUtils.synthesizeKey("k", { ctrlKey: true });
|
||||
logActiveElement();
|
||||
is(document.activeElement, searchbar.textbox.inputField, "The searchbar should be focused");
|
||||
|
||||
let hiddenPanelPromise = promisePanelHidden(window);
|
||||
EventUtils.synthesizeKey("VK_ESCAPE", {});
|
||||
yield hiddenPanelPromise;
|
||||
},
|
||||
teardown: function() {
|
||||
CustomizableUI.reset();
|
||||
}
|
||||
},
|
||||
{
|
||||
desc: "Ctrl+K should open the overflow panel and focus the search bar if the search bar is overflowed.",
|
||||
setup: function() {
|
||||
this.originalWindowWidth = window.outerWidth;
|
||||
let navbar = document.getElementById(CustomizableUI.AREA_NAVBAR);
|
||||
ok(!navbar.hasAttribute("overflowing"), "Should start with a non-overflowing toolbar.");
|
||||
ok(CustomizableUI.inDefaultState, "Should start in default state.");
|
||||
|
||||
window.resizeTo(480, window.outerHeight);
|
||||
yield waitForCondition(() => navbar.hasAttribute("overflowing"));
|
||||
ok(!navbar.querySelector("#search-container"), "Search container should be overflowing");
|
||||
},
|
||||
run: function() {
|
||||
let searchbar = document.getElementById("searchbar");
|
||||
|
||||
let shownPanelPromise = promiseOverflowShown(window);
|
||||
EventUtils.synthesizeKey("k", { ctrlKey: true });
|
||||
yield shownPanelPromise;
|
||||
|
||||
let chevron = document.getElementById("nav-bar-overflow-button");
|
||||
yield waitForCondition(function() chevron.open);
|
||||
logActiveElement();
|
||||
is(document.activeElement, searchbar.textbox.inputField, "The searchbar should be focused");
|
||||
|
||||
let hiddenPanelPromise = promiseOverflowHidden(window);
|
||||
EventUtils.synthesizeKey("VK_ESCAPE", {});
|
||||
yield hiddenPanelPromise;
|
||||
},
|
||||
teardown: function() {
|
||||
let navbar = document.getElementById(CustomizableUI.AREA_NAVBAR);
|
||||
window.resizeTo(this.originalWindowWidth, window.outerHeight);
|
||||
yield waitForCondition(() => !navbar.hasAttribute("overflowing"));
|
||||
ok(!navbar.hasAttribute("overflowing"), "Should not have an overflowing toolbar.");
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
runTests(gTests);
|
||||
}
|
||||
|
||||
function logActiveElement() {
|
||||
let element = document.activeElement;
|
||||
info("Active element: " + element ?
|
||||
element + " (" + element.localName + "#" + element.id + "." + [...element.classList].join(".") + ")" :
|
||||
"null");
|
||||
}
|
@ -196,49 +196,31 @@ function openAndLoadWindow(aOptions, aWaitForDelayedStartup=false) {
|
||||
|
||||
function promisePanelShown(win) {
|
||||
let panelEl = win.PanelUI.panel;
|
||||
return promisePanelElementShown(win, panelEl);
|
||||
}
|
||||
|
||||
function promiseOverflowShown(win) {
|
||||
let panelEl = win.document.getElementById("widget-overflow");
|
||||
return promisePanelElementShown(win, panelEl);
|
||||
}
|
||||
|
||||
function promisePanelElementShown(win, aPanel) {
|
||||
let deferred = Promise.defer();
|
||||
let timeoutId = win.setTimeout(() => {
|
||||
deferred.reject("Panel did not show within 20 seconds.");
|
||||
}, 20000);
|
||||
function onPanelOpen(e) {
|
||||
aPanel.removeEventListener("popupshown", onPanelOpen);
|
||||
panelEl.removeEventListener("popupshown", onPanelOpen);
|
||||
win.clearTimeout(timeoutId);
|
||||
deferred.resolve();
|
||||
};
|
||||
aPanel.addEventListener("popupshown", onPanelOpen);
|
||||
panelEl.addEventListener("popupshown", onPanelOpen);
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function promisePanelHidden(win) {
|
||||
let panelEl = win.PanelUI.panel;
|
||||
return promisePanelElementHidden(win, panelEl);
|
||||
}
|
||||
|
||||
function promiseOverflowHidden(win) {
|
||||
let panelEl = document.getElementById("widget-overflow");
|
||||
return promisePanelElementHidden(win, panelEl);
|
||||
}
|
||||
|
||||
function promisePanelElementHidden(win, aPanel) {
|
||||
let deferred = Promise.defer();
|
||||
let timeoutId = win.setTimeout(() => {
|
||||
deferred.reject("Panel did not hide within 20 seconds.");
|
||||
}, 20000);
|
||||
function onPanelClose(e) {
|
||||
aPanel.removeEventListener("popuphidden", onPanelClose);
|
||||
panelEl.removeEventListener("popuphidden", onPanelClose);
|
||||
win.clearTimeout(timeoutId);
|
||||
deferred.resolve();
|
||||
}
|
||||
aPanel.addEventListener("popuphidden", onPanelClose);
|
||||
panelEl.addEventListener("popuphidden", onPanelClose);
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user