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.

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

mercurial