summaryrefslogtreecommitdiffstats
path: root/browser/base
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-08 15:18:07 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-08 15:18:07 +0000
commit328078c4d259e52db1a4848c00ee0b420775c91c (patch)
treeca9b0e61a1c03f0246b0371423bbbe570193e2f1 /browser/base
parentAdding upstream version 115.8.0esr. (diff)
downloadfirefox-esr-328078c4d259e52db1a4848c00ee0b420775c91c.tar.xz
firefox-esr-328078c4d259e52db1a4848c00ee0b420775c91c.zip
Adding upstream version 115.9.0esr.upstream/115.9.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/base')
-rw-r--r--browser/base/content/browser-fullScreenAndPointerLock.js13
-rw-r--r--browser/base/content/test/popupNotifications/browser_popupNotification_security_delay.js101
2 files changed, 114 insertions, 0 deletions
diff --git a/browser/base/content/browser-fullScreenAndPointerLock.js b/browser/base/content/browser-fullScreenAndPointerLock.js
index 82d5727f14..cc5fefff68 100644
--- a/browser/base/content/browser-fullScreenAndPointerLock.js
+++ b/browser/base/content/browser-fullScreenAndPointerLock.js
@@ -275,11 +275,24 @@ var PointerlockFsWarning = {
};
var PointerLock = {
+ _isActive: false,
+
+ /**
+ * @returns {boolean} - true if pointer lock is currently active for the
+ * associated window.
+ */
+ get isActive() {
+ return this._isActive;
+ },
+
entered(originNoSuffix) {
+ this._isActive = true;
+ Services.obs.notifyObservers(null, "pointer-lock-entered");
PointerlockFsWarning.showPointerLock(originNoSuffix);
},
exited() {
+ this._isActive = false;
PointerlockFsWarning.close("pointerlock-warning");
},
};
diff --git a/browser/base/content/test/popupNotifications/browser_popupNotification_security_delay.js b/browser/base/content/test/popupNotifications/browser_popupNotification_security_delay.js
index 515895f35a..600456640b 100644
--- a/browser/base/content/test/popupNotifications/browser_popupNotification_security_delay.js
+++ b/browser/base/content/test/popupNotifications/browser_popupNotification_security_delay.js
@@ -294,3 +294,104 @@ add_task(async function test_notificationReshowTabSwitch() {
"Should not longer see the notification."
);
});
+
+/**
+ * Tests that the security delay gets reset when a window is repositioned and
+ * the PopupNotifications panel position is updated.
+ */
+add_task(async function test_notificationWindowMove() {
+ await ensureSecurityDelayReady();
+
+ info("Open a notification.");
+ let popupShownPromise = waitForNotificationPanel();
+ showNotification();
+ await popupShownPromise;
+ ok(
+ PopupNotifications.isPanelOpen,
+ "PopupNotification should be open after show call."
+ );
+
+ // Test that the initial security delay works.
+ info("Trigger main action via button click during the new security delay.");
+ triggerMainCommand(PopupNotifications.panel);
+
+ await new Promise(resolve => setTimeout(resolve, 0));
+
+ ok(PopupNotifications.isPanelOpen, "PopupNotification should still be open.");
+ let notification = PopupNotifications.getNotification(
+ "foo",
+ gBrowser.selectedBrowser
+ );
+ ok(
+ notification,
+ "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) {
+ return;
+ }
+
+ info("Wait for security delay to expire.");
+ await new Promise(resolve =>
+ // eslint-disable-next-line mozilla/no-arbitrary-setTimeout
+ setTimeout(resolve, TEST_SECURITY_DELAY + 500)
+ );
+
+ info("Reposition the window");
+ // Remember original window position.
+ let { screenX, screenY } = window;
+
+ let promisePopupPositioned = BrowserTestUtils.waitForEvent(
+ PopupNotifications.panel,
+ "popuppositioned"
+ );
+
+ // Move the window.
+ window.moveTo(200, 200);
+
+ // Wait for the panel to reposition and the PopupNotifications listener to run.
+ await promisePopupPositioned;
+ await new Promise(resolve => setTimeout(resolve, 0));
+
+ info("Trigger main action via button click during the new security delay.");
+ triggerMainCommand(PopupNotifications.panel);
+
+ await new Promise(resolve => setTimeout(resolve, 0));
+
+ ok(PopupNotifications.isPanelOpen, "PopupNotification should still be open.");
+ notification = PopupNotifications.getNotification(
+ "foo",
+ gBrowser.selectedBrowser
+ );
+ ok(
+ notification,
+ "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) {
+ return;
+ }
+
+ // 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");
+ let notificationHiddenPromise = waitForNotificationPanelHidden();
+ triggerMainCommand(PopupNotifications.panel);
+
+ info("Wait for panel to be hidden.");
+ await notificationHiddenPromise;
+
+ ok(
+ !PopupNotifications.getNotification("foo", gBrowser.selectedBrowser),
+ "Should not longer see the notification."
+ );
+
+ // Reset window position
+ window.moveTo(screenX, screenY);
+});