diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /toolkit/identity/tests/unit/test_store.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'toolkit/identity/tests/unit/test_store.js')
-rw-r--r-- | toolkit/identity/tests/unit/test_store.js | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/toolkit/identity/tests/unit/test_store.js b/toolkit/identity/tests/unit/test_store.js new file mode 100644 index 000000000..1cd9cc4dd --- /dev/null +++ b/toolkit/identity/tests/unit/test_store.js @@ -0,0 +1,64 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +XPCOMUtils.defineLazyModuleGetter(this, "IDService", + "resource://gre/modules/identity/Identity.jsm", + "IdentityService"); + +function test_id_store() { + // XXX - this is ugly, peaking in like this into IDService + // probably should instantiate our own. + var store = get_idstore(); + + // try adding an identity + store.addIdentity(TEST_USER, TEST_PRIVKEY, TEST_CERT); + do_check_neq(store.getIdentities()[TEST_USER], null); + do_check_eq(store.getIdentities()[TEST_USER].cert, TEST_CERT); + + // does fetch identity work? + do_check_neq(store.fetchIdentity(TEST_USER), null); + do_check_eq(store.fetchIdentity(TEST_USER).cert, TEST_CERT); + + // clear the cert should keep the identity but not the cert + store.clearCert(TEST_USER); + do_check_neq(store.getIdentities()[TEST_USER], null); + do_check_null(store.getIdentities()[TEST_USER].cert); + + // remove it should remove everything + store.removeIdentity(TEST_USER); + do_check_eq(store.getIdentities()[TEST_USER], undefined); + + // act like we're logged in to TEST_URL + store.setLoginState(TEST_URL, true, TEST_USER); + do_check_neq(store.getLoginState(TEST_URL), null); + do_check_true(store.getLoginState(TEST_URL).isLoggedIn); + do_check_eq(store.getLoginState(TEST_URL).email, TEST_USER); + + // log out + store.setLoginState(TEST_URL, false, TEST_USER); + do_check_neq(store.getLoginState(TEST_URL), null); + do_check_false(store.getLoginState(TEST_URL).isLoggedIn); + + // email is still set + do_check_eq(store.getLoginState(TEST_URL).email, TEST_USER); + + // not logged into other site + do_check_null(store.getLoginState(TEST_URL2)); + + // clear login state + store.clearLoginState(TEST_URL); + do_check_null(store.getLoginState(TEST_URL)); + do_check_null(store.getLoginState(TEST_URL2)); + + run_next_test(); +} + +var TESTS = [test_id_store, ]; + +TESTS.forEach(add_test); + +function run_test() { + run_next_test(); +} |