1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/telemetry/tests/unit/head.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,52 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 + 1.8 +// copied from toolkit/mozapps/extensions/test/xpcshell/head_addons.js 1.9 +const XULAPPINFO_CONTRACTID = "@mozilla.org/xre/app-info;1"; 1.10 +const XULAPPINFO_CID = Components.ID("{c763b610-9d49-455a-bbd2-ede71682a1ac}"); 1.11 + 1.12 +function createAppInfo(id, name, version, platformVersion) { 1.13 + gAppInfo = { 1.14 + // nsIXULAppInfo 1.15 + vendor: "Mozilla", 1.16 + name: name, 1.17 + ID: id, 1.18 + version: version, 1.19 + appBuildID: "2007010101", 1.20 + platformVersion: platformVersion, 1.21 + platformBuildID: "2007010101", 1.22 + 1.23 + // nsIXULRuntime 1.24 + inSafeMode: false, 1.25 + logConsoleErrors: true, 1.26 + OS: "XPCShell", 1.27 + XPCOMABI: "noarch-spidermonkey", 1.28 + invalidateCachesOnRestart: function invalidateCachesOnRestart() { 1.29 + // Do nothing 1.30 + }, 1.31 + 1.32 + // nsICrashReporter 1.33 + annotations: {}, 1.34 + 1.35 + annotateCrashReport: function(key, data) { 1.36 + this.annotations[key] = data; 1.37 + }, 1.38 + 1.39 + QueryInterface: XPCOMUtils.generateQI([Ci.nsIXULAppInfo, 1.40 + Ci.nsIXULRuntime, 1.41 + Ci.nsICrashReporter, 1.42 + Ci.nsISupports]) 1.43 + }; 1.44 + 1.45 + var XULAppInfoFactory = { 1.46 + createInstance: function (outer, iid) { 1.47 + if (outer != null) 1.48 + throw Components.results.NS_ERROR_NO_AGGREGATION; 1.49 + return gAppInfo.QueryInterface(iid); 1.50 + } 1.51 + }; 1.52 + var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); 1.53 + registrar.registerFactory(XULAPPINFO_CID, "XULAppInfo", 1.54 + XULAPPINFO_CONTRACTID, XULAppInfoFactory); 1.55 +}