mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-18 13:17:29 +09:00
import FIREFOX_52_6_0esr_RELEASE from mozilla-esr52 hg repo
This commit is contained in:
commit
dcd9973243
150858 changed files with 23884658 additions and 0 deletions
64
toolkit/identity/tests/unit/test_store.js
Normal file
64
toolkit/identity/tests/unit/test_store.js
Normal file
|
|
@ -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();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue