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.
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 /**
5 * By their nature, these tests duplicate some of the functionality of
6 * other tests for Identity, RelyingParty, and IdentityProvider.
7 *
8 * In particular, "identity-auth-complete" and
9 * "identity-login-state-changed" are tested in test_authentication.js
10 */
12 "use strict";
14 XPCOMUtils.defineLazyModuleGetter(this, "IDService",
15 "resource://gre/modules/identity/Identity.jsm",
16 "IdentityService");
18 function test_smoke() {
19 do_check_neq(IDService, null);
20 run_next_test();
21 }
23 function test_identity_request() {
24 // In response to navigator.id.request(), initiate a login with user
25 // interaction by notifying observers of 'identity-request'
27 do_test_pending();
29 IDService.reset();
31 let id = "landru@mockmyid.com";
32 setup_test_identity(id, TEST_CERT, function() {
33 // deliberately adding a trailing final slash on the domain
34 // to test path composition
35 let mockedDoc = mock_doc(null, "http://jed.gov/", function() {});
37 // by calling watch() we create an rp flow.
38 IDService.RP.watch(mockedDoc);
40 // register the request UX observer
41 makeObserver("identity-request", function (aSubject, aTopic, aData) {
42 do_check_eq(aTopic, "identity-request");
43 do_check_eq(aData, null);
45 // check that all the URLs are properly resolved
46 let subj = aSubject.wrappedJSObject;
47 do_check_eq(subj.privacyPolicy, "http://jed.gov/pp.html");
48 do_check_eq(subj.termsOfService, "http://jed.gov/tos.html");
50 do_test_finished();
51 run_next_test();
52 });
54 let requestOptions = {
55 privacyPolicy: "/pp.html",
56 termsOfService: "/tos.html"
57 };
58 IDService.RP.request(mockedDoc.id, requestOptions);
59 });
61 }
63 function test_identity_auth() {
64 // see test_authentication.js for "identity-auth-complete"
65 // and "identity-login-state-changed"
67 do_test_pending();
68 let _provId = "bogus";
70 // Simulate what would be returned by IDService._fetchWellKnownFile
71 // for a given domain.
72 let idpParams = {
73 domain: "myfavoriteflan.com",
74 idpParams: {
75 authentication: "/foo/authenticate.html",
76 provisioning: "/foo/provision.html"
77 }
78 };
80 // Create an RP flow
81 let mockedDoc = mock_doc(null, TEST_URL, function(action, params) {});
82 IDService.RP.watch(mockedDoc);
84 // The identity-auth notification is sent up to the UX from the
85 // _doAuthentication function. Be ready to receive it and call
86 // beginAuthentication
87 makeObserver("identity-auth", function (aSubject, aTopic, aData) {
88 do_check_neq(aSubject, null);
89 do_check_eq(aTopic, "identity-auth");
90 do_check_eq(aData, "https://myfavoriteflan.com/foo/authenticate.html");
92 do_check_eq(aSubject.wrappedJSObject.provId, _provId);
93 do_test_finished();
94 run_next_test();
95 });
97 // Even though our provisioning flow id is bogus, IdentityProvider
98 // won't look at it until farther along in the authentication
99 // process. So this test can pass with a fake provId.
100 IDService.IDP._doAuthentication(_provId, idpParams);
101 }
103 let TESTS = [
104 test_smoke,
105 test_identity_request,
106 test_identity_auth,
107 ];
110 TESTS.forEach(add_test);
112 function run_test() {
113 run_next_test();
114 }