toolkit/components/social/test/browser/worker_social.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.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 // apiPort is our port to WorkerAPI
michael@0 6 let apiPort;
michael@0 7 // testerPort is whatever port a test calls us on
michael@0 8 let testerPort;
michael@0 9
michael@0 10 onconnect = function(e) {
michael@0 11 // assume this is a test connecting, but if we get
michael@0 12 // social.initialize, we know it is our WorkerAPI
michael@0 13 // instance connecting and we'll set apiPort
michael@0 14 let port = e.ports[0];
michael@0 15 port.onmessage = function onMessage(event) {
michael@0 16 let {topic, data} = event.data;
michael@0 17 switch (topic) {
michael@0 18 case "social.initialize":
michael@0 19 apiPort = port;
michael@0 20 break;
michael@0 21 case "test-initialization":
michael@0 22 testerPort = port;
michael@0 23 port.postMessage({topic: "test-initialization-complete"});
michael@0 24 break;
michael@0 25 case "test-profile":
michael@0 26 apiPort.postMessage({topic: "social.user-profile", data: data});
michael@0 27 break;
michael@0 28 case "test-ambient":
michael@0 29 apiPort.postMessage({topic: "social.ambient-notification", data: data});
michael@0 30 break;
michael@0 31 case "test.cookies-get":
michael@0 32 apiPort.postMessage({topic: "social.cookies-get"});
michael@0 33 break;
michael@0 34 case "social.cookies-get-response":
michael@0 35 testerPort.postMessage({topic: "test.cookies-get-response", data: data});
michael@0 36 break;
michael@0 37 case "test-reload-init":
michael@0 38 apiPort.postMessage({topic: 'social.reload-worker'});
michael@0 39 break;
michael@0 40 case "test-notification-create":
michael@0 41 apiPort.postMessage({topic: 'social.notification-create',
michael@0 42 data: data});
michael@0 43 testerPort.postMessage({topic: 'did-notification-create'});
michael@0 44 break;
michael@0 45 case "test-indexeddb-create":
michael@0 46 var request = indexedDB.open("workerdb", 1);
michael@0 47 request.onerror = function(event) {
michael@0 48 port.postMessage({topic: 'social.indexeddb-result', data: { result: "error" }});
michael@0 49 };
michael@0 50 request.onsuccess = function(event) {
michael@0 51 // Do something with request.result!
michael@0 52 var db = request.result;
michael@0 53 db.close();
michael@0 54 port.postMessage({topic: 'social.indexeddb-result', data: { result: "ok" }});
michael@0 55 };
michael@0 56 break;
michael@0 57 }
michael@0 58 }
michael@0 59 }

mercurial