зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1693621 - Only clear temporary block permissions on user reload. r=johannh
Differential Revision: https://phabricator.services.mozilla.com/D106496
This commit is contained in:
Родитель
c08d590590
Коммит
5d2d56e536
|
@ -3539,7 +3539,7 @@ function BrowserReloadWithFlags(reloadFlags) {
|
||||||
// This is done here because we only want to reset
|
// This is done here because we only want to reset
|
||||||
// permissions on user reload.
|
// permissions on user reload.
|
||||||
for (let tab of unchangedRemoteness) {
|
for (let tab of unchangedRemoteness) {
|
||||||
SitePermissions.clearTemporaryPermissions(tab.linkedBrowser);
|
SitePermissions.clearTemporaryBlockPermissions(tab.linkedBrowser);
|
||||||
// Also reset DOS mitigations for the basic auth prompt on reload.
|
// Also reset DOS mitigations for the basic auth prompt on reload.
|
||||||
delete tab.linkedBrowser.authPromptAbuseCounter;
|
delete tab.linkedBrowser.authPromptAbuseCounter;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4361,7 +4361,7 @@
|
||||||
let browser = this.getBrowserForTab(aTab);
|
let browser = this.getBrowserForTab(aTab);
|
||||||
// Reset temporary permissions on the current tab. This is done here
|
// Reset temporary permissions on the current tab. This is done here
|
||||||
// because we only want to reset permissions on user reload.
|
// because we only want to reset permissions on user reload.
|
||||||
SitePermissions.clearTemporaryPermissions(browser);
|
SitePermissions.clearTemporaryBlockPermissions(browser);
|
||||||
// Also reset DOS mitigations for the basic auth prompt on reload.
|
// Also reset DOS mitigations for the basic auth prompt on reload.
|
||||||
delete browser.authPromptAbuseCounter;
|
delete browser.authPromptAbuseCounter;
|
||||||
gIdentityHandler.hidePopup();
|
gIdentityHandler.hidePopup();
|
||||||
|
|
|
@ -2391,7 +2391,7 @@ class UrlbarInput {
|
||||||
browser.currentURI &&
|
browser.currentURI &&
|
||||||
url === browser.currentURI.spec
|
url === browser.currentURI.spec
|
||||||
) {
|
) {
|
||||||
this.window.SitePermissions.clearTemporaryPermissions(browser);
|
this.window.SitePermissions.clearTemporaryBlockPermissions(browser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -240,21 +240,54 @@ const TemporaryPermissions = {
|
||||||
// Clears all permissions for the specified browser.
|
// Clears all permissions for the specified browser.
|
||||||
// Unlike other methods, this does NOT clear only for
|
// Unlike other methods, this does NOT clear only for
|
||||||
// the currentURI but the whole browser state.
|
// the currentURI but the whole browser state.
|
||||||
clear(browser) {
|
|
||||||
let entry = this._stateByBrowser.get(browser);
|
|
||||||
this._stateByBrowser.delete(browser);
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear temporary permissions for the specified browser. Unlike other
|
||||||
|
* methods, this does NOT clear only for the currentURI but the whole browser
|
||||||
|
* state.
|
||||||
|
* @param {Browser} browser - Browser to clear permissions for.
|
||||||
|
* @param {Number} [filterState] - Only clear permissions with the given state
|
||||||
|
* value. Defaults to all permissions.
|
||||||
|
*/
|
||||||
|
clear(browser, filterState = null) {
|
||||||
|
let entry = this._stateByBrowser.get(browser);
|
||||||
if (!entry?.uriToPerm) {
|
if (!entry?.uriToPerm) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Object.values(entry.uriToPerm).forEach(permissions => {
|
|
||||||
Object.values(permissions).forEach(({ expireTimeout }) => {
|
let { uriToPerm } = entry;
|
||||||
if (!expireTimeout) {
|
Object.entries(uriToPerm).forEach(([uriKey, permissions]) => {
|
||||||
return;
|
Object.entries(permissions).forEach(
|
||||||
|
([permId, { state, expireTimeout }]) => {
|
||||||
|
// We need to explicitly check for null or undefined here, because the
|
||||||
|
// permission state may be 0.
|
||||||
|
if (filterState != null) {
|
||||||
|
if (state != filterState) {
|
||||||
|
// Skip permission entry if it doesn't match the filter.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
delete permissions[permId];
|
||||||
|
}
|
||||||
|
// For the clear-all case we remove the entire browser entry, so we
|
||||||
|
// only need to clear the timeouts.
|
||||||
|
if (!expireTimeout) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
clearTimeout(expireTimeout);
|
||||||
}
|
}
|
||||||
clearTimeout(expireTimeout);
|
);
|
||||||
});
|
// If there are no more permissions, remove the entry from the URI map.
|
||||||
|
if (filterState != null && !Object.keys(permissions).length) {
|
||||||
|
delete uriToPerm[uriKey];
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// We're either clearing all permissions or only the permissions with state
|
||||||
|
// == filterState. If we have a filter, we can only clean up the browser if
|
||||||
|
// there are no permission entries left in the map.
|
||||||
|
if (filterState == null || !Object.keys(uriToPerm).length) {
|
||||||
|
this._stateByBrowser.delete(browser);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// Copies the temporary permission state of one browser
|
// Copies the temporary permission state of one browser
|
||||||
|
@ -866,13 +899,13 @@ var SitePermissions = {
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clears all permissions that were temporarily saved.
|
* Clears all block permissions that were temporarily saved.
|
||||||
*
|
*
|
||||||
* @param {Browser} browser
|
* @param {Browser} browser
|
||||||
* The browser object to clear.
|
* The browser object to clear.
|
||||||
*/
|
*/
|
||||||
clearTemporaryPermissions(browser) {
|
clearTemporaryBlockPermissions(browser) {
|
||||||
TemporaryPermissions.clear(browser);
|
TemporaryPermissions.clear(browser, SitePermissions.BLOCK);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -77,7 +77,7 @@ add_task(async function testTemporaryPermissionTabURLs() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SitePermissions.clearTemporaryPermissions(browser);
|
SitePermissions.clearTemporaryBlockPermissions(browser);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let principal of different) {
|
for (let principal of different) {
|
||||||
|
@ -126,7 +126,7 @@ add_task(async function testTemporaryPermissionTabURLs() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SitePermissions.clearTemporaryPermissions(browser);
|
SitePermissions.clearTemporaryBlockPermissions(browser);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Загрузка…
Ссылка в новой задаче