chrome/test/unit/test_abi.js

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 const XULAppInfo = {
     2   vendor: "Mozilla",
     3   name: "XPCShell",
     4   ID: "{39885e5f-f6b4-4e2a-87e5-6259ecf79011}",
     5   version: "5",
     6   appBuildID: "2007010101",
     7   platformVersion: "1.9",
     8   platformBuildID: "2007010101",
     9   inSafeMode: false,
    10   logConsoleErrors: true,
    11   OS: "XPCShell",
    12   XPCOMABI: "noarch-spidermonkey",
    14   QueryInterface: function QueryInterface(iid) {
    15     if (iid.equals(Ci.nsIXULAppInfo)
    16      || iid.equals(Ci.nsIXULRuntime)
    17      || iid.equals(Ci.nsISupports))
    18       return this;
    20     throw Components.results.NS_ERROR_NO_INTERFACE;
    21   }
    22 };
    24 const XULAppInfoFactory = {
    25   // These two are used when we register all our factories (and unregister)
    26   CID: XULAPPINFO_CID,
    27   scheme: "XULAppInfo",
    28   contractID: XULAPPINFO_CONTRACTID,
    29   createInstance: function (outer, iid) {
    30     if (outer != null)
    31       throw Cr.NS_ERROR_NO_AGGREGATION;
    32     return XULAppInfo.QueryInterface(iid);
    33   }
    34 };
    36 var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
    37 registrar.registerFactory(XULAPPINFO_CID, "XULAppInfo",
    38                           XULAPPINFO_CONTRACTID, XULAppInfoFactory);
    40 registerManifests([do_get_file("data/test_abi.manifest")]);
    42 const catman = Components.classes["@mozilla.org/categorymanager;1"].
    43   getService(Components.interfaces.nsICategoryManager);
    45 function is_registered(name) {
    46   try {
    47     var d = catman.getCategoryEntry("abitest", name);
    48     return d == "found";
    49   }
    50   catch (e) {
    51     return false;
    52   }
    53 }
    55 function run_test() {
    56   do_check_true(is_registered("test1"));
    57   do_check_false(is_registered("test2"));
    58   do_check_true(is_registered("test3"));
    59   do_check_false(is_registered("test4"));
    60 }

mercurial