Unverified Commit 8c9dc570 authored by Mark Smith's avatar Mark Smith Committed by boklm
Browse files

Bug 1642404 - add an option to show that an update is being downloaded...

Bug 1642404 - add an option to show that an update is being downloaded r=bytesized,fluent-reviewers,flod

Add support for a hidden preference named app.update.notifyDuringDownload
that, when set to true, causes a "Downloading update" message to appear
in the app menu during a MAR download. Clicking the message opens the
about box so the user can see detailed progress information.

Differential Revision: https://phabricator.services.mozilla.com/D77688
parent 5a3b504e
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -131,6 +131,10 @@ pref("app.update.download.promptMaxAttempts", 2);
// download a fresh installer.
pref("app.update.elevation.promptMaxAttempts", 2);

// If set to true, a message will be displayed in the hamburger menu while
// an update is being downloaded.
pref("app.update.notifyDuringDownload", false);

// If set to true, the Update Service will automatically download updates if the
// user can apply updates. This pref is no longer used on Windows, except as the
// default value to migrate to the new location that this data is now stored
+1 −0
Original line number Diff line number Diff line
@@ -769,6 +769,7 @@ const global = this;

const listeners = {
  observers: {
    "update-downloading": ["UpdateListener"],
    "update-staged": ["UpdateListener"],
    "update-downloaded": ["UpdateListener"],
    "update-available": ["UpdateListener"],
+2 −0
Original line number Diff line number Diff line
@@ -223,6 +223,8 @@
      <vbox class="panel-subview-body">
        <vbox id="appMenu-addon-banners"/>
        <toolbarbutton id="appMenu-update-banner" class="panel-banner-item"
                       data-l10n-id="appmenuitem-update-banner"
                       data-l10n-attrs="label-update-downloading"
                       label-update-available="&updateAvailable.panelUI.label;"
                       label-update-manual="&updateManual.panelUI.label;"
                       label-update-unsupported="&updateUnsupported.panelUI.label;"
+5 −0
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ const PanelUI = {

    Services.obs.addObserver(this, "fullscreen-nav-toolbox");
    Services.obs.addObserver(this, "appMenu-notifications");
    Services.obs.addObserver(this, "show-update-progress");

    XPCOMUtils.defineLazyPreferenceGetter(
      this,
@@ -182,6 +183,7 @@ const PanelUI = {

    Services.obs.removeObserver(this, "fullscreen-nav-toolbox");
    Services.obs.removeObserver(this, "appMenu-notifications");
    Services.obs.removeObserver(this, "show-update-progress");

    window.removeEventListener("MozDOMFullscreen:Entered", this);
    window.removeEventListener("MozDOMFullscreen:Exited", this);
@@ -271,6 +273,9 @@ const PanelUI = {
        this._notifications = AppMenuNotifications.notifications;
        this._updateNotifications(true);
        break;
      case "show-update-progress":
        openAboutDialog();
        break;
    }
  },

+62 −0
Original line number Diff line number Diff line
@@ -156,6 +156,68 @@ add_task(async function testSecondaryActionWorkflow() {
  });
});

/**
 * This tests that the PanelUI update downloading badge and banner
 * notification are correctly displayed and that clicking the banner
 * item calls the main action.
 */
add_task(async function testDownloadingBadge() {
  let options = {
    gBrowser: window.gBrowser,
    url: "about:blank",
  };

  await BrowserTestUtils.withNewTab(options, async function(browser) {
    let mainActionCalled = false;
    let mainAction = {
      callback: () => {
        mainActionCalled = true;
      },
    };
    // The downloading notification is always displayed in a dismissed state.
    AppMenuNotifications.showNotification(
      "update-downloading",
      mainAction,
      undefined,
      { dismissed: true }
    );
    is(PanelUI.notificationPanel.state, "closed", "doorhanger is closed.");

    is(
      PanelUI.menuButton.getAttribute("badge-status"),
      "update-downloading",
      "Downloading badge is displaying on PanelUI button."
    );

    await gCUITestUtils.openMainMenu();
    isnot(
      PanelUI.menuButton.getAttribute("badge-status"),
      "update-downloading",
      "Downloading badge is hidden on PanelUI button."
    );
    let menuItem = PanelUI.mainView.querySelector(".panel-banner-item");
    is(
      menuItem.label,
      menuItem.getAttribute("label-update-downloading"),
      "Showing correct label (downloading)"
    );
    is(menuItem.hidden, false, "update-downloading menu item is showing.");

    await gCUITestUtils.hideMainMenu();
    is(
      PanelUI.menuButton.getAttribute("badge-status"),
      "update-downloading",
      "Downloading badge is shown on PanelUI button."
    );

    await gCUITestUtils.openMainMenu();
    menuItem.click();
    ok(mainActionCalled, "Main action callback was called");

    AppMenuNotifications.removeNotification(/.*/);
  });
});

/**
 * We want to ensure a few things with this:
 * - Adding a doorhanger will make a badge disappear
Loading