mirror of
https://github.com/zotero/zotero.git
synced 2026-10-11 03:38:25 +00:00
As of Firefox 153.3.0esr, Services.scriptloader refuses jar:file: and file: URIs unless allowUnsafeURL is passed (Mozilla bug 1974213), so no plugin loads: bootstrap.js fails with "Trying to load untrusted URI", then "Plugin ... is missing bootstrap method 'startup'". Pass allowUnsafeURL when loading a plugin's bootstrap.js and prefs.js, and preference pane scripts, and temporarily enable security.allow_unsafe_subscript_loads, which covers loads from plugin code outside the bootstrap scope. Also add a test that installs a fixture plugin that loads a script from its XPI and sets a default pref. --------- Co-authored-by: Dan Stillman <dstillman@zotero.org>
29 lines
1.1 KiB
JavaScript
29 lines
1.1 KiB
JavaScript
describe("Zotero.Plugins", function () {
|
|
var { AddonManager } = ChromeUtils.importESModule("resource://gre/modules/AddonManager.sys.mjs");
|
|
|
|
describe("Loading", function () {
|
|
var addon;
|
|
|
|
afterEach(async function () {
|
|
if (addon) {
|
|
await addon.uninstall();
|
|
addon = null;
|
|
}
|
|
Zotero.Prefs.clear('pluginLoadingTest.pref');
|
|
});
|
|
|
|
// The fixture's bootstrap.js loads main.js from its own XPI with
|
|
// Services.scriptloader.loadSubScript(rootURI + ...), as plugins commonly do
|
|
it("should load scripts and default prefs from a plugin's XPI", async function () {
|
|
let dir = getTestDataDirectory();
|
|
dir.append('plugin-loading-test');
|
|
let xpiPath = PathUtils.join(await getTempDirectory(), 'plugin-loading-test.xpi');
|
|
await Zotero.File.zipDirectory(dir.path, xpiPath);
|
|
addon = await AddonManager.installTemporaryAddon(Zotero.File.pathToFile(xpiPath));
|
|
|
|
await waitForCallback(() => Zotero.PluginLoadingTest, 100, 10);
|
|
assert.equal(Zotero.PluginLoadingTest, 'loaded');
|
|
assert.equal(Zotero.Prefs.get('pluginLoadingTest.pref'), 'default');
|
|
});
|
|
});
|
|
});
|