summaryrefslogtreecommitdiffstats
path: root/services/sync/tests/unit/fake_login_manager.js
blob: 6f3148c45a7d02cc8751e3a914d966a852828d0e (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
Cu.import("resource://services-sync/util.js");

// ----------------------------------------
// Fake Sample Data
// ----------------------------------------

var fakeSampleLogins = [
  // Fake nsILoginInfo object.
  {hostname: "www.boogle.com",
   formSubmitURL: "http://www.boogle.com/search",
   httpRealm: "",
   username: "",
   password: "",
   usernameField: "test_person",
   passwordField: "test_password"}
];

// ----------------------------------------
// Fake Login Manager
// ----------------------------------------

function FakeLoginManager(fakeLogins) {
  this.fakeLogins = fakeLogins;

  let self = this;

  // Use a fake nsILoginManager object.
  delete Services.logins;
  Services.logins = {
      removeAllLogins: function() { self.fakeLogins = []; },
      getAllLogins: function() { return self.fakeLogins; },
      addLogin: function(login) {
        getTestLogger().info("nsILoginManager.addLogin() called " +
                             "with hostname '" + login.hostname + "'.");
        self.fakeLogins.push(login);
      }
  };
}