toolkit/components/startup/tests/unit/head_startup.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/startup/tests/unit/head_startup.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,57 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +const XULRUNTIME_CONTRACTID = "@mozilla.org/xre/runtime;1";
     1.8 +const XULRUNTIME_CID = Components.ID("7685dac8-3637-4660-a544-928c5ec0e714}");
     1.9 +
    1.10 +Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
    1.11 +
    1.12 +let gAppInfo = null;
    1.13 +
    1.14 +function createAppInfo(id, name, version, platformVersion) {
    1.15 +  gAppInfo = {
    1.16 +    // nsIXULAppInfo
    1.17 +    vendor: "Mozilla",
    1.18 +    name: name,
    1.19 +    ID: id,
    1.20 +    version: version,
    1.21 +    appBuildID: "2007010101",
    1.22 +    platformVersion: platformVersion ? platformVersion : "1.0",
    1.23 +    platformBuildID: "2007010101",
    1.24 +
    1.25 +    // nsIXULRuntime
    1.26 +    inSafeMode: false,
    1.27 +    logConsoleErrors: true,
    1.28 +    OS: "XPCShell",
    1.29 +    replacedLockTime: 0,
    1.30 +    XPCOMABI: "noarch-spidermonkey",
    1.31 +    invalidateCachesOnRestart: function invalidateCachesOnRestart() {
    1.32 +      // Do nothing
    1.33 +    },
    1.34 +
    1.35 +    // nsICrashReporter
    1.36 +    annotations: {
    1.37 +    },
    1.38 +
    1.39 +    annotateCrashReport: function(key, data) {
    1.40 +      this.annotations[key] = data;
    1.41 +    },
    1.42 +
    1.43 +    QueryInterface: XPCOMUtils.generateQI([Ci.nsIXULAppInfo,
    1.44 +                                           Ci.nsIXULRuntime,
    1.45 +                                           Ci.nsICrashReporter,
    1.46 +                                           Ci.nsISupports])
    1.47 +  };
    1.48 +
    1.49 +  let XULAppInfoFactory = {
    1.50 +    createInstance: function (outer, iid) {
    1.51 +      if (outer != null)
    1.52 +        throw Components.results.NS_ERROR_NO_AGGREGATION;
    1.53 +      return gAppInfo.QueryInterface(iid);
    1.54 +    }
    1.55 +  };
    1.56 +  let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
    1.57 +  registrar.registerFactory(XULRUNTIME_CID, "XULRuntime",
    1.58 +                            XULRUNTIME_CONTRACTID, XULAppInfoFactory);
    1.59 +
    1.60 +}

mercurial