Bug 1551213 - Update commands on show in HTML about:addons r=mixedpuppy,kmag
authorMark Striemer <mstriemer@mozilla.com>
Fri, 31 May 2019 22:19:50 +0000
changeset 476474 a55afb0346770d95e0d978538ce79023597df785
parent 476473 118a2ee534364fc3162d9ad1bc15b9089bab3730
child 476475 1a8ef8583a0bb15ef763484d52af06427ef2a118
push id36095
push userdvarga@mozilla.com
push dateSat, 01 Jun 2019 09:40:47 +0000
treeherdermozilla-central@219a897031a3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmixedpuppy, kmag
bugs1551213
milestone69.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1551213 - Update commands on show in HTML about:addons r=mixedpuppy,kmag Differential Revision: https://phabricator.services.mozilla.com/D33304
toolkit/mozapps/extensions/content/extensions.js
toolkit/mozapps/extensions/test/browser/browser_html_detail_view.js
--- a/toolkit/mozapps/extensions/content/extensions.js
+++ b/toolkit/mozapps/extensions/content/extensions.js
@@ -3837,16 +3837,17 @@ function htmlView(type) {
 
     initialize() {
       this.node = getHtmlBrowser();
     },
 
     async show(param, request, state, refresh) {
       await htmlBrowserLoaded;
       await this.node.contentWindow.show(type, param);
+      gViewController.updateCommands();
       gViewController.notifyViewChanged();
     },
 
     async hide() {
       await htmlBrowserLoaded;
       return this.node.contentWindow.hide();
     },
 
--- a/toolkit/mozapps/extensions/test/browser/browser_html_detail_view.js
+++ b/toolkit/mozapps/extensions/test/browser/browser_html_detail_view.js
@@ -819,8 +819,47 @@ add_task(async function testPermissions(
   }
 
   info("Check permissions for add-on with permission message");
   await runTest("addon1@mochi.test", ["<all_urls>", "tabs", "webNavigation"]);
 
   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);
+});