Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | |
michael@0 | 5 | // copied from toolkit/mozapps/extensions/test/xpcshell/head_addons.js |
michael@0 | 6 | const XULAPPINFO_CONTRACTID = "@mozilla.org/xre/app-info;1"; |
michael@0 | 7 | const XULAPPINFO_CID = Components.ID("{c763b610-9d49-455a-bbd2-ede71682a1ac}"); |
michael@0 | 8 | |
michael@0 | 9 | function createAppInfo(id, name, version, platformVersion) { |
michael@0 | 10 | gAppInfo = { |
michael@0 | 11 | // nsIXULAppInfo |
michael@0 | 12 | vendor: "Mozilla", |
michael@0 | 13 | name: name, |
michael@0 | 14 | ID: id, |
michael@0 | 15 | version: version, |
michael@0 | 16 | appBuildID: "2007010101", |
michael@0 | 17 | platformVersion: platformVersion, |
michael@0 | 18 | platformBuildID: "2007010101", |
michael@0 | 19 | |
michael@0 | 20 | // nsIXULRuntime |
michael@0 | 21 | inSafeMode: false, |
michael@0 | 22 | logConsoleErrors: true, |
michael@0 | 23 | OS: "XPCShell", |
michael@0 | 24 | XPCOMABI: "noarch-spidermonkey", |
michael@0 | 25 | invalidateCachesOnRestart: function invalidateCachesOnRestart() { |
michael@0 | 26 | // Do nothing |
michael@0 | 27 | }, |
michael@0 | 28 | |
michael@0 | 29 | // nsICrashReporter |
michael@0 | 30 | annotations: {}, |
michael@0 | 31 | |
michael@0 | 32 | annotateCrashReport: function(key, data) { |
michael@0 | 33 | this.annotations[key] = data; |
michael@0 | 34 | }, |
michael@0 | 35 | |
michael@0 | 36 | QueryInterface: XPCOMUtils.generateQI([Ci.nsIXULAppInfo, |
michael@0 | 37 | Ci.nsIXULRuntime, |
michael@0 | 38 | Ci.nsICrashReporter, |
michael@0 | 39 | Ci.nsISupports]) |
michael@0 | 40 | }; |
michael@0 | 41 | |
michael@0 | 42 | var XULAppInfoFactory = { |
michael@0 | 43 | createInstance: function (outer, iid) { |
michael@0 | 44 | if (outer != null) |
michael@0 | 45 | throw Components.results.NS_ERROR_NO_AGGREGATION; |
michael@0 | 46 | return gAppInfo.QueryInterface(iid); |
michael@0 | 47 | } |
michael@0 | 48 | }; |
michael@0 | 49 | var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); |
michael@0 | 50 | registrar.registerFactory(XULAPPINFO_CID, "XULAppInfo", |
michael@0 | 51 | XULAPPINFO_CONTRACTID, XULAppInfoFactory); |
michael@0 | 52 | } |