summaryrefslogtreecommitdiffstats
path: root/services/sync/tests/unit/head_appinfo.js
blob: 51bb1349a8f488b67d8701de71c66727cf9e1ea8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

/* import-globals-from ../../../common/tests/unit/head_helpers.js */

var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
var { XPCOMUtils } = ChromeUtils.import(
  "resource://gre/modules/XPCOMUtils.jsm"
);

// Required to avoid failures.
do_get_profile();

// Init FormHistoryStartup and pretend we opened a profile.
var fhs = Cc["@mozilla.org/satchel/form-history-startup;1"].getService(
  Ci.nsIObserver
);
fhs.observe(null, "profile-after-change", null);

// An app is going to have some prefs set which xpcshell tests don't.
Services.prefs.setCharPref(
  "identity.sync.tokenserver.uri",
  "http://token-server"
);

// Make sure to provide the right OS so crypto loads the right binaries
function getOS() {
  switch (mozinfo.os) {
    case "win":
      return "WINNT";
    case "mac":
      return "Darwin";
    default:
      return "Linux";
  }
}

ChromeUtils.import("resource://testing-common/AppInfo.jsm", this);
updateAppInfo({
  name: "XPCShell",
  ID: "xpcshell@tests.mozilla.org",
  version: "1",
  platformVersion: "",
  OS: getOS(),
});

// Register resource aliases. Normally done in SyncComponents.manifest.
function addResourceAlias() {
  const resProt = Services.io
    .getProtocolHandler("resource")
    .QueryInterface(Ci.nsIResProtocolHandler);
  for (let s of ["common", "sync", "crypto"]) {
    let uri = Services.io.newURI("resource://gre/modules/services-" + s + "/");
    resProt.setSubstitution("services-" + s, uri);
  }
}
addResourceAlias();