Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | Cu.import("resource://services-sync/constants.js"); |
michael@0 | 5 | Cu.import("resource://services-sync/service.js"); |
michael@0 | 6 | Cu.import("resource://services-sync/util.js"); |
michael@0 | 7 | Cu.import("resource://testing-common/services/sync/utils.js"); |
michael@0 | 8 | |
michael@0 | 9 | function run_test() { |
michael@0 | 10 | try { |
michael@0 | 11 | // Ensure we have a blank slate to start. |
michael@0 | 12 | ensureLegacyIdentityManager(); |
michael@0 | 13 | Services.logins.removeAllLogins(); |
michael@0 | 14 | |
michael@0 | 15 | setBasicCredentials("johndoe", "ilovejane", "abbbbbcccccdddddeeeeefffff"); |
michael@0 | 16 | |
michael@0 | 17 | _("Confirm initial environment is empty."); |
michael@0 | 18 | let logins = Services.logins.findLogins({}, PWDMGR_HOST, null, |
michael@0 | 19 | PWDMGR_PASSWORD_REALM); |
michael@0 | 20 | do_check_eq(logins.length, 0); |
michael@0 | 21 | logins = Services.logins.findLogins({}, PWDMGR_HOST, null, |
michael@0 | 22 | PWDMGR_PASSPHRASE_REALM); |
michael@0 | 23 | do_check_eq(logins.length, 0); |
michael@0 | 24 | |
michael@0 | 25 | _("Persist logins to the login service"); |
michael@0 | 26 | Service.persistLogin(); |
michael@0 | 27 | |
michael@0 | 28 | _("The password has been persisted in the login service."); |
michael@0 | 29 | logins = Services.logins.findLogins({}, PWDMGR_HOST, null, |
michael@0 | 30 | PWDMGR_PASSWORD_REALM); |
michael@0 | 31 | do_check_eq(logins.length, 1); |
michael@0 | 32 | do_check_eq(logins[0].username, "johndoe"); |
michael@0 | 33 | do_check_eq(logins[0].password, "ilovejane"); |
michael@0 | 34 | |
michael@0 | 35 | _("The passphrase has been persisted in the login service."); |
michael@0 | 36 | logins = Services.logins.findLogins({}, PWDMGR_HOST, null, |
michael@0 | 37 | PWDMGR_PASSPHRASE_REALM); |
michael@0 | 38 | do_check_eq(logins.length, 1); |
michael@0 | 39 | do_check_eq(logins[0].username, "johndoe"); |
michael@0 | 40 | do_check_eq(logins[0].password, "abbbbbcccccdddddeeeeefffff"); |
michael@0 | 41 | |
michael@0 | 42 | } finally { |
michael@0 | 43 | Svc.Prefs.resetBranch(""); |
michael@0 | 44 | Services.logins.removeAllLogins(); |
michael@0 | 45 | } |
michael@0 | 46 | } |