Back out b9597187a3d6 (bug 985212) for xpcshell bustage

CLOSED TREE
This commit is contained in:
Phil Ringnalda 2014-03-22 21:30:46 -07:00
Родитель 708509ef43
Коммит 5b1152ce0e
34 изменённых файлов: 45 добавлений и 79 удалений

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

@ -173,15 +173,16 @@ function uninstallFakePAC() {
Cm.nsIComponentRegistrar.unregisterFactory(CID, PACSystemSettings);
}
// Many tests do service.startOver() and don't expect the provider type to
// change (whereas by default, a startOver will do exactly that so FxA is
// subsequently used). The tests that know how to deal with
// We want to ensure the legacy provider is used for most of these tests,
// including after a service.startOver. The tests that know how to deal with
// the Firefox Accounts identity hack things to ensure that still works.
function ensureStartOverKeepsIdentity() {
function setDefaultIdentityConfig() {
Cu.import("resource://gre/modules/Services.jsm");
Services.prefs.setBoolPref("services.sync.fxaccounts.enabled", false);
Services.prefs.setBoolPref("services.sync-testing.startOverKeepIdentity", true);
do_register_cleanup(function() {
Services.prefs.clearUserPref("services.sync.fxaccounts.enabled");
Services.prefs.clearUserPref("services.sync-testing.startOverKeepIdentity");
});
}
ensureStartOverKeepsIdentity();
setDefaultIdentityConfig();

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

@ -98,14 +98,23 @@ WeaveService.prototype = {
* @return bool
*/
get fxAccountsEnabled() {
// work out what identity manager to use. This is stored in a preference;
// if the preference exists, we trust it.
let fxAccountsEnabled;
try {
// Old sync guarantees '@' will never appear in the username while FxA
// uses the FxA email address - so '@' is the flag we use.
let username = Services.prefs.getCharPref(SYNC_PREFS_BRANCH + "username");
return !username || username.contains('@');
fxAccountsEnabled = Services.prefs.getBoolPref("services.sync.fxaccounts.enabled");
} catch (_) {
return true; // No username == only allow FxA to be configured.
// That pref doesn't exist - so let's assume this is a first-run.
// If sync already appears configured, we assume it's for the legacy
// provider.
let prefs = Services.prefs.getBranch(SYNC_PREFS_BRANCH);
fxAccountsEnabled = !prefs.prefHasUserValue("username");
Services.prefs.setBoolPref("services.sync.fxaccounts.enabled", fxAccountsEnabled);
}
// Currently we don't support toggling this pref after initialization -
// except when sync is reset - but this 1 exception is enough that we can't
// cache the value.
return fxAccountsEnabled;
},
/**

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

@ -7,7 +7,6 @@
this.EXPORTED_SYMBOLS = [
"btoa", // It comes from a module import.
"encryptPayload",
"ensureLegacyIdentityManager",
"setBasicCredentials",
"makeIdentityConfig",
"configureFxAccountIdentity",
@ -50,17 +49,6 @@ this.waitForZeroTimer = function waitForZeroTimer(callback) {
CommonUtils.namedTimer(wait, 150, {}, "timer");
}
/**
* Ensure Sync is configured with the "legacy" identity provider.
*/
this.ensureLegacyIdentityManager = function() {
let ns = {};
Cu.import("resource://services-sync/service.js", ns);
Status.__authManager = ns.Service.identity = new IdentityManager();
ns.Service._clusterManager = ns.Service.identity.createClusterManager(ns.Service);
}
this.setBasicCredentials =
function setBasicCredentials(username, password, syncKey) {
let ns = {};
@ -182,7 +170,7 @@ this.SyncTestingInfrastructure = function (server, username, password, syncKey)
let ns = {};
Cu.import("resource://services-sync/service.js", ns);
ensureLegacyIdentityManager();
let auth = ns.Service.identity;
let config = makeIdentityConfig();
// XXX - hacks for the sync identity provider.
if (username)
@ -245,7 +233,7 @@ this.add_identity_test = function(test, testFunction) {
test.add_task(function() {
note("sync");
let oldIdentity = Status._authManager;
ensureLegacyIdentityManager();
Status.__authManager = ns.Service.identity = new IdentityManager();
yield testFunction();
Status.__authManager = ns.Service.identity = oldIdentity;
});

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

@ -910,6 +910,7 @@ Sync11Service.prototype = {
this.identity.finalize().then(
() => {
this.identity.username = "";
Services.prefs.clearUserPref("services.sync.fxaccounts.enabled");
this.status.__authManager = null;
this.identity = Status._authManager;
this._clusterManager = this.identity.createClusterManager(this);

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

@ -7,7 +7,6 @@ Cu.import("resource://services-sync/keys.js");
Cu.import("resource://services-sync/record.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
Cu.import("resource://testing-common/services/sync/utils.js");
function prepareBookmarkItem(collection, id) {
let b = new Bookmark(collection, id);
@ -16,7 +15,6 @@ function prepareBookmarkItem(collection, id) {
}
function run_test() {
ensureLegacyIdentityManager();
Service.identity.username = "john@example.com";
Service.identity.syncKey = "abcdeabcdeabcdeabcdeabcdea";
generateNewKeys(Service.collectionKeys);

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

@ -81,7 +81,6 @@ add_test(function test_bad_hmac() {
}
try {
ensureLegacyIdentityManager();
let passphrase = "abcdeabcdeabcdeabcdeabcdea";
Service.serverURL = server.baseURI;
Service.login("foo", "ilovejane", passphrase);

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

@ -5,12 +5,10 @@ Cu.import("resource://services-sync/keys.js");
Cu.import("resource://services-sync/record.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
Cu.import("resource://testing-common/services/sync/utils.js");
function run_test() {
_("Set up test fixtures.");
ensureLegacyIdentityManager();
Service.identity.username = "john@example.com";
Service.clusterURL = "http://fakebase/";
let baseUri = "http://fakebase/1.1/foo/storage/";

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

@ -204,8 +204,6 @@ function run_test() {
let logger = Log.repository.rootLogger;
Log.repository.rootLogger.addAppender(new Log.DumpAppender());
ensureLegacyIdentityManager();
run_next_test();
}

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

@ -55,8 +55,6 @@ function run_test() {
Log.repository.getLogger("Sync.SyncScheduler").level = Log.Level.Trace;
Log.repository.getLogger("Sync.ErrorHandler").level = Log.Level.Trace;
ensureLegacyIdentityManager();
run_next_test();
}

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

@ -15,10 +15,10 @@ add_task(function* test_startover() {
let oldValue = Services.prefs.getBoolPref("services.sync-testing.startOverKeepIdentity", true);
Services.prefs.setBoolPref("services.sync-testing.startOverKeepIdentity", false);
ensureLegacyIdentityManager();
yield configureIdentity({username: "johndoe"});
// The boolean flag on the xpcom service should reflect a legacy provider.
// The pref that forces FxA identities should not be set.
do_check_false(Services.prefs.getBoolPref("services.sync.fxaccounts.enabled"));
// And the boolean flag on the xpcom service should reflect this.
let xps = Cc["@mozilla.org/weave/service;1"]
.getService(Components.interfaces.nsISupports)
.wrappedJSObject;
@ -43,7 +43,9 @@ add_task(function* test_startover() {
Service.startOver();
yield deferred.promise; // wait for the observer to fire.
// the xpcom service should indicate FxA is enabled.
// should have reset the pref that indicates if FxA is enabled.
do_check_true(Services.prefs.getBoolPref("services.sync.fxaccounts.enabled"));
// the xpcom service should agree FxA is enabled.
do_check_true(xps.fxAccountsEnabled);
// should have swapped identities.
do_check_true(Service.identity instanceof BrowserIDManager);
@ -55,5 +57,6 @@ add_task(function* test_startover() {
do_check_neq(oldClusterManager, Service._clusterManager);
// reset the world.
Services.prefs.setBoolPref("services.sync.fxaccounts.enabled", false);
Services.prefs.setBoolPref("services.sync-testing.startOverKeepIdentity", oldValue);
});

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

@ -14,6 +14,15 @@ Cu.import("resource://testing-common/services/healthreport/utils.jsm", this);
function run_test() {
initTestLogging();
// A head JS file always sets the
// services.sync.fxaccounts.enabled pref. This prevents us from testing
// pristine profile conditions and likely indicates there isn't test
// coverage of the Sync service's fxAccountsEnabled property. Check
// that pre-condition and hack around it.
let branch = new Preferences("services.sync.");
Assert.ok(branch.isSet("fxaccounts.enabled"), "Check precondition");
branch.reset("fxaccounts.enabled");
run_next_test();
}

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

@ -21,7 +21,6 @@ function shared_setup() {
hmacErrorCount = 0;
// Do not instantiate SyncTestingInfrastructure; we need real crypto.
ensureLegacyIdentityManager();
setBasicCredentials("foo", "foo", "aabcdeabcdeabcdeabcdeabcde");
// Make sure RotaryEngine is the only one we sync.

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

@ -186,7 +186,6 @@ function run_test() {
// Simulate Sync setup with credentials in place. We want to make
// sure the J-PAKE requests don't include those data.
ensureLegacyIdentityManager();
setBasicCredentials("johndoe", "ilovejane");
initTestLogging("Trace");

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

@ -8,7 +8,6 @@ Cu.import("resource://services-sync/record.js");
Cu.import("resource://services-sync/resource.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
Cu.import("resource://testing-common/services/sync/utils.js");
let cryptoWrap;
@ -31,7 +30,6 @@ function run_test() {
let server;
do_test_pending();
ensureLegacyIdentityManager();
Service.identity.username = "john@example.com";
Service.identity.syncKey = "a-abcde-abcde-abcde-abcde-abcde";
let keyBundle = Service.identity.syncKeyBundle;

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

@ -6,7 +6,6 @@ Cu.import("resource://services-sync/identity.js");
Cu.import("resource://services-sync/resource.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
Cu.import("resource://testing-common/services/sync/utils.js");
function test_toJSON() {
@ -79,7 +78,6 @@ function test_fetch() {
function run_test() {
initTestLogging("Trace");
ensureLegacyIdentityManager();
test_toJSON();
test_fetch();

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

@ -31,7 +31,6 @@ function run_test() {
"/1.1/johndoe/storage/meta/global": uaHandler(meta_global.handler()),
});
ensureLegacyIdentityManager();
setBasicCredentials("johndoe", "ilovejane");
Service.serverURL = server.baseURI + "/";
Service.clusterURL = server.baseURI + "/";

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

@ -8,7 +8,6 @@ Cu.import("resource://services-sync/util.js");
Cu.import("resource://testing-common/services/sync/utils.js");
function run_test() {
ensureLegacyIdentityManager();
setBasicCredentials("johndoe", "ilovejane", Utils.generatePassphrase());
Service.serverURL = "http://weave.server/";

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

@ -5,12 +5,10 @@ Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
Cu.import("resource://testing-common/services/sync/fakeservices.js");
Cu.import("resource://testing-common/services/sync/utils.js");
function test_urls() {
_("URL related Service properties correspond to preference settings.");
try {
ensureLegacyIdentityManager();
do_check_true(!!Service.serverURL); // actual value may change
do_check_eq(Service.clusterURL, "");
do_check_eq(Service.userBaseURL, undefined);

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

@ -13,8 +13,6 @@ function run_test() {
Log.repository.getLogger("Sync.Resource").level = Log.Level.Trace;
Log.repository.getLogger("Sync.Service").level = Log.Level.Trace;
ensureLegacyIdentityManager();
run_next_test();
}

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

@ -7,7 +7,6 @@ Cu.import("resource://testing-common/services/sync/utils.js");
function run_test() {
do_test_pending();
ensureLegacyIdentityManager();
let server = httpd_setup({
"/user/1.0/johndoe": httpd_handler(200, "OK", "1"),
"/user/1.0/janedoe": httpd_handler(200, "OK", "0"),

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

@ -18,12 +18,11 @@ function do_check_throws(func) {
add_test(function test_findCluster() {
_("Test Service._findCluster()");
let server;
ensureLegacyIdentityManager();
try {
_("_findCluster() throws on network errors (e.g. connection refused).");
do_check_throws(function() {
Service.serverURL = "http://dummy:9000/";
Service.identity.account = "johndoe";
Service.identify.account = "johndoe";
Service._clusterManager._findCluster();
});

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

@ -43,8 +43,6 @@ add_test(function v4_upgrade() {
"/1.1/johndoe/storage/prefs": new ServerCollection().handler()
});
ensureLegacyIdentityManager();
try {
_("Set up some tabs.");

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

@ -16,7 +16,6 @@ function run_test() {
Log.repository.getLogger("Sync.StorageRequest").level = Log.Level.Trace;
initTestLogging();
ensureLegacyIdentityManager();
setBasicCredentials("johndoe", "ilovejane");
run_next_test();

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

@ -72,7 +72,6 @@ add_test(function test_login_logout() {
try {
_("Force the initial state.");
ensureLegacyIdentityManager();
Service.status.service = STATUS_OK;
do_check_eq(Service.status.service, STATUS_OK);

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

@ -58,8 +58,6 @@ function run_test() {
let upd = collectionsHelper.with_updated_collection;
let collections = collectionsHelper.collections;
ensureLegacyIdentityManager();
do_test_pending();
let server = httpd_setup({
"/1.1/johndoe/info/collections": login_handling(collectionsHelper.handler),

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

@ -9,7 +9,6 @@ Cu.import("resource://testing-common/services/sync/utils.js");
function run_test() {
try {
// Ensure we have a blank slate to start.
ensureLegacyIdentityManager();
Services.logins.removeAllLogins();
setBasicCredentials("johndoe", "ilovejane", "abbbbbcccccdddddeeeeefffff");

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

@ -65,7 +65,6 @@ function run_test() {
try {
_("Log in.");
ensureLegacyIdentityManager();
Service.serverURL = server.baseURI;
_("Checking Status.sync with no credentials.");

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

@ -30,7 +30,6 @@ function run_test() {
let logger = Log.repository.rootLogger;
Log.repository.rootLogger.addAppender(new Log.DumpAppender());
ensureLegacyIdentityManager();
// This test expects a clean slate -- no saved passphrase.
Services.logins.removeAllLogins();
let johnHelper = track_collections_helper();

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

@ -82,7 +82,6 @@ add_test(function test_credentials_preserved() {
_("Ensure that credentials are preserved if client is wiped.");
// Required for wipeClient().
ensureLegacyIdentityManager();
Service.identity.account = "testaccount";
Service.identity.basicPassword = "testpassword";
Service.clusterURL = "http://dummy:9000/";

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

@ -4,11 +4,9 @@
Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-sync/status.js");
Cu.import("resource://services-sync/util.js");
Cu.import("resource://testing-common/services/sync/utils.js");
function run_test() {
initTestLogging("Trace");
ensureLegacyIdentityManager();
try {
_("Ensure fresh config.");

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

@ -85,13 +85,6 @@ function run_test() {
Log.repository.getLogger("Sync.Service").level = Log.Level.Trace;
Log.repository.getLogger("Sync.scheduler").level = Log.Level.Trace;
// The scheduler checks Weave.fxaEnabled to determine whether to use
// FxA defaults or legacy defaults. As .fxaEnabled checks the username, we
// set a username here then reset the default to ensure they are used.
ensureLegacyIdentityManager();
setBasicCredentials("johndoe");
scheduler.setDefaults();
run_next_test();
}

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

@ -12,8 +12,6 @@ function run_test() {
Log.repository.getLogger("Sync.RESTRequest").level = Log.Level.Trace;
initTestLogging();
ensureLegacyIdentityManager();
run_next_test();
}

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

@ -4,13 +4,11 @@
Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
Cu.import("resource://testing-common/services/sync/utils.js");
// Test upgrade of a dashed old-style sync key.
function run_test() {
const PBKDF2_KEY_BYTES = 16;
initTestLogging("Trace");
ensureLegacyIdentityManager();
let passphrase = "abcde-abcde-abcde-abcde";
do_check_false(Utils.isPassphrase(passphrase));

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

@ -95,10 +95,11 @@ let TPS = {
* Check if the Firefox Accounts feature is enabled
*/
get fxaccounts_enabled() {
let service = Cc["@mozilla.org/weave/service;1"]
.getService(Components.interfaces.nsISupports)
.wrappedJSObject;
return service.fxAccountsEnabled;
try {
return Services.prefs.getBoolPref("services.sync.fxaccounts.enabled");
} catch (e) {
return false;
}
},
DumpError: function (msg) {