js/xpconnect/tests/unit/component_import.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 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
     7 function FooComponent() {
     8   this.wrappedJSObject = this;
     9 }
    10 FooComponent.prototype =
    11 {
    12   // nsIClassInfo + information for XPCOM registration code in XPCOMUtils.jsm
    13   classDescription:  "Foo Component",
    14   classID:           Components.ID("{6b933fe6-6eba-4622-ac86-e4f654f1b474}"),
    15   contractID:       "@mozilla.org/tests/module-importer;1",
    17   // nsIClassInfo
    18   implementationLanguage: Components.interfaces.nsIProgrammingLanguage.JAVASCRIPT,
    19   flags: 0,
    21   getInterfaces: function getInterfaces(aCount) {
    22     var interfaces = [Components.interfaces.nsIClassInfo];
    23     aCount.value = interfaces.length;
    25     // Guerilla test for line numbers hiding in this method
    26     var threw = true;
    27     try {
    28       thereIsNoSuchIdentifier;
    29       threw = false;
    30     } catch (ex) {
    31       do_check_true(ex.lineNumber == 28);
    32     }
    33     do_check_true(threw);
    35     return interfaces;
    36   },
    38   getHelperForLanguage: function getHelperForLanguage(aLanguage) {
    39     return null;
    40   },
    42   // nsISupports
    43   QueryInterface: function QueryInterface(aIID) {
    44     if (aIID.equals(Components.interfaces.nsIClassInfo) ||
    45         aIID.equals(Components.interfaces.nsISupports))
    46       return this;
    48     throw Components.results.NS_ERROR_NO_INTERFACE;
    49   }
    50 };
    52 function BarComponent() {
    53 }
    54 BarComponent.prototype =
    55 {
    56   // nsIClassInfo + information for XPCOM registration code in XPCOMUtils.jsm
    57   classDescription: "Module importer test 2",
    58   classID: Components.ID("{708a896a-b48d-4bff-906e-fc2fd134b296}"),
    59   contractID: "@mozilla.org/tests/module-importer;2",
    61   // nsIClassInfo
    62   implementationLanguage: Components.interfaces.nsIProgrammingLanguage.JAVASCRIPT,
    63   flags: 0,
    65   getInterfaces: function getInterfaces(aCount) {
    66     var interfaces = [Components.interfaces.nsIClassInfo];
    67     aCount.value = interfaces.length;
    68     return interfaces;
    69   },
    71   getHelperForLanguage: function getHelperForLanguage(aLanguage) {
    72     return null;
    73   },
    75   // nsISupports
    76   QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIClassInfo])
    77 };
    79 function do_check_true(cond, text) {
    80   // we don't have the test harness' utilities in this scope, so we need this
    81   // little helper. In the failure case, the exception is propagated to the
    82   // caller in the main run_test() function, and the test fails.
    83   if (!cond)
    84     throw "Failed check: " + text;
    85 }
    87 var gComponentsArray = [FooComponent, BarComponent];
    88 this.NSGetFactory = XPCOMUtils.generateNSGetFactory(gComponentsArray);

mercurial