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/service.js"); |
michael@0 | 5 | Cu.import("resource://services-sync/util.js"); |
michael@0 | 6 | Cu.import("resource://testing-common/services/sync/utils.js"); |
michael@0 | 7 | |
michael@0 | 8 | function run_test() { |
michael@0 | 9 | do_test_pending(); |
michael@0 | 10 | ensureLegacyIdentityManager(); |
michael@0 | 11 | let server = httpd_setup({ |
michael@0 | 12 | "/user/1.0/johndoe": httpd_handler(200, "OK", "1"), |
michael@0 | 13 | "/user/1.0/janedoe": httpd_handler(200, "OK", "0"), |
michael@0 | 14 | // john@doe.com |
michael@0 | 15 | "/user/1.0/7wohs32cngzuqt466q3ge7indszva4of": httpd_handler(200, "OK", "0"), |
michael@0 | 16 | // jane@doe.com |
michael@0 | 17 | "/user/1.0/vuuf3eqgloxpxmzph27f5a6ve7gzlrms": httpd_handler(200, "OK", "1") |
michael@0 | 18 | }); |
michael@0 | 19 | try { |
michael@0 | 20 | Service.serverURL = server.baseURI; |
michael@0 | 21 | |
michael@0 | 22 | _("A 404 will be recorded as 'generic-server-error'"); |
michael@0 | 23 | do_check_eq(Service.checkAccount("jimdoe"), "generic-server-error"); |
michael@0 | 24 | |
michael@0 | 25 | _("Account that's available."); |
michael@0 | 26 | do_check_eq(Service.checkAccount("john@doe.com"), "available"); |
michael@0 | 27 | |
michael@0 | 28 | _("Account that's not available."); |
michael@0 | 29 | do_check_eq(Service.checkAccount("jane@doe.com"), "notAvailable"); |
michael@0 | 30 | |
michael@0 | 31 | _("Username fallback: Account that's not available."); |
michael@0 | 32 | do_check_eq(Service.checkAccount("johndoe"), "notAvailable"); |
michael@0 | 33 | |
michael@0 | 34 | _("Username fallback: Account that's available."); |
michael@0 | 35 | do_check_eq(Service.checkAccount("janedoe"), "available"); |
michael@0 | 36 | |
michael@0 | 37 | } finally { |
michael@0 | 38 | Svc.Prefs.resetBranch(""); |
michael@0 | 39 | server.stop(do_test_finished); |
michael@0 | 40 | } |
michael@0 | 41 | } |