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';
9 var server;
10 var step = 0;
12 function xhr_handler(metadata, response) {
13 response.setStatusLine(metadata.httpVersion, 200, 'OK');
14 response.setHeader('Cache-Control', 'no-cache', false);
15 response.setHeader('Content-Type', 'text/plain', false);
16 response.write('false');
17 }
19 function fakeUIResponse() {
20 Services.obs.addObserver(function observe(subject, topic, data) {
21 if (topic === 'captive-portal-login') {
22 let xhr = Cc['@mozilla.org/xmlextras/xmlhttprequest;1']
23 .createInstance(Ci.nsIXMLHttpRequest);
24 xhr.open('GET', gServerURL + kCanonicalSitePath, true);
25 xhr.send();
26 do_check_eq(++step, 2);
27 let details = JSON.parse(data);
28 gCaptivePortalDetector.cancelLogin(details.id);
29 }
30 }, 'captive-portal-login', false);
31 }
33 function test_cancel() {
34 do_test_pending();
36 let callback = {
37 QueryInterface: XPCOMUtils.generateQI([Ci.nsICaptivePortalCallback]),
38 prepare: function prepare() {
39 do_check_eq(++step, 1);
40 gCaptivePortalDetector.finishPreparation(kInterfaceName);
41 },
42 complete: function complete(success) {
43 do_check_eq(++step, 3);
44 do_check_false(success);
45 gServer.stop(do_test_finished);
46 },
47 };
49 gCaptivePortalDetector.checkCaptivePortal(kInterfaceName, callback);
50 }
52 function run_test() {
53 run_captivedetect_test(xhr_handler, fakeUIResponse, test_cancel);
54 }