Sat, 03 Jan 2015 20:18:00 +0100
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 "use strict";
7 module.metadata = {
8 "stability": "experimental"
9 };
11 const { Cc, Ci } = require("chrome");
12 const { id } = require("./self");
14 // placeholder, copied from bootstrap.js
15 let sanitizeId = function(id){
16 let uuidRe =
17 /^\{([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\}$/;
19 let domain = id.
20 toLowerCase().
21 replace(/@/g, "-at-").
22 replace(/\./g, "-dot-").
23 replace(uuidRe, "$1");
25 return domain
26 };
28 const PSEUDOURI = "indexeddb://" + sanitizeId(id) // https://bugzilla.mozilla.org/show_bug.cgi?id=779197
30 // Firefox 26 and earlier releases don't support `indexedDB` in sandboxes
31 // automatically, so we need to inject `indexedDB` to `this` scope ourselves.
32 if (typeof(indexedDB) === "undefined") {
33 Cc["@mozilla.org/dom/indexeddb/manager;1"].
34 getService(Ci.nsIIndexedDatabaseManager).
35 initWindowless(this);
37 // Firefox 14 gets this with a prefix
38 if (typeof(indexedDB) === "undefined")
39 this.indexedDB = mozIndexedDB;
40 }
42 // Use XPCOM because `require("./url").URL` doesn't expose the raw uri object.
43 let principaluri = Cc["@mozilla.org/network/io-service;1"].
44 getService(Ci.nsIIOService).
45 newURI(PSEUDOURI, null, null);
47 let principal = Cc["@mozilla.org/scriptsecuritymanager;1"].
48 getService(Ci.nsIScriptSecurityManager).
49 getCodebasePrincipal(principaluri);
51 exports.indexedDB = Object.freeze({
52 open: indexedDB.openForPrincipal.bind(indexedDB, principal),
53 deleteDatabase: indexedDB.deleteForPrincipal.bind(indexedDB, principal),
54 cmp: indexedDB.cmp
55 });
57 exports.IDBKeyRange = IDBKeyRange;
58 exports.DOMException = Ci.nsIDOMDOMException;