Bug 1551213 - Update commands on show in HTML about:addons r=mixedpuppy,kmag

Differential Revision: https://phabricator.services.mozilla.com/D33304

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mark Striemer 2019-05-31 22:19:50 +00:00
parent aa48f14906
commit 9b169ea3a5
2 changed files with 40 additions and 0 deletions

View File

@ -3842,6 +3842,7 @@ function htmlView(type) {
async show(param, request, state, refresh) {
await htmlBrowserLoaded;
await this.node.contentWindow.show(type, param);
gViewController.updateCommands();
gViewController.notifyViewChanged();
},

View File

@ -824,3 +824,42 @@ add_task(async function testPermissions() {
info("Check permissions for add-on without permission messages");
await runTest("addon2@mochi.test");
});
// When the back button is used, its disabled state will be updated. If it
// isn't updated when showing a view, then it will be disabled on the next
// use (bug 1551213) if the last use caused it to become disabled.
add_task(async function testGoBackButton() {
// Make sure the list view is the first loaded view so you cannot go back.
Services.prefs.setCharPref(PREF_UI_LASTCATEGORY, "addons://list/extension");
let id = "addon1@mochi.test";
let win = await loadInitialView("extension");
let doc = win.document;
let backButton = win.managerWindow.document.getElementById("go-back");
let loadDetailView = () => {
let loaded = waitForViewLoad(win);
getAddonCard(doc, id).querySelector("[action=expand]").click();
return loaded;
};
let checkBackButtonState = () => {
is_element_visible(backButton, "Back button is visible on the detail page");
ok(!backButton.disabled, "Back button is enabled");
};
// Load the detail view, first time should be fine.
await loadDetailView();
checkBackButtonState();
// Use the back button directly to pop from history and trigger its disabled
// state to be updated.
let loaded = waitForViewLoad(win);
backButton.click();
await loaded;
await loadDetailView();
checkBackButtonState();
await closeView(win);
});