Load each preference pane in its own scope

To eliminate conflicts between top-level const/let declarations.
This commit is contained in:
Abe Jellinek 2025-07-01 12:04:47 -04:00 • committed by Dan Stillman
parent ab5758c0b6
commit 32f812d515

View file

@ -95,6 +95,10 @@ var Zotero_Preferences = {
let event = new Event('unload');
child.dispatchEvent(event);
}
if (pane.sandbox) {
Cu.nukeSandbox(pane.sandbox);
pane.sandbox = null;
}
}
},
@ -276,8 +280,12 @@ var Zotero_Preferences = {
await Zotero.Promise.delay();
if (pane.scripts) {
pane.scope = new Cu.Sandbox(window, {
sandboxPrototype: window,
sandboxName: pane.rawLabel,
});
for (let script of pane.scripts) {
Services.scriptloader.loadSubScript(script, window);
Services.scriptloader.loadSubScript(script, pane.scope);
}
}
if (pane.stylesheets) {