toolkit/components/social/test/xpcshell/test_SocialServiceMigration29.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     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");
     8 function run_test() {
     9   // Test must run at startup for migration to occur, so we can only test
    10   // one migration per test file
    11   initApp();
    13   // NOTE: none of the manifests here can have a workerURL set, or we attempt
    14   // to create a FrameWorker and that fails under xpcshell...
    15   let manifest = { // normal provider
    16     name: "provider 1",
    17     origin: "https://example1.com",
    18   };
    20   MANIFEST_PREFS.setCharPref(manifest.origin, JSON.stringify(manifest));
    22   // Set both providers active and flag the first one as "current"
    23   let activeVal = Cc["@mozilla.org/supports-string;1"].
    24              createInstance(Ci.nsISupportsString);
    25   let active = {};
    26   active[manifest.origin] = 1;
    27   activeVal.data = JSON.stringify(active);
    28   Services.prefs.setComplexValue("social.activeProviders",
    29                                  Ci.nsISupportsString, activeVal);
    31   // social.enabled pref is the key focus of this test. We set the user pref,
    32   // and then migration should a) remove the provider from activeProviders and
    33   // b) unset social.enabled
    34   Services.prefs.setBoolPref("social.enabled", false);
    36   Cu.import("resource://gre/modules/SocialService.jsm");
    38   let runner = new AsyncRunner();
    39   let next = runner.next.bind(runner);
    40   runner.appendIterator(testMigration(manifest, next));
    41   runner.next();
    42 }
    44 function testMigration(manifest, next) {
    45   // look at social.activeProviders, we should have migrated into that, and
    46   // we should be set as a user level pref after migration
    47   do_check_true(Services.prefs.prefHasUserValue("social.enabled"));
    48   do_check_true(MANIFEST_PREFS.prefHasUserValue(manifest.origin));
    49   // we need to access the providers for everything to initialize
    50   yield SocialService.getProviderList(next);
    51   do_check_false(SocialService.enabled);
    52   do_check_false(Services.prefs.prefHasUserValue("social.enabled"));
    53   do_check_true(Services.prefs.prefHasUserValue("social.activeProviders"));
    55   let activeProviders;
    56   let pref = Services.prefs.getComplexValue("social.activeProviders",
    57                                             Ci.nsISupportsString).data;
    58   activeProviders = JSON.parse(pref);
    59   do_check_true(activeProviders[manifest.origin] == undefined);
    60   do_check_true(MANIFEST_PREFS.prefHasUserValue(manifest.origin));
    61 }

mercurial