toolkit/identity/tests/unit/test_identity_utils.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1
michael@0 2 "use strict";
michael@0 3
michael@0 4 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
michael@0 5 Cu.import('resource://gre/modules/Services.jsm');
michael@0 6 Cu.import('resource://gre/modules/identity/IdentityUtils.jsm');
michael@0 7
michael@0 8 function test_check_deprecated() {
michael@0 9 let options = {
michael@0 10 id: 123,
michael@0 11 loggedInEmail: "jed@foo.com",
michael@0 12 pies: 42
michael@0 13 };
michael@0 14
michael@0 15 do_check_true(checkDeprecated(options, "loggedInEmail"));
michael@0 16 do_check_false(checkDeprecated(options, "flans"));
michael@0 17
michael@0 18 run_next_test();
michael@0 19 }
michael@0 20
michael@0 21 function test_check_renamed() {
michael@0 22 let options = {
michael@0 23 id: 123,
michael@0 24 loggedInEmail: "jed@foo.com",
michael@0 25 pies: 42
michael@0 26 };
michael@0 27
michael@0 28 checkRenamed(options, "loggedInEmail", "loggedInUser");
michael@0 29
michael@0 30 // It moves loggedInEmail to loggedInUser
michael@0 31 do_check_false(!!options.loggedInEmail);
michael@0 32 do_check_eq(options.loggedInUser, "jed@foo.com");
michael@0 33
michael@0 34 run_next_test();
michael@0 35 }
michael@0 36
michael@0 37 let TESTS = [
michael@0 38 test_check_deprecated,
michael@0 39 test_check_renamed
michael@0 40 ];
michael@0 41
michael@0 42 TESTS.forEach(add_test);
michael@0 43
michael@0 44 function run_test() {
michael@0 45 run_next_test();
michael@0 46 }

mercurial