Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
5 Cu.import("resource://gre/modules/Services.jsm");
7 const DEFAULT_PREFS = Services.prefs.getDefaultBranch("social.manifest.");
9 function run_test() {
10 // Test must run at startup for migration to occur, so we can only test
11 // one migration per test file
12 initApp();
14 // NOTE: none of the manifests here can have a workerURL set, or we attempt
15 // to create a FrameWorker and that fails under xpcshell...
16 let manifest = { // normal provider
17 name: "provider 1",
18 origin: "https://example1.com",
19 builtin: true // as of fx22 this should be true for default prefs
20 };
22 DEFAULT_PREFS.setCharPref(manifest.origin, JSON.stringify(manifest));
23 Services.prefs.setBoolPref("social.active", true);
25 Cu.import("resource://gre/modules/SocialService.jsm");
27 let runner = new AsyncRunner();
28 let next = runner.next.bind(runner);
29 runner.appendIterator(testMigration(manifest, next));
30 runner.next();
31 }
33 function testMigration(manifest, next) {
34 // look at social.activeProviders, we should have migrated into that, and
35 // we should be set as a user level pref after migration
36 do_check_false(MANIFEST_PREFS.prefHasUserValue(manifest.origin));
37 // we need to access the providers for everything to initialize
38 yield SocialService.getProviderList(next);
39 do_check_true(SocialService.enabled);
40 do_check_true(Services.prefs.prefHasUserValue("social.activeProviders"));
42 let activeProviders;
43 let pref = Services.prefs.getComplexValue("social.activeProviders",
44 Ci.nsISupportsString);
45 activeProviders = JSON.parse(pref);
46 do_check_true(activeProviders[manifest.origin]);
47 do_check_true(MANIFEST_PREFS.prefHasUserValue(manifest.origin));
48 do_check_true(JSON.parse(DEFAULT_PREFS.getCharPref(manifest.origin)).builtin);
50 let userPref = JSON.parse(MANIFEST_PREFS.getCharPref(manifest.origin));
51 do_check_true(parseInt(userPref.updateDate) > 0);
52 // migrated providers wont have an installDate
53 do_check_true(userPref.installDate === 0);
54 }