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 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
4 * You can obtain one at http://mozilla.org/MPL/2.0/. */
5 'use strict';
7 const kInterfaceName = 'wifi';
8 const kOtherInterfaceName = 'ril';
10 var server;
11 var step = 0;
12 var loginFinished = false;
14 function xhr_handler(metadata, response) {
15 response.setStatusLine(metadata.httpVersion, 200, 'OK');
16 response.setHeader('Cache-Control', 'no-cache', false);
17 response.setHeader('Content-Type', 'text/plain', false);
18 if (loginFinished) {
19 response.write('true');
20 } else {
21 response.write('false');
22 }
23 }
25 function fakeUIResponse() {
26 Services.obs.addObserver(function observe(subject, topic, data) {
27 if (topic === 'captive-portal-login') {
28 let xhr = Cc['@mozilla.org/xmlextras/xmlhttprequest;1']
29 .createInstance(Ci.nsIXMLHttpRequest);
30 xhr.open('GET', gServerURL + kCanonicalSitePath, true);
31 xhr.send();
32 loginFinished = true;
33 do_check_eq(++step, 3);
34 }
35 }, 'captive-portal-login', false);
36 }
38 function test_multiple_requests_abort() {
39 do_test_pending();
41 let callback = {
42 QueryInterface: XPCOMUtils.generateQI([Ci.nsICaptivePortalCallback]),
43 prepare: function prepare() {
44 do_check_eq(++step, 1);
45 gCaptivePortalDetector.finishPreparation(kInterfaceName);
46 },
47 complete: function complete(success) {
48 do_throw('should not execute |complete| callback for ' + kInterfaceName);
49 },
50 };
52 let otherCallback = {
53 QueryInterface: XPCOMUtils.generateQI([Ci.nsICaptivePortalCallback]),
54 prepare: function prepare() {
55 do_check_eq(++step, 2);
56 gCaptivePortalDetector.finishPreparation(kOtherInterfaceName);
57 },
58 complete: function complete(success) {
59 do_check_eq(++step, 4);
60 do_check_true(success);
61 gServer.stop(do_test_finished);
62 }
63 };
65 gCaptivePortalDetector.checkCaptivePortal(kInterfaceName, callback);
66 gCaptivePortalDetector.checkCaptivePortal(kOtherInterfaceName, otherCallback);
67 gCaptivePortalDetector.abort(kInterfaceName);
68 }
70 function run_test() {
71 run_captivedetect_test(xhr_handler, fakeUIResponse, test_multiple_requests_abort);
72 }