services/sync/tests/unit/fake_login_manager.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 Cu.import("resource://services-sync/util.js");
michael@0 2
michael@0 3 // ----------------------------------------
michael@0 4 // Fake Sample Data
michael@0 5 // ----------------------------------------
michael@0 6
michael@0 7 let fakeSampleLogins = [
michael@0 8 // Fake nsILoginInfo object.
michael@0 9 {hostname: "www.boogle.com",
michael@0 10 formSubmitURL: "http://www.boogle.com/search",
michael@0 11 httpRealm: "",
michael@0 12 username: "",
michael@0 13 password: "",
michael@0 14 usernameField: "test_person",
michael@0 15 passwordField: "test_password"}
michael@0 16 ];
michael@0 17
michael@0 18 // ----------------------------------------
michael@0 19 // Fake Login Manager
michael@0 20 // ----------------------------------------
michael@0 21
michael@0 22 function FakeLoginManager(fakeLogins) {
michael@0 23 this.fakeLogins = fakeLogins;
michael@0 24
michael@0 25 let self = this;
michael@0 26
michael@0 27 // Use a fake nsILoginManager object.
michael@0 28 delete Services.logins;
michael@0 29 Services.logins = {
michael@0 30 removeAllLogins: function() { self.fakeLogins = []; },
michael@0 31 getAllLogins: function() { return self.fakeLogins; },
michael@0 32 addLogin: function(login) {
michael@0 33 getTestLogger().info("nsILoginManager.addLogin() called " +
michael@0 34 "with hostname '" + login.hostname + "'.");
michael@0 35 self.fakeLogins.push(login);
michael@0 36 }
michael@0 37 };
michael@0 38 }

mercurial