toolkit/components/social/test/browser/browser_SocialProvider.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
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 let provider;
     7 function test() {
     8   waitForExplicitFinish();
    10   let manifest = {
    11     origin: 'http://example.com',
    12     name: "Example Provider",
    13     workerURL: "http://example.com/browser/toolkit/components/social/test/browser/worker_social.js"
    14   };
    16   SocialService.addProvider(manifest, function (p) {
    17     provider = p;
    18     runTests(tests, undefined, undefined, function () {
    19       SocialService.removeProvider(p.origin, function() {
    20         ok(!provider.enabled, "removing an enabled provider should have disabled the provider");
    21         let port = provider.getWorkerPort();
    22         ok(!port, "should not be able to get a port after removing the provider");
    23         provider = null;
    24         finish();
    25       });
    26     });
    27   });
    28 }
    30 let tests = {
    31   testSingleProvider: function(next) {
    32     ok(provider.enabled, "provider is initially enabled");
    33     let port = provider.getWorkerPort();
    34     ok(port, "should be able to get a port from enabled provider");
    35     port.close();
    36     ok(provider.workerAPI, "should be able to get a workerAPI from enabled provider");
    38     provider.enabled = false;
    40     ok(!provider.enabled, "provider is now disabled");
    41     port = provider.getWorkerPort();
    42     ok(!port, "shouldn't be able to get a port from disabled provider");
    43     ok(!provider.workerAPI, "shouldn't be able to get a workerAPI from disabled provider");
    45     provider.enabled = true;
    47     ok(provider.enabled, "provider is re-enabled");
    48     let port = provider.getWorkerPort();
    49     ok(port, "should be able to get a port from re-enabled provider");
    50     port.close();
    51     ok(provider.workerAPI, "should be able to get a workerAPI from re-enabled provider");
    52     next();
    53   },
    54   testTwoProviders: function(next) {
    55     // add another provider, test both workers
    56     let manifest = {
    57       origin: 'http://test2.example.com',
    58       name: "Example Provider 2",
    59       workerURL: "http://test2.example.com/browser/toolkit/components/social/test/browser/worker_social.js"
    60     };
    61     SocialService.addProvider(manifest, function (provider2) {
    62       ok(provider.enabled, "provider is initially enabled");
    63       ok(provider2.enabled, "provider2 is initially enabled");
    64       let port = provider.getWorkerPort();
    65       let port2 = provider2.getWorkerPort();
    66       ok(port, "have port for provider");
    67       ok(port2, "have port for provider2");
    68       port.onmessage = function(e) {
    69         if (e.data.topic == "test-initialization-complete") {
    70           ok(true, "first provider initialized");
    71           port2.postMessage({topic: "test-initialization"});
    72         }
    73       }
    74       port2.onmessage = function(e) {
    75         if (e.data.topic == "test-initialization-complete") {
    76           ok(true, "second provider initialized");
    77           SocialService.removeProvider(provider2.origin, function() {
    78             next();
    79           });
    80         }
    81       }
    82       port.postMessage({topic: "test-initialization"});
    83     });
    84   }
    85 }

mercurial