dom/bindings/test/TestInterfaceJS.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 const Cu = Components.utils;
     6 const Ci = Components.interfaces;
     8 "use strict";
     9 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
    10 Cu.import("resource://gre/modules/Services.jsm");
    12 var gGlobal = this;
    13 function checkGlobal(obj) {
    14   if (Object(obj) === obj && Cu.getGlobalForObject(obj) != gGlobal) {
    15     // This message may not make it to the caller in a useful form, so dump
    16     // as well.
    17     var msg = "TestInterfaceJS received an object from a different scope!";
    18     dump(msg + "\n");
    19     throw new Error(msg);
    20   }
    21 }
    23 function TestInterfaceJS(anyArg, objectArg) {}
    25 TestInterfaceJS.prototype = {
    26   classID: Components.ID("{2ac4e026-cf25-47d5-b067-78d553c3cad8}"),
    27   contractID: "@mozilla.org/dom/test-interface-js;1",
    28   QueryInterface: XPCOMUtils.generateQI([Ci.nsISupports]),
    30   __init: function (anyArg, objectArg) {
    31     this._anyAttr = undefined;
    32     this._objectAttr = null;
    33     this._anyArg = anyArg;
    34     this._objectArg = objectArg;
    35     checkGlobal(anyArg);
    36     checkGlobal(objectArg);
    37   },
    39   get anyArg() { return this._anyArg; },
    40   get objectArg() { return this._objectArg; },
    41   get anyAttr() { return this._anyAttr; },
    42   set anyAttr(val) { checkGlobal(val); this._anyAttr = val; },
    43   get objectAttr() { return this._objectAttr; },
    44   set objectAttr(val) { checkGlobal(val); this._objectAttr = val; },
    45   pingPongAny: function(any) { checkGlobal(any); return any; },
    46   pingPongObject: function(obj) { checkGlobal(obj); return obj; },
    48   getCallerPrincipal: function() { return Cu.getWebIDLCallerPrincipal().origin; }
    49 };
    51 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([TestInterfaceJS])

mercurial