head_appinfo.js (1581B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 /* import-globals-from ../../../common/tests/unit/head_helpers.js */ 5 6 var { XPCOMUtils } = ChromeUtils.importESModule( 7 "resource://gre/modules/XPCOMUtils.sys.mjs" 8 ); 9 10 // Required to avoid failures. 11 do_get_profile(); 12 13 // Init FormHistoryStartup and pretend we opened a profile. 14 var fhs = Cc["@mozilla.org/satchel/form-history-startup;1"].getService( 15 Ci.nsIObserver 16 ); 17 fhs.observe(null, "profile-after-change", null); 18 19 // An app is going to have some prefs set which xpcshell tests don't. 20 Services.prefs.setStringPref( 21 "identity.sync.tokenserver.uri", 22 "http://token-server" 23 ); 24 25 // Make sure to provide the right OS so crypto loads the right binaries 26 function getOS() { 27 switch (mozinfo.os) { 28 case "win": 29 return "WINNT"; 30 case "mac": 31 return "Darwin"; 32 default: 33 return "Linux"; 34 } 35 } 36 37 const { updateAppInfo } = ChromeUtils.importESModule( 38 "resource://testing-common/AppInfo.sys.mjs" 39 ); 40 updateAppInfo({ 41 name: "XPCShell", 42 ID: "xpcshell@tests.mozilla.org", 43 version: "1", 44 platformVersion: "", 45 OS: getOS(), 46 }); 47 48 // Register resource aliases. Normally done in SyncComponents.manifest. 49 function addResourceAlias() { 50 const resProt = Services.io 51 .getProtocolHandler("resource") 52 .QueryInterface(Ci.nsIResProtocolHandler); 53 for (let s of ["common", "sync", "crypto"]) { 54 let uri = Services.io.newURI("resource://gre/modules/services-" + s + "/"); 55 resProt.setSubstitution("services-" + s, uri); 56 } 57 } 58 addResourceAlias();