Skip to content

Commit 6c322af

Browse files
committed
Bug 1828966 - Ensure Pin to Toolbar context menu item shows the correct state when opening the context menu. r=mconley
I could only reproduce on macOS but it is indeed a valid bug. I noticed that moving the `await` code at the bottom of the function fixed it but that didn't sound too great. I decided to propose this patch instead, and I made sure that we wouldn't hit a similar problem with the "disabled" state of the remove button. Apparently, that still works as expected (on macOS). I am not quite sure how to cover that with a test, though, because we have test coverage for the attributes and the HTML markup is correctly updated. For example, I could see the correct `checked` attribute in the HTML (in the devtools) with the wrong context menu item state rendered, sigh. This likely means the race is at a lower level (cocoa?). Differential Revision: https://phabricator.services.mozilla.com/D176416 UltraBlame original commit: 123d6c05b43fbf76d56f9326a177a1851610133d
1 parent 7438c55 commit 6c322af

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

browser/base/content/browser-addons.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,7 +1592,7 @@ var gUnifiedExtensions = {
15921592
window.dispatchEvent(new CustomEvent("UnifiedExtensionsTogglePanel"));
15931593
},
15941594

1595-
async updateContextMenu(menu, event) {
1595+
updateContextMenu(menu, event) {
15961596

15971597

15981598

@@ -1601,7 +1601,6 @@ var gUnifiedExtensions = {
16011601
}
16021602

16031603
const id = this._getExtensionId(menu);
1604-
const addon = await AddonManager.getAddonByID(id);
16051604
const widgetId = this._getWidgetId(menu);
16061605
const forBrowserAction = !!widgetId;
16071606

@@ -1621,17 +1620,22 @@ var gUnifiedExtensions = {
16211620
menuSeparator.hidden = !forBrowserAction;
16221621
pinButton.hidden = !forBrowserAction;
16231622

1623+
reportButton.hidden = !gAddonAbuseReportEnabled;
1624+
1625+
1626+
1627+
AddonManager.getAddonByID(id).then(addon => {
1628+
removeButton.disabled = !(
1629+
addon.permissions & AddonManager.PERM_CAN_UNINSTALL
1630+
);
1631+
});
1632+
16241633
if (forBrowserAction) {
16251634
let area = CustomizableUI.getPlacementOfWidget(widgetId).area;
16261635
let inToolbar = area != CustomizableUI.AREA_ADDONS;
16271636
pinButton.setAttribute("checked", inToolbar);
16281637
}
16291638

1630-
reportButton.hidden = !gAddonAbuseReportEnabled;
1631-
removeButton.disabled = !(
1632-
addon.permissions & AddonManager.PERM_CAN_UNINSTALL
1633-
);
1634-
16351639
ExtensionsUI.originControlsMenu(menu, id);
16361640

16371641
const browserAction = this.browserActionFor(WebExtensionPolicy.getByID(id));

0 commit comments

Comments
 (0)