Skip to content

Commit 0df9ebb

Browse files
committed
Bug 1996449 - Ensure runOncePerModification("displayMenuBar", ..) works as expected. r=mkaply,mossop
runOncePerModification works on strings. If you pass a boolean down it will always call its callback (because "true" != true etc). Differential Revision: https://phabricator.services.mozilla.com/D271452
1 parent 8c5cb13 commit 0df9ebb

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

browser/components/enterprisepolicies/Policies.sys.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3177,6 +3177,8 @@ export function runOnce(actionName, callback) {
31773177
* A promise that will resolve once the callback finishes running.
31783178
*/
31793179
async function runOncePerModification(actionName, policyValue, callback) {
3180+
// Stringify the value so that it matches what we'd get from getStringPref.
3181+
policyValue = policyValue + "";
31803182
let prefName = `browser.policies.runOncePerModification.${actionName}`;
31813183
let oldPolicyValue = Services.prefs.getStringPref(prefName, undefined);
31823184
if (policyValue === oldPolicyValue) {

browser/components/enterprisepolicies/tests/browser/browser_policy_display_menu.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,22 @@ add_task(async function test_menu_shown_string() {
2828

2929
// Since testing will apply the policy after the browser has already started,
3030
// we will need to open a new window to actually see the menu bar
31-
let newWin = await BrowserTestUtils.openNewBrowserWindow();
32-
let menubar = newWin.document.getElementById("toolbar-menubar");
33-
ok(!menubar.hasAttribute("autohide"), "The menu bar should not be hidden");
31+
{
32+
let newWin = await BrowserTestUtils.openNewBrowserWindow();
33+
let menubar = newWin.document.getElementById("toolbar-menubar");
34+
ok(!menubar.hasAttribute("autohide"), "The menu bar should not be hidden");
35+
setToolbarVisibility(menubar, false);
36+
ok(menubar.hasAttribute("autohide"), "The menu bar should be hidden");
37+
await BrowserTestUtils.closeWindow(newWin);
38+
}
3439

35-
await BrowserTestUtils.closeWindow(newWin);
40+
{
41+
// Make sure the menubar autohide persists even tho it's default-on.
42+
let newWin = await BrowserTestUtils.openNewBrowserWindow();
43+
let menubar = newWin.document.getElementById("toolbar-menubar");
44+
ok(menubar.hasAttribute("autohide"), "The menu bar should be hidden");
45+
await BrowserTestUtils.closeWindow(newWin);
46+
}
3647
});
3748

3849
add_task(async function test_menubar_on() {

0 commit comments

Comments
 (0)