Bug 1385196 - [Form Autofill] Test: Enable the feature based on locale and geoip. r=lchang

MozReview-Commit-ID: 3eCRKB9eiDK

--HG--
extra : rebase_source : bca338ef318a61e9a786df7895eaf1e7db7539c5
This commit is contained in:
Matthew Noorenberghe 2017-08-10 21:38:48 -07:00
Родитель e0f4586d33
Коммит 5ca6d3bc4c
3 изменённых файлов: 39 добавлений и 1 удалений

Просмотреть файл

@ -3,7 +3,7 @@
*/
/* exported getTempFile, loadFormAutofillContent, runHeuristicsTest, sinon,
* initProfileStorage, getSyncChangeCounter, objectMatches
* initProfileStorage, getSyncChangeCounter, objectMatches, bootstrapURI
*/
"use strict";
@ -51,10 +51,15 @@ let extensionDir = Services.dirsvc.get("GreD", Ci.nsIFile);
extensionDir.append("browser");
extensionDir.append("features");
extensionDir.append(EXTENSION_ID);
let bootstrapFile = extensionDir.clone();
bootstrapFile.append("bootstrap.js");
let bootstrapURI = Services.io.newFileURI(bootstrapFile).spec;
// If the unpacked extension doesn't exist, use the packed version.
if (!extensionDir.exists()) {
extensionDir = extensionDir.parent;
extensionDir.append(EXTENSION_ID + ".xpi");
let jarURI = Services.io.newFileURI(extensionDir);
bootstrapURI = "jar:" + jarURI.spec + "!/bootstrap.js";
}
Components.manager.addBootstrappedManifestLocation(extensionDir);

Просмотреть файл

@ -0,0 +1,32 @@
/**
* Test enabling the feature in specific locales and regions.
*/
"use strict";
// Load bootstrap.js into a sandbox to be able to test `isAvailable`
let sandbox = {};
Services.scriptloader.loadSubScript(bootstrapURI, sandbox, "utf-8");
do_print("bootstrapURI: " + bootstrapURI);
add_task(async function test_defaultTestEnvironment() {
do_check_true(sandbox.isAvailable());
});
add_task(async function test_unsupportedRegion() {
Services.prefs.setCharPref("extensions.formautofill.available", "detect");
Services.prefs.setCharPref("browser.search.region", "ZZ");
do_register_cleanup(function cleanupRegion() {
Services.prefs.clearUserPref("browser.search.region");
});
do_check_false(sandbox.isAvailable());
});
add_task(async function test_supportedRegion() {
Services.prefs.setCharPref("extensions.formautofill.available", "detect");
Services.prefs.setCharPref("browser.search.region", "US");
do_register_cleanup(function cleanupRegion() {
Services.prefs.clearUserPref("browser.search.region");
});
do_check_true(sandbox.isAvailable());
});

Просмотреть файл

@ -28,6 +28,7 @@ support-files =
[test_getFormInputDetails.js]
[test_getInfo.js]
[test_getRecords.js]
[test_isAvailable.js]
[test_isCJKName.js]
[test_isFieldEligibleForAutofill.js]
[test_markAsAutofillField.js]