[tor-browser#32668] Use the Security Level as the default policy for Options Reset on Tor Browser.

This commit is contained in:
hackademix 2024-10-25 23:52:28 +02:00
parent 5e3e15f9e6
commit 1ccbcc5da1
No known key found for this signature in database
GPG Key ID: 231A83AFDA9C2434
2 changed files with 12 additions and 13 deletions

View File

@ -102,7 +102,7 @@ var Settings = {
ns.defaults.local.isTorBrowser = true; // prevents reset from forgetting
ns.defaults.sync.cascadeRestrictions = true; // we want this to be the default even on reset
Sites.onionSecure = true;
ns.local.torBrowserPolicy = policy; // save for reset
if (!this.gotTorBrowserInit) {
// First initialization message from the Tor Browser
this.gotTorBrowserInit = true;
@ -111,13 +111,14 @@ var Settings = {
// copying the Security Level preset on startup (only).
// Manually changing the security level works as usual.
ns.local.isTorBrowser = true;
await ns.save(ns.local);
await Promise.all([ns.saveSession(), ns.save(ns.local)]);
this.reloadOptionsUI();
return;
}
} else {
reloadOptionsUI = true;
}
reloadOptionsUI = true;
if (policy && policy.TRUSTED) {
// Gracefully handle "new" capabilities still unknown to our settings host
const knownCapabilities = settingsHost && settingsHost.knownCapabilities
@ -151,13 +152,9 @@ var Settings = {
}
if (settings.sync === null) {
// user is resetting options
policy = this.createDefaultDryPolicy();
// overriden defaults when user manually resets options
// we want the reset options to stick (otherwise it gets very confusing)
ns.defaults.sync.overrideTorBrowserPolicy = true;
// User is resetting options:
// pick either current Tor Browser Security Level or default NoScript policy
policy = ns.local.torBrowserPolicy || this.createDefaultDryPolicy();
reloadOptionsUI = true;
}

View File

@ -71,14 +71,12 @@
if (data) {
ns.policy = new Policy(data.policy);
ns.unrestrictedTabs = new Set(data.unrestrictedTabs);
Settings.gotTorBrowserInit = data.gotTorBrowserInit;
}
},
beforeSave() { // beforeSave
return {
policy: ns.policy.dry(true),
unrestrictedTabs: [...ns.unrestrictedTabs],
gotTorBrowserInit: Settings.gotTorBrowserInit,
};
},
}
@ -401,6 +399,10 @@
return obj;
},
async saveSession() {
await session.save();
},
async collectSeen(tabId) {
await this.initializing;
try {