Created
April 11, 2020 21:44
-
-
Save daleharvey/d5bf7257da6552aaf82d9f894fbc1bf5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Any copyright is dedicated to the Public Domain. | |
http://creativecommons.org/publicdomain/zero/1.0/ */ | |
"use strict"; | |
const { ExtensionTestUtils } = ChromeUtils.import( | |
"resource://testing-common/ExtensionXPCShellUtils.jsm" | |
); | |
const { | |
createAppInfo, | |
promiseShutdownManager, | |
promiseStartupManager, | |
} = AddonTestUtils; | |
ExtensionTestUtils.init(this); | |
AddonTestUtils.usePrivilegedSignatures = false; | |
AddonTestUtils.overrideCertDB(); | |
const TEST_CONFIG = [ | |
{ | |
webExtension: { | |
id: "[email protected]", | |
locales: ["af", "an"] | |
}, | |
appliesTo: [{ included: { everywhere: true } }], | |
}, | |
]; | |
async function getEngineNames() { | |
let engines = await Services.search.getEngines(); | |
return engines.map(engine => engine._name); | |
} | |
function createManifest(id, name, version, keyword) { | |
return { | |
useAddonManager: "permanent", | |
manifest: { | |
version, | |
applications: { | |
gecko: { id: `${id}@tests.mozilla.org` }, | |
}, | |
chrome_settings_overrides: { | |
search_provider: { | |
name, | |
keyword, | |
search_url: `https://example.com/?q={searchTerms}&version=${version}`, | |
}, | |
}, | |
}, | |
}; | |
} | |
add_task(async function setup() { | |
Services.prefs.setBoolPref("browser.search.gModernConfig", true); | |
await useTestEngines("test-extensions", null, TEST_CONFIG); | |
await promiseStartupManager(); | |
registerCleanupFunction(promiseShutdownManager); | |
await Services.search.init(); | |
}); | |
add_task(async function basic_multilocale_test() { | |
Assert.deepEqual(await getEngineNames(), [ | |
"Multilocale AF", | |
"Multilocale AN", | |
]); | |
let manifest = createManifest("multilocale", "Multilocale AF", "2.0", "bar"); | |
const policy = WebExtensionPolicy.getByID("[email protected]"); | |
await policy.extension.upgrade(manifest); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment