Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | const Cc = Components.classes; |
michael@0 | 5 | const Ci = Components.interfaces; |
michael@0 | 6 | const Cr = Components.results; |
michael@0 | 7 | |
michael@0 | 8 | var XULAppInfo = { |
michael@0 | 9 | vendor: "Mozilla", |
michael@0 | 10 | name: "Url Formatter Test", |
michael@0 | 11 | ID: "urlformattertest@test.mozilla.org", |
michael@0 | 12 | version: "1", |
michael@0 | 13 | appBuildID: "2007122405", |
michael@0 | 14 | platformVersion: "2.0", |
michael@0 | 15 | platformBuildID: "2007122406", |
michael@0 | 16 | inSafeMode: false, |
michael@0 | 17 | logConsoleErrors: true, |
michael@0 | 18 | OS: "XPCShell", |
michael@0 | 19 | XPCOMABI: "noarch-spidermonkey", |
michael@0 | 20 | |
michael@0 | 21 | QueryInterface: function QueryInterface(iid) { |
michael@0 | 22 | if (iid.equals(Ci.nsIXULAppInfo) || |
michael@0 | 23 | iid.equals(Ci.nsIXULRuntime) || |
michael@0 | 24 | iid.equals(Ci.nsISupports)) |
michael@0 | 25 | return this; |
michael@0 | 26 | throw Cr.NS_ERROR_NO_INTERFACE; |
michael@0 | 27 | } |
michael@0 | 28 | }; |
michael@0 | 29 | |
michael@0 | 30 | var XULAppInfoFactory = { |
michael@0 | 31 | createInstance: function (outer, iid) { |
michael@0 | 32 | if (outer != null) |
michael@0 | 33 | throw Cr.NS_ERROR_NO_AGGREGATION; |
michael@0 | 34 | return XULAppInfo.QueryInterface(iid); |
michael@0 | 35 | } |
michael@0 | 36 | }; |
michael@0 | 37 | |
michael@0 | 38 | var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); |
michael@0 | 39 | registrar.registerFactory(Components.ID("{ecff8849-cee8-40a7-bd4a-3f4fdfeddb5c}"), |
michael@0 | 40 | "XULAppInfo", "@mozilla.org/xre/app-info;1", |
michael@0 | 41 | XULAppInfoFactory); |