From fcea19dfd2c426bac0456da850e7c12258e4b9eb Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 8 Apr 2024 17:11:26 +0200 Subject: Adding upstream version 115.8.0esr. Signed-off-by: Daniel Baumann --- browser/actors/PromptParent.sys.mjs | 2 +- .../content/browser-fullScreenAndPointerLock.js | 3 + .../browser_fullscreen_permissions_prompt.js | 130 +++++++++++++++++++++ .../components/enterprisepolicies/Policies.sys.mjs | 31 +++-- .../schemas/policies-schema.json | 4 + .../enterprisepolicies/tests/xpcshell/head.js | 5 + .../tests/xpcshell/test_preferences.js | 11 ++ browser/config/version.txt | 2 +- browser/config/version_display.txt | 2 +- .../test/fixtures/heuristics_cc_exp.html | 2 +- 10 files changed, 178 insertions(+), 14 deletions(-) (limited to 'browser') diff --git a/browser/actors/PromptParent.sys.mjs b/browser/actors/PromptParent.sys.mjs index 76eca1a66f..eaabe22ca8 100644 --- a/browser/actors/PromptParent.sys.mjs +++ b/browser/actors/PromptParent.sys.mjs @@ -132,7 +132,7 @@ export class PromptParent extends JSWindowActorParent { switch (message.name) { case "Prompt:Open": - if (!this.windowContext.isCurrentGlobal) { + if (!this.windowContext.isActiveInTab) { return undefined; } diff --git a/browser/base/content/browser-fullScreenAndPointerLock.js b/browser/base/content/browser-fullScreenAndPointerLock.js index 29183138c7..82d5727f14 100644 --- a/browser/base/content/browser-fullScreenAndPointerLock.js +++ b/browser/base/content/browser-fullScreenAndPointerLock.js @@ -255,6 +255,9 @@ var PointerlockFsWarning = { if (this._state == "hiding") { this._element.hidden = true; } + if (this._state == "onscreen") { + window.dispatchEvent(new CustomEvent("FullscreenWarningOnScreen")); + } break; } case "activate": { diff --git a/browser/base/content/test/fullscreen/browser_fullscreen_permissions_prompt.js b/browser/base/content/test/fullscreen/browser_fullscreen_permissions_prompt.js index 82f0c97631..70dab99276 100644 --- a/browser/base/content/test/fullscreen/browser_fullscreen_permissions_prompt.js +++ b/browser/base/content/test/fullscreen/browser_fullscreen_permissions_prompt.js @@ -158,3 +158,133 @@ add_task(async function test_permission_prompt_closes_fullscreen() { BrowserTestUtils.removeTab(tab); await SpecialPowers.popPrefEnv(); }); + +function triggerMainCommand(popup) { + let notifications = popup.childNodes; + ok(!!notifications.length, "at least one notification displayed"); + let notification = notifications[0]; + info("Triggering main command for notification " + notification.id); + EventUtils.synthesizeMouseAtCenter(notification.button, {}); +} + +add_task( + async function test_permission_prompt_closes_fullscreen_and_extends_security_delay() { + const TEST_SECURITY_DELAY = 500; + await SpecialPowers.pushPrefEnv({ + set: [ + ["dom.webnotifications.requireuserinteraction", false], + ["permissions.fullscreen.allowed", false], + ["security.notification_enable_delay", TEST_SECURITY_DELAY], + // macOS is not affected by the sec delay bug because it uses the native + // macOS full screen API. Revert back to legacy behavior so we can also + // test on macOS. If this pref is removed in the future we can consider + // skipping the testcase for macOS altogether. + ["full-screen-api.macos-native-full-screen", false], + ], + }); + + let tab = await BrowserTestUtils.openNewForegroundTab( + gBrowser, + "https://example.com" + ); + let browser = tab.linkedBrowser; + info("Entering DOM full-screen"); + await changeFullscreen(browser, true); + + let popupShown = BrowserTestUtils.waitForPopupEvent( + window.PopupNotifications.panel, + "shown" + ); + let fullScreenExit = waitForFullScreenState(browser, false); + + info("Requesting notification permission"); + requestNotificationPermission(browser).catch(() => {}); + await popupShown; + + let notificationHiddenPromise = BrowserTestUtils.waitForPopupEvent( + window.PopupNotifications.panel, + "hidden" + ); + + info("Waiting for full-screen exit"); + await fullScreenExit; + + info("Wait for original security delay to expire."); + SimpleTest.requestFlakyTimeout( + "Wait for original security delay to expire." + ); + // eslint-disable-next-line mozilla/no-arbitrary-setTimeout + await new Promise(resolve => setTimeout(resolve, TEST_SECURITY_DELAY)); + + info( + "Trigger main action via button click during the extended security delay" + ); + triggerMainCommand(PopupNotifications.panel); + + let notification = PopupNotifications.getNotification( + "web-notifications", + gBrowser.selectedBrowser + ); + + // Linux in CI seems to skip the full screen animation, which means its not + // affected by the bug and we can't test extension of the sec delay here. + if (Services.appinfo.OS == "Linux") { + todo( + notification && + !notification.dismissed && + BrowserTestUtils.is_visible(PopupNotifications.panel.firstChild), + "Notification should still be open because we clicked during the security delay." + ); + } else { + ok( + notification && + !notification.dismissed && + BrowserTestUtils.is_visible(PopupNotifications.panel.firstChild), + "Notification should still be open because we clicked during the security delay." + ); + } + + // If the notification is no longer shown (test failure) skip the remaining + // checks. + if (!notification) { + // Cleanup + BrowserTestUtils.removeTab(tab); + await SpecialPowers.popPrefEnv(); + // Remove the granted notification permission. + Services.perms.removeAll(); + return; + } + + Assert.greater( + notification.timeShown, + performance.now(), + "Notification timeShown property should be in the future, because the security delay was extended." + ); + + // Ensure that once the security delay has passed the notification can be + // closed again. + let fakeTimeShown = TEST_SECURITY_DELAY + 500; + info(`Manually set timeShown to ${fakeTimeShown}ms in the past.`); + notification.timeShown = performance.now() - fakeTimeShown; + + info("Trigger main action via button click outside security delay"); + triggerMainCommand(PopupNotifications.panel); + + info("Wait for panel to be hidden."); + await notificationHiddenPromise; + + ok( + !PopupNotifications.getNotification( + "web-notifications", + gBrowser.selectedBrowser + ), + "Should not longer see the notification." + ); + + // Cleanup + BrowserTestUtils.removeTab(tab); + await SpecialPowers.popPrefEnv(); + // Remove the granted notification permission. + Services.perms.removeAll(); + } +); diff --git a/browser/components/enterprisepolicies/Policies.sys.mjs b/browser/components/enterprisepolicies/Policies.sys.mjs index cb15d441a6..21c5bfaa67 100644 --- a/browser/components/enterprisepolicies/Policies.sys.mjs +++ b/browser/components/enterprisepolicies/Policies.sys.mjs @@ -1797,7 +1797,9 @@ export var Policies = { Services.prefs.unlockPref(preference); } try { - switch (typeof param[preference].Value) { + let prefType = + param[preference].Type || typeof param[preference].Value; + switch (prefType) { case "boolean": prefBranch.setBoolPref(preference, param[preference].Value); break; @@ -1807,14 +1809,9 @@ export var Policies = { throw new Error(`Non-integer value for ${preference}`); } - // This is ugly, but necessary. On Windows GPO and macOS - // configs, booleans are converted to 0/1. In the previous - // Preferences implementation, the schema took care of - // automatically converting these values to booleans. - // Since we allow arbitrary prefs now, we have to do - // something different. See bug 1666836. - // Even uglier, because pdfjs prefs are set async, we need - // to get their type from PdfJsDefaultPreferences. + // Because pdfjs prefs are set async, we can't check the + // default pref branch to see if they are int or bool, so we + // have to get their type from PdfJsDefaultPreferences. if (preference.startsWith("pdfjs.")) { let preferenceTail = preference.replace("pdfjs.", ""); if ( @@ -1829,7 +1826,21 @@ export var Policies = { !!param[preference].Value ); } - } else if ( + break; + } + + // This is ugly, but necessary. On Windows GPO and macOS + // configs, booleans are converted to 0/1. In the previous + // Preferences implementation, the schema took care of + // automatically converting these values to booleans. + // Since we allow arbitrary prefs now, we have to do + // something different. See bug 1666836, 1668374, and 1872267. + + // We only set something as int if it was explicit in policy, + // the same type as the default pref, or NOT 0/1. Otherwise + // we set it as bool. + if ( + param[preference].Type == "number" || prefBranch.getPrefType(preference) == prefBranch.PREF_INT || ![0, 1].includes(param[preference].Value) ) { diff --git a/browser/components/enterprisepolicies/schemas/policies-schema.json b/browser/components/enterprisepolicies/schemas/policies-schema.json index 62885837b9..8ff88935dd 100644 --- a/browser/components/enterprisepolicies/schemas/policies-schema.json +++ b/browser/components/enterprisepolicies/schemas/policies-schema.json @@ -1131,6 +1131,10 @@ "Status": { "type": "string", "enum": ["default", "locked", "user", "clear"] + }, + "Type": { + "type": "string", + "enum": ["number", "boolean", "string"] } } } diff --git a/browser/components/enterprisepolicies/tests/xpcshell/head.js b/browser/components/enterprisepolicies/tests/xpcshell/head.js index 0680e7ece7..1c7c8844fa 100644 --- a/browser/components/enterprisepolicies/tests/xpcshell/head.js +++ b/browser/components/enterprisepolicies/tests/xpcshell/head.js @@ -132,6 +132,11 @@ function checkDefaultPref(prefName, prefValue) { Services.prefs.PREF_INVALID, `Pref ${prefName} is set on the default branch` ); + strictEqual( + Preferences.get(prefName), + prefValue, + `Pref ${prefName} has the correct value` + ); } function checkUnsetPref(prefName) { diff --git a/browser/components/enterprisepolicies/tests/xpcshell/test_preferences.js b/browser/components/enterprisepolicies/tests/xpcshell/test_preferences.js index 44b77ddc63..eb13fe24ae 100644 --- a/browser/components/enterprisepolicies/tests/xpcshell/test_preferences.js +++ b/browser/components/enterprisepolicies/tests/xpcshell/test_preferences.js @@ -64,12 +64,23 @@ const NEW_PREFERENCES_TESTS = [ Value: 11, Status: "user", }, + "browser.policies.test.default.number.implicit": { + Value: 0, + Status: "default", + }, + "browser.policies.test.default.number.explicit": { + Value: 0, + Status: "default", + Type: "number", + }, }, }, defaultPrefs: { "browser.policies.test.default.boolean": true, "browser.policies.test.default.string": "string", "browser.policies.test.default.number": 11, + "browser.policies.test.default.number.implicit": false, + "browser.policies.test.default.number.explicit": 0, }, lockedPrefs: { "browser.policies.test.locked.boolean": true, diff --git a/browser/config/version.txt b/browser/config/version.txt index fe6fbc7f02..f5a13d6b75 100644 --- a/browser/config/version.txt +++ b/browser/config/version.txt @@ -1 +1 @@ -115.7.0 +115.8.0 diff --git a/browser/config/version_display.txt b/browser/config/version_display.txt index dd6d2998c7..86a7ee43ba 100644 --- a/browser/config/version_display.txt +++ b/browser/config/version_display.txt @@ -1 +1 @@ -115.7.0esr +115.8.0esr diff --git a/browser/extensions/formautofill/test/fixtures/heuristics_cc_exp.html b/browser/extensions/formautofill/test/fixtures/heuristics_cc_exp.html index e14f1520a6..4d8cb4a101 100644 --- a/browser/extensions/formautofill/test/fixtures/heuristics_cc_exp.html +++ b/browser/extensions/formautofill/test/fixtures/heuristics_cc_exp.html @@ -48,7 +48,6 @@

-- cgit v1.2.3