Bug 1441284 - Part 1 - Remove the "current" property. r=Gijs
MozReview-Commit-ID: GyqI8N3JQ9O
--- a/browser/base/content/test/performance/browser_appmenu_reflows.js
+++ b/browser/base/content/test/performance/browser_appmenu_reflows.js
@@ -91,29 +91,33 @@ add_task(async function() {
async function openSubViewsRecursively(currentView) {
let navButtons = Array.from(currentView.querySelectorAll(".subviewbutton-nav"));
if (!navButtons) {
return;
}
for (let button of navButtons) {
info("Click " + button.id);
+ let promiseViewShown = BrowserTestUtils.waitForEvent(PanelUI.panel,
+ "ViewShown");
button.click();
- await BrowserTestUtils.waitForEvent(PanelUI.panel, "ViewShown");
+ let viewShownEvent = await promiseViewShown;
// Workaround until bug 1363756 is fixed, then this can be removed.
let container = PanelUI.multiView.querySelector(".panel-viewcontainer");
await BrowserTestUtils.waitForCondition(() => {
return !container.hasAttribute("width");
});
- info("Shown " + PanelUI.multiView.current.id);
- await openSubViewsRecursively(PanelUI.multiView.current);
+ info("Shown " + viewShownEvent.originalTarget.id);
+ await openSubViewsRecursively(viewShownEvent.originalTarget);
+ promiseViewShown = BrowserTestUtils.waitForEvent(currentView,
+ "ViewShown");
PanelUI.multiView.goBack();
- await BrowserTestUtils.waitForEvent(PanelUI.panel, "ViewShown");
+ await promiseViewShown;
// Workaround until bug 1363756 is fixed, then this can be removed.
await BrowserTestUtils.waitForCondition(() => {
return !container.hasAttribute("width");
});
}
}
--- a/browser/components/customizableui/PanelMultiView.jsm
+++ b/browser/components/customizableui/PanelMultiView.jsm
@@ -374,24 +374,17 @@ var PanelMultiView = class extends this.
}
get _screenManager() {
if (this.__screenManager)
return this.__screenManager;
return this.__screenManager = Cc["@mozilla.org/gfx/screenmanager;1"]
.getService(Ci.nsIScreenManager);
}
- /**
- * @return {panelview} the currently visible subview OR the subview that is
- * about to be shown whilst a 'ViewShowing' event is being
- * dispatched.
- */
- get current() {
- return this.node && this._currentSubView;
- }
+
get _currentSubView() {
// Peek the top of the stack, but fall back to the main view if the list of
// opened views is currently empty.
let panelView = this.openViews[this.openViews.length - 1];
return (panelView && panelView.node) || this._mainView;
}
get showingSubView() {
return this.openViews.length > 1;
@@ -447,17 +440,17 @@ var PanelMultiView = class extends this.
// Proxy these public properties and methods, as used elsewhere by various
// parts of the browser, to this instance.
["goBack", "showSubView"].forEach(method => {
Object.defineProperty(this.node, method, {
enumerable: true,
value: (...args) => this[method](...args)
});
});
- ["current", "showingSubView"].forEach(property => {
+ ["showingSubView"].forEach(property => {
Object.defineProperty(this.node, property, {
enumerable: true,
get: () => this[property]
});
});
}
disconnect() {
--- a/browser/components/places/tests/browser/browser_stayopenmenu.js
+++ b/browser/components/places/tests/browser/browser_stayopenmenu.js
@@ -141,17 +141,17 @@ add_task(async function testStayopenBook
ok(appMenu.open, "Menu should remain open.");
// Test App Menu's Bookmarks Library stayopen clicks: middle-click.
promiseTabOpened = BrowserTestUtils.waitForNewTab(gBrowser, null);
EventUtils.synthesizeMouseAtCenter(testMenuitem, {button: 1});
newTab = await promiseTabOpened;
ok(true, "Bookmark middle-click opened new tab.");
await BrowserTestUtils.removeTab(newTab);
- is(PanelUI.multiView.current.id, "PanelUI-bookmarks", "Should still show the bookmarks subview");
+ ok(PanelView.forNode(BMview).active, "Should still show the bookmarks subview");
ok(appMenu.open, "Menu should remain open.");
// Close the App Menu
appMenuPopup.hidePopup();
ok(!appMenu.open, "The menu should now be closed.");
// Disable the rest of the tests on Mac due to Mac's handling of menus being
// slightly different to the other platforms.
--- a/browser/components/uitour/test/browser_UITour5.js
+++ b/browser/components/uitour/test/browser_UITour5.js
@@ -24,17 +24,18 @@ add_UITour_task(async function test_high
let ViewShownPromise = new Promise(resolve => {
appMenu.addEventListener("ViewShown", resolve, { once: true });
});
let highlightHiddenPromise = elementHiddenPromise(highlight, "Should hide highlight");
let libraryBtn = document.getElementById("appMenu-library-button");
libraryBtn.dispatchEvent(new Event("command"));
await highlightHiddenPromise;
await ViewShownPromise;
- is(PanelUI.multiView.current.id, "appMenu-libraryView", "Should show the library subview");
+ let libView = document.getElementById("appMenu-libraryView");
+ ok(PanelView.forNode(libView).active, "Should show the library subview");
is(appMenu.state, "open", "Should still open the app menu for the library subview");
// Clean up
let appMenuHiddenPromise = promisePanelElementHidden(window, appMenu);
gContentAPI.hideMenu("appMenu");
await appMenuHiddenPromise;
is(appMenu.state, "closed", "Should close the app menu");
});