1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/services/sync/tests/unit/fake_login_manager.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,38 @@ 1.4 +Cu.import("resource://services-sync/util.js"); 1.5 + 1.6 +// ---------------------------------------- 1.7 +// Fake Sample Data 1.8 +// ---------------------------------------- 1.9 + 1.10 +let fakeSampleLogins = [ 1.11 + // Fake nsILoginInfo object. 1.12 + {hostname: "www.boogle.com", 1.13 + formSubmitURL: "http://www.boogle.com/search", 1.14 + httpRealm: "", 1.15 + username: "", 1.16 + password: "", 1.17 + usernameField: "test_person", 1.18 + passwordField: "test_password"} 1.19 +]; 1.20 + 1.21 +// ---------------------------------------- 1.22 +// Fake Login Manager 1.23 +// ---------------------------------------- 1.24 + 1.25 +function FakeLoginManager(fakeLogins) { 1.26 + this.fakeLogins = fakeLogins; 1.27 + 1.28 + let self = this; 1.29 + 1.30 + // Use a fake nsILoginManager object. 1.31 + delete Services.logins; 1.32 + Services.logins = { 1.33 + removeAllLogins: function() { self.fakeLogins = []; }, 1.34 + getAllLogins: function() { return self.fakeLogins; }, 1.35 + addLogin: function(login) { 1.36 + getTestLogger().info("nsILoginManager.addLogin() called " + 1.37 + "with hostname '" + login.hostname + "'."); 1.38 + self.fakeLogins.push(login); 1.39 + } 1.40 + }; 1.41 +}