Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | const Cc = Components.classes; |
michael@0 | 2 | const Ci = Components.interfaces; |
michael@0 | 3 | const Cr = Components.results; |
michael@0 | 4 | const Cu = Components.utils; |
michael@0 | 5 | |
michael@0 | 6 | Cu.import("resource://gre/modules/XPCOMUtils.jsm"); |
michael@0 | 7 | |
michael@0 | 8 | try { |
michael@0 | 9 | // In the context of xpcshell tests, there won't be a default AppInfo |
michael@0 | 10 | Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULAppInfo); |
michael@0 | 11 | } |
michael@0 | 12 | catch(ex) { |
michael@0 | 13 | |
michael@0 | 14 | // Make sure to provide the right OS so crypto loads the right binaries |
michael@0 | 15 | let OS = "XPCShell"; |
michael@0 | 16 | if ("@mozilla.org/windows-registry-key;1" in Cc) |
michael@0 | 17 | OS = "WINNT"; |
michael@0 | 18 | else if ("nsILocalFileMac" in Ci) |
michael@0 | 19 | OS = "Darwin"; |
michael@0 | 20 | else |
michael@0 | 21 | OS = "Linux"; |
michael@0 | 22 | |
michael@0 | 23 | let XULAppInfo = { |
michael@0 | 24 | vendor: "Mozilla", |
michael@0 | 25 | name: "XPCShell", |
michael@0 | 26 | ID: "{3e3ba16c-1675-4e88-b9c8-afef81b3d2ef}", |
michael@0 | 27 | version: "1", |
michael@0 | 28 | appBuildID: "20100621", |
michael@0 | 29 | platformVersion: "", |
michael@0 | 30 | platformBuildID: "20100621", |
michael@0 | 31 | inSafeMode: false, |
michael@0 | 32 | logConsoleErrors: true, |
michael@0 | 33 | OS: OS, |
michael@0 | 34 | XPCOMABI: "noarch-spidermonkey", |
michael@0 | 35 | QueryInterface: XPCOMUtils.generateQI([Ci.nsIXULAppInfo, Ci.nsIXULRuntime]) |
michael@0 | 36 | }; |
michael@0 | 37 | |
michael@0 | 38 | let XULAppInfoFactory = { |
michael@0 | 39 | createInstance: function (outer, iid) { |
michael@0 | 40 | if (outer != null) |
michael@0 | 41 | throw Cr.NS_ERROR_NO_AGGREGATION; |
michael@0 | 42 | return XULAppInfo.QueryInterface(iid); |
michael@0 | 43 | } |
michael@0 | 44 | }; |
michael@0 | 45 | |
michael@0 | 46 | let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); |
michael@0 | 47 | registrar.registerFactory(Components.ID("{fbfae60b-64a4-44ef-a911-08ceb70b9f31}"), |
michael@0 | 48 | "XULAppInfo", "@mozilla.org/xre/app-info;1", |
michael@0 | 49 | XULAppInfoFactory); |
michael@0 | 50 | |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | // Register resource alias. Normally done in SyncComponents.manifest. |
michael@0 | 54 | function addResourceAlias() { |
michael@0 | 55 | Cu.import("resource://gre/modules/Services.jsm"); |
michael@0 | 56 | const resProt = Services.io.getProtocolHandler("resource") |
michael@0 | 57 | .QueryInterface(Ci.nsIResProtocolHandler); |
michael@0 | 58 | let uri = Services.io.newURI("resource://gre/modules/services-crypto/", |
michael@0 | 59 | null, null); |
michael@0 | 60 | resProt.setSubstitution("services-crypto", uri); |
michael@0 | 61 | } |
michael@0 | 62 | addResourceAlias(); |
michael@0 | 63 | |
michael@0 | 64 | /** |
michael@0 | 65 | * Print some debug message to the console. All arguments will be printed, |
michael@0 | 66 | * separated by spaces. |
michael@0 | 67 | * |
michael@0 | 68 | * @param [arg0, arg1, arg2, ...] |
michael@0 | 69 | * Any number of arguments to print out |
michael@0 | 70 | * @usage _("Hello World") -> prints "Hello World" |
michael@0 | 71 | * @usage _(1, 2, 3) -> prints "1 2 3" |
michael@0 | 72 | */ |
michael@0 | 73 | let _ = function(some, debug, text, to) print(Array.slice(arguments).join(" ")); |