hamburger menu update badge is not displayed on new windows

RESOLVED WORKSFORME

Status

()

Firefox
Toolbars and Customization
RESOLVED WORKSFORME
3 years ago
3 months ago

People

(Reporter: zer0, Unassigned)

Tracking

Trunk
x86
Mac OS X
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

3 years ago
The hamburger icon shows a badge in case an update is available, or was failed, to all windows currently open. However, any windows opened after that, won't inherit that state – no badge is displayed on hamburger menu.

STR:
1) Open Firefox, create a new window (e.g. CTRL+N)
2) Open scratchpad, set browser as environment, paste the following code and execute it:

Services.obs.notifyObservers(null, "update-staged", "pending");

3) The icon shows in both windows
4) Create a new window
5) The new window doesn't have any badge on hamburger button

In order to fix it, we need to store a value for the "session", that we reset every time Firefox is executed. We could probably store that value in a preference, but maybe there is a better way.
(Reporter)

Comment 1

3 years ago
Gijs, do you have any suggestion about what's the best place to store such information?
Flags: needinfo?(gijskruitbosch+bugs)
(In reply to Matteo Ferretti [:matteo] [:zer0] from comment #1)
> Gijs, do you have any suggestion about what's the best place to store such
> information?

The update service already exposes this information, surely?
Flags: needinfo?(gijskruitbosch+bugs)
I looked into it and I think the following code should do the trick:

XPCOMUtils.defineLazyServiceGetter(Services, "um",
                                   "@mozilla.org/updates/update-manager;1",
                                   "nsIUpdateManager");

// There is an update already staged / ready to be applied.
if (Services.um.activeUpdate &&
    (Services.um.activeUpdate.state == "pending" ||
     Services.um.activeUpdate.state == "pending-service")) {
       addBadge(); // (you get the point)
}
(Reporter)

Comment 4

3 years ago
(In reply to Panos Astithas [:past] from comment #3)

> // There is an update already staged / ready to be applied.
> if (Services.um.activeUpdate &&
>     (Services.um.activeUpdate.state == "pending" ||
>      Services.um.activeUpdate.state == "pending-service")) {
>        addBadge(); // (you get the point)
> }

Thanks! I discovered that code in aboutDialog.js yesterday, but I wasn't sure how to test it in order to check if it's working as we expect. Under your suggestion, I'll try to contact Robert Strong to check how to do so.
Blocks: 1080406
Duplicate of this bug: 1108147
The app update mochitest-chrome and xpcshell tests do this and you should be able to do the same. They can create the state for the different types of updates and end results for applying an update then reload the updatemanager if needed, etc.

They are located under toolkit/mozapps/update/tests/
I see this working today in 57 Nightly, but I don't know when it was fixed.
Status: NEW → RESOLVED
Last Resolved: 3 months ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.