Bug 1876675, a=diannaS

Original Revision: https://phabricator.services.mozilla.com/D202932

Differential Revision: https://phabricator.services.mozilla.com/D203626
This commit is contained in:
Paul Zuehlcke 2024-03-05 20:35:22 +00:00
parent 4ffc0adfb0
commit f982fb1714
2 changed files with 26 additions and 4 deletions

View File

@ -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");
},
};

View File

@ -309,9 +309,11 @@ export function PopupNotifications(tabbrowser, panel, iconBox, options = {}) {
);
Services.obs.addObserver(this, "fullscreen-transition-start");
Services.obs.addObserver(this, "pointer-lock-entered");
this.window.addEventListener("unload", () => {
Services.obs.removeObserver(this, "fullscreen-transition-start");
Services.obs.removeObserver(this, "pointer-lock-entered");
});
this.window.addEventListener("activate", this, true);
@ -361,7 +363,11 @@ PopupNotifications.prototype = {
},
observe(subject, topic) {
if (topic == "fullscreen-transition-start") {
// These observers apply to all windows.
if (
topic == "fullscreen-transition-start" ||
topic == "pointer-lock-entered"
) {
// Extend security delay if the panel is open.
if (this.isPanelOpen) {
let notification = this.panel.firstChild?.notification;
@ -1336,9 +1342,12 @@ PopupNotifications.prototype = {
n._recordTelemetryStat(TELEMETRY_STAT_OFFERED);
}, this);
// We're about to open the panel while in a full screen transition. Extend
// the security delay.
if (this.window.isInFullScreenTransition) {
// We're about to open the panel while in a full screen transition or
// during pointer lock. Extend the security delay to avoid clickjacking.
if (
this.window.isInFullScreenTransition ||
this.window.PointerLock?.isActive
) {
this._extendSecurityDelay(notificationsToShow);
}