1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/services/sync/tests/unit/head_appinfo.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,68 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +const {classes: Cc, interfaces: Ci, results: Cr, utils: Cu} = Components; 1.8 + 1.9 +let gSyncProfile; 1.10 + 1.11 +gSyncProfile = do_get_profile(); 1.12 + 1.13 +// Init FormHistoryStartup and pretend we opened a profile. 1.14 +let fhs = Cc["@mozilla.org/satchel/form-history-startup;1"] 1.15 + .getService(Ci.nsIObserver); 1.16 +fhs.observe(null, "profile-after-change", null); 1.17 + 1.18 + 1.19 +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); 1.20 + 1.21 +// Make sure to provide the right OS so crypto loads the right binaries 1.22 +let OS = "XPCShell"; 1.23 +if ("@mozilla.org/windows-registry-key;1" in Cc) 1.24 + OS = "WINNT"; 1.25 +else if ("nsILocalFileMac" in Ci) 1.26 + OS = "Darwin"; 1.27 +else 1.28 + OS = "Linux"; 1.29 + 1.30 +let XULAppInfo = { 1.31 + vendor: "Mozilla", 1.32 + name: "XPCShell", 1.33 + ID: "xpcshell@tests.mozilla.org", 1.34 + version: "1", 1.35 + appBuildID: "20100621", 1.36 + platformVersion: "", 1.37 + platformBuildID: "20100621", 1.38 + inSafeMode: false, 1.39 + logConsoleErrors: true, 1.40 + OS: OS, 1.41 + XPCOMABI: "noarch-spidermonkey", 1.42 + QueryInterface: XPCOMUtils.generateQI([Ci.nsIXULAppInfo, Ci.nsIXULRuntime]), 1.43 + invalidateCachesOnRestart: function invalidateCachesOnRestart() { } 1.44 +}; 1.45 + 1.46 +let XULAppInfoFactory = { 1.47 + createInstance: function (outer, iid) { 1.48 + if (outer != null) 1.49 + throw Cr.NS_ERROR_NO_AGGREGATION; 1.50 + return XULAppInfo.QueryInterface(iid); 1.51 + } 1.52 +}; 1.53 + 1.54 +let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); 1.55 +registrar.registerFactory(Components.ID("{fbfae60b-64a4-44ef-a911-08ceb70b9f31}"), 1.56 + "XULAppInfo", "@mozilla.org/xre/app-info;1", 1.57 + XULAppInfoFactory); 1.58 + 1.59 + 1.60 +// Register resource aliases. Normally done in SyncComponents.manifest. 1.61 +function addResourceAlias() { 1.62 + Cu.import("resource://gre/modules/Services.jsm"); 1.63 + const resProt = Services.io.getProtocolHandler("resource") 1.64 + .QueryInterface(Ci.nsIResProtocolHandler); 1.65 + for each (let s in ["common", "sync", "crypto"]) { 1.66 + let uri = Services.io.newURI("resource://gre/modules/services-" + s + "/", null, 1.67 + null); 1.68 + resProt.setSubstitution("services-" + s, uri); 1.69 + } 1.70 +} 1.71 +addResourceAlias();