зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
69e9ee97f9
Коммит
090be35fed
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче