Sat, 03 Jan 2015 20:18:00 +0100
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 | /* 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://gre/modules/XPCOMUtils.jsm"); |
michael@0 | 5 | Cu.import("resource://gre/modules/Services.jsm"); |
michael@0 | 6 | |
michael@0 | 7 | XPCOMUtils.defineLazyModuleGetter(this, "IDService", |
michael@0 | 8 | "resource://gre/modules/identity/Identity.jsm", |
michael@0 | 9 | "IdentityService"); |
michael@0 | 10 | |
michael@0 | 11 | const WELL_KNOWN_PATH = "/.well-known/browserid"; |
michael@0 | 12 | |
michael@0 | 13 | let SERVER_PORT = 8080; |
michael@0 | 14 | |
michael@0 | 15 | // valid IDP |
michael@0 | 16 | function test_well_known_1() { |
michael@0 | 17 | do_test_pending(); |
michael@0 | 18 | |
michael@0 | 19 | let server = new HttpServer(); |
michael@0 | 20 | server.registerFile(WELL_KNOWN_PATH, do_get_file("data/idp_1" + WELL_KNOWN_PATH)); |
michael@0 | 21 | server.start(SERVER_PORT); |
michael@0 | 22 | let hostPort = "localhost:" + SERVER_PORT; |
michael@0 | 23 | |
michael@0 | 24 | function check_well_known(aErr, aCallbackObj) { |
michael@0 | 25 | do_check_null(aErr); |
michael@0 | 26 | do_check_eq(aCallbackObj.domain, hostPort); |
michael@0 | 27 | let idpParams = aCallbackObj.idpParams; |
michael@0 | 28 | do_check_eq(idpParams['public-key'].algorithm, "RS"); |
michael@0 | 29 | do_check_eq(idpParams.authentication, "/browserid/sign_in.html"); |
michael@0 | 30 | do_check_eq(idpParams.provisioning, "/browserid/provision.html"); |
michael@0 | 31 | |
michael@0 | 32 | do_test_finished(); |
michael@0 | 33 | server.stop(run_next_test); |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | IDService._fetchWellKnownFile(hostPort, check_well_known, "http"); |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | // valid domain, non-exixtent browserid file |
michael@0 | 40 | function test_well_known_404() { |
michael@0 | 41 | do_test_pending(); |
michael@0 | 42 | |
michael@0 | 43 | let server = new HttpServer(); |
michael@0 | 44 | // Don't register the well-known file |
michael@0 | 45 | // Change ports to avoid HTTP caching |
michael@0 | 46 | SERVER_PORT++; |
michael@0 | 47 | server.start(SERVER_PORT); |
michael@0 | 48 | |
michael@0 | 49 | let hostPort = "localhost:" + SERVER_PORT; |
michael@0 | 50 | |
michael@0 | 51 | function check_well_known_404(aErr, aCallbackObj) { |
michael@0 | 52 | do_check_eq("Error", aErr); |
michael@0 | 53 | do_check_eq(undefined, aCallbackObj); |
michael@0 | 54 | do_test_finished(); |
michael@0 | 55 | server.stop(run_next_test); |
michael@0 | 56 | } |
michael@0 | 57 | |
michael@0 | 58 | IDService._fetchWellKnownFile(hostPort, check_well_known_404, "http"); |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | // valid domain, invalid browserid file (no "provisioning" member) |
michael@0 | 62 | function test_well_known_invalid_1() { |
michael@0 | 63 | do_test_pending(); |
michael@0 | 64 | |
michael@0 | 65 | let server = new HttpServer(); |
michael@0 | 66 | server.registerFile(WELL_KNOWN_PATH, do_get_file("data/idp_invalid_1" + WELL_KNOWN_PATH)); |
michael@0 | 67 | // Change ports to avoid HTTP caching |
michael@0 | 68 | SERVER_PORT++; |
michael@0 | 69 | server.start(SERVER_PORT); |
michael@0 | 70 | |
michael@0 | 71 | let hostPort = "localhost:" + SERVER_PORT; |
michael@0 | 72 | |
michael@0 | 73 | function check_well_known_invalid_1(aErr, aCallbackObj) { |
michael@0 | 74 | // check for an error message |
michael@0 | 75 | do_check_true(aErr && aErr.length > 0); |
michael@0 | 76 | do_check_eq(undefined, aCallbackObj); |
michael@0 | 77 | do_test_finished(); |
michael@0 | 78 | server.stop(run_next_test); |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | IDService._fetchWellKnownFile(hostPort, check_well_known_invalid_1, "http"); |
michael@0 | 82 | } |
michael@0 | 83 | |
michael@0 | 84 | let TESTS = [test_well_known_1, test_well_known_404, test_well_known_invalid_1]; |
michael@0 | 85 | |
michael@0 | 86 | TESTS.forEach(add_test); |
michael@0 | 87 | |
michael@0 | 88 | function run_test() { |
michael@0 | 89 | run_next_test(); |
michael@0 | 90 | } |