Backed out changeset bf603affd1e0 (bug 1388753) for failing browser-chrome's browser_947914_button_history.js. r=backout a=merge

MozReview-Commit-ID: AHOsaTvCWms

--HG--
extra : source : 5475c7748903350a91842046eeb614880738b83e
This commit is contained in:
Sebastian Hengst 2017-08-10 20:02:44 +02:00
Родитель 3cb6b7715c
Коммит 6081d7a11e
3 изменённых файлов: 27 добавлений и 18 удалений

Просмотреть файл

@ -338,6 +338,7 @@ this.PanelMultiView = class {
this._panel.removeEventListener("popupshown", this);
this._panel.removeEventListener("popuphidden", this);
this.window.removeEventListener("keydown", this);
this._dispatchViewEvent(this.node, "destructed");
this.node = this._clickCapturer = this._viewContainer = this._mainViewContainer =
this._subViews = this._viewStack = this.__dwu = this._panelViewCache = null;
}
@ -675,8 +676,8 @@ this.PanelMultiView = class {
*/
_dispatchViewEvent(viewNode, eventName, anchor, detail) {
let cancel = false;
if (eventName != "PanelMultiViewHidden") {
// Don't need to do this for PanelMultiViewHidden event
if (eventName != "PanelMultiViewHidden" && eventName != "destructed") {
// Don't need to do this for PanelMultiViewHidden or "destructed" events
CustomizableUI.ensureSubviewListeners(viewNode);
}

Просмотреть файл

@ -11,15 +11,12 @@ add_task(async function() {
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_PATH + "dummy_history_item.html");
await BrowserTestUtils.removeTab(tab);
tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_PATH); // will 404, but we don't care.
CustomizableUI.addWidgetToArea("history-panelmenu", CustomizableUI.AREA_FIXED_OVERFLOW_PANEL);
registerCleanupFunction(() => CustomizableUI.reset());
await document.getElementById("nav-bar").overflowable.show();
info("Menu panel was opened");
let historyButton = document.getElementById("history-panelmenu");
ok(historyButton, "History button appears in Panel Menu");
@ -28,18 +25,12 @@ add_task(async function() {
historyButton.click();
await promise;
ok(historyPanel.getAttribute("current"), "History Panel is in view");
let browserLoaded = BrowserTestUtils.browserLoaded(tab.linkedBrowser);
let panelHiddenPromise = promiseOverflowHidden(window);
let historyItems = document.getElementById("appMenu_historyMenu");
let historyItemForURL = historyItems.querySelector("toolbarbutton.bookmark-item[label='Happy History Hero']");
ok(historyItemForURL, "Should have a history item for the history we just made.");
EventUtils.synthesizeMouseAtCenter(historyItemForURL, {});
await browserLoaded;
is(gBrowser.currentURI.spec, TEST_PATH + "dummy_history_item.html", "Should have expected page load");
ok(historyItems.querySelector("toolbarbutton.bookmark-item[label='Happy History Hero']"),
"Should have a history item for the history we just made.");
let panelHiddenPromise = promiseOverflowHidden(window);
document.getElementById("widget-overflow").hidePopup();
await panelHiddenPromise
await BrowserTestUtils.removeTab(tab);
info("Menu panel was closed");
});

Просмотреть файл

@ -2020,7 +2020,8 @@ this.PlacesPanelview = class extends PlacesViewBase {
get events() {
if (this._events)
return this._events;
return this._events = ["command", "dragend", "dragstart", "ViewHiding", "ViewShown"];
return this._events = ["command", "destructed", "dragend", "dragstart",
"ViewHiding", "ViewShowing", "ViewShown"];
}
get panel() {
@ -2036,6 +2037,9 @@ this.PlacesPanelview = class extends PlacesViewBase {
case "command":
this._onCommand(event);
break;
case "destructed":
this._onDestructed(event);
break;
case "dragend":
this._onDragEnd(event);
break;
@ -2048,6 +2052,9 @@ this.PlacesPanelview = class extends PlacesViewBase {
case "ViewHiding":
this._onPopupHidden(event);
break;
case "ViewShowing":
this._onPopupShowing(event);
break;
case "ViewShown":
this._onViewShown(event);
break;
@ -2062,6 +2069,13 @@ this.PlacesPanelview = class extends PlacesViewBase {
PlacesUIUtils.openNodeWithEvent(button._placesNode, event);
}
_onDestructed(event) {
// The panelmultiview is ephemeral, so let's keep an eye out when the root
// element is showing again.
this._removeEventListeners(event.target, this.events);
this._addEventListeners(this._viewElt, ["ViewShowing"]);
}
_onDragEnd() {
this._draggedElt = null;
}
@ -2081,6 +2095,7 @@ this.PlacesPanelview = class extends PlacesViewBase {
uninit(event) {
this._removeEventListeners(this.panelMultiView, this.events);
this._removeEventListeners(this._viewElt, ["ViewShowing"]);
this._removeEventListeners(window, ["unload"]);
super.uninit(event);
}
@ -2162,9 +2177,11 @@ this.PlacesPanelview = class extends PlacesViewBase {
}
_onPopupShowing(event) {
// If the event came from the root element, this is the first time
// If the event came from the root element, this is a sign that the panelmultiview
// was just instantiated (see `_onDestructed` above) or this is the first time
// we ever get here.
if (event.originalTarget == this._rootElt) {
if (event.originalTarget == this._viewElt) {
this._removeEventListeners(this._viewElt, ["ViewShowing"]);
// Start listening for events from all panels inside the panelmultiview.
this._addEventListeners(this.panelMultiView, this.events);
}