Bug 1677625 - Fix the What's New panel DevTools control buttons. r=emcminn

This was originally fixed in bug 1673733, but then re-broken with a refactor
for unit tests in bug 1673109.

Differential Revision: https://phabricator.services.mozilla.com/D97231
This commit is contained in:
Mike Conley 2020-11-17 19:58:56 +00:00
Родитель 69e9ee97f9
Коммит 090be35fed
2 изменённых файлов: 22 добавлений и 20 удалений

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

@ -1843,29 +1843,27 @@ class _ASRouter {
);
}
async forceWNPanel(browserWindow) {
async forceWNPanel(browser) {
let win = browser.ownerGlobal;
await ToolbarPanelHub.enableToolbarButton();
browserWindow.PanelUI.showSubView(
win.PanelUI.showSubView(
"PanelUI-whatsNew",
browserWindow.document.getElementById("whats-new-menu-button")
win.document.getElementById("whats-new-menu-button")
);
let panel = browserWindow.document.getElementById(
"customizationui-widget-panel"
);
let panel = win.document.getElementById("customizationui-widget-panel");
// Set the attribute to keep the panel open
panel.setAttribute("noautohide", true);
}
async closeWNPanel(browserWindow) {
let panel = browserWindow.document.getElementById(
"customizationui-widget-panel"
);
async closeWNPanel(browser) {
let win = browser.ownerGlobal;
let panel = win.document.getElementById("customizationui-widget-panel");
// Set the attribute to allow the panel to close
panel.setAttribute("noautohide", false);
// Removing the button is enough to close the panel.
await ToolbarPanelHub._hideToolbarButton(browserWindow);
await ToolbarPanelHub._hideToolbarButton(win);
}
}
this._ASRouter = _ASRouter;

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

@ -2207,24 +2207,28 @@ describe("ASRouter", () => {
});
describe("#forceWNPanel", () => {
let browserWindow = {
document: new Document(),
PanelUI: {
showSubView: sinon.stub(),
panel: {
setAttribute: sinon.stub(),
let browser = {
ownerGlobal: {
document: new Document(),
PanelUI: {
showSubView: sinon.stub(),
panel: {
setAttribute: sinon.stub(),
},
},
},
};
let fakePanel = {
setAttribute: sinon.stub(),
};
sinon.stub(browserWindow.document, "getElementById").returns(fakePanel);
sinon
.stub(browser.ownerGlobal.document, "getElementById")
.returns(fakePanel);
it("should call enableToolbarButton", async () => {
await Router.forceWNPanel(browserWindow);
await Router.forceWNPanel(browser);
assert.calledOnce(FakeToolbarPanelHub.enableToolbarButton);
assert.calledOnce(browserWindow.PanelUI.showSubView);
assert.calledOnce(browser.ownerGlobal.PanelUI.showSubView);
assert.calledWith(fakePanel.setAttribute, "noautohide", true);
});
});