diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /toolkit/mozapps/extensions/test/xpcshell/test_db_path.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/mozapps/extensions/test/xpcshell/test_db_path.js')
-rw-r--r-- | toolkit/mozapps/extensions/test/xpcshell/test_db_path.js | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_db_path.js b/toolkit/mozapps/extensions/test/xpcshell/test_db_path.js new file mode 100644 index 0000000000..a9a54291f0 --- /dev/null +++ b/toolkit/mozapps/extensions/test/xpcshell/test_db_path.js @@ -0,0 +1,64 @@ +const { AddonTestUtils } = ChromeUtils.importESModule( + "resource://testing-common/AddonTestUtils.sys.mjs" +); + +const DEFAULT_THEME_ID = "default-theme@mozilla.org"; + +let global = this; + +// Test that paths in the extensions database are stored properly +// if they include non-ascii characters (see bug 1428234 for an example of +// a past bug with such paths) +add_task(async function test_non_ascii_path() { + const PROFILE_VAR = "XPCSHELL_TEST_PROFILE_DIR"; + let profileDir = PathUtils.join( + Services.env.get(PROFILE_VAR), + "\u00ce \u00e5m \u00f1\u00f8t \u00e5s\u00e7ii" + ); + Services.env.set(PROFILE_VAR, profileDir); + + AddonTestUtils.init(global); + AddonTestUtils.overrideCertDB(); + AddonTestUtils.createAppInfo( + "xpcshell@tests.mozilla.org", + "XPCShell", + "1", + "1" + ); + + const ID1 = "profile1@tests.mozilla.org"; + let xpi1 = await AddonTestUtils.createTempWebExtensionFile({ + id: ID1, + manifest: { + browser_specific_settings: { gecko: { id: ID1 } }, + }, + }); + + const ID2 = "profile2@tests.mozilla.org"; + let xpi2 = await AddonTestUtils.createTempWebExtensionFile({ + id: ID2, + manifest: { + browser_specific_settings: { gecko: { id: ID2 } }, + }, + }); + + await AddonTestUtils.manuallyInstall(xpi1); + await AddonTestUtils.promiseStartupManager(); + await AddonTestUtils.promiseInstallFile(xpi2); + await AddonTestUtils.promiseShutdownManager(); + + let dbfile = PathUtils.join(profileDir, "extensions.json"); + let data = await IOUtils.readJSON(dbfile); + + let addons = data.addons.filter(a => a.id !== DEFAULT_THEME_ID); + Assert.ok(Array.isArray(addons), "extensions.json has addons array"); + Assert.equal(2, addons.length, "extensions.json has 2 addons"); + Assert.ok( + addons[0].path.startsWith(profileDir), + "path property for sideloaded extension has the proper profile directory" + ); + Assert.ok( + addons[1].path.startsWith(profileDir), + "path property for extension installed at runtime has the proper profile directory" + ); +}); |