diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /browser/modules/test/unit/social/test_SocialServiceMigration29.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'browser/modules/test/unit/social/test_SocialServiceMigration29.js')
-rw-r--r-- | browser/modules/test/unit/social/test_SocialServiceMigration29.js | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/browser/modules/test/unit/social/test_SocialServiceMigration29.js b/browser/modules/test/unit/social/test_SocialServiceMigration29.js new file mode 100644 index 000000000..824673ddf --- /dev/null +++ b/browser/modules/test/unit/social/test_SocialServiceMigration29.js @@ -0,0 +1,61 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + +Cu.import("resource://gre/modules/Services.jsm"); + + +function run_test() { + // Test must run at startup for migration to occur, so we can only test + // one migration per test file + initApp(); + + // NOTE: none of the manifests here can have a workerURL set, or we attempt + // to create a FrameWorker and that fails under xpcshell... + let manifest = { // normal provider + name: "provider 1", + origin: "https://example1.com", + }; + + MANIFEST_PREFS.setCharPref(manifest.origin, JSON.stringify(manifest)); + + // Set both providers active and flag the first one as "current" + let activeVal = Cc["@mozilla.org/supports-string;1"]. + createInstance(Ci.nsISupportsString); + let active = {}; + active[manifest.origin] = 1; + activeVal.data = JSON.stringify(active); + Services.prefs.setComplexValue("social.activeProviders", + Ci.nsISupportsString, activeVal); + + // social.enabled pref is the key focus of this test. We set the user pref, + // and then migration should a) remove the provider from activeProviders and + // b) unset social.enabled + Services.prefs.setBoolPref("social.enabled", false); + + Cu.import("resource:///modules/SocialService.jsm"); + + let runner = new AsyncRunner(); + let next = runner.next.bind(runner); + runner.appendIterator(testMigration(manifest, next)); + runner.next(); +} + +function* testMigration(manifest, next) { + // look at social.activeProviders, we should have migrated into that, and + // we should be set as a user level pref after migration + do_check_true(Services.prefs.prefHasUserValue("social.enabled")); + do_check_true(MANIFEST_PREFS.prefHasUserValue(manifest.origin)); + // we need to access the providers for everything to initialize + yield SocialService.getProviderList(next); + do_check_false(SocialService.enabled); + do_check_false(Services.prefs.prefHasUserValue("social.enabled")); + do_check_true(Services.prefs.prefHasUserValue("social.activeProviders")); + + let activeProviders; + let pref = Services.prefs.getComplexValue("social.activeProviders", + Ci.nsISupportsString).data; + activeProviders = JSON.parse(pref); + do_check_true(activeProviders[manifest.origin] == undefined); + do_check_true(MANIFEST_PREFS.prefHasUserValue(manifest.origin)); +} |