toolkit/components/captivedetect/test/unit/head_setprefs.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 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 4 * You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5 'use strict';
michael@0 6
michael@0 7 const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
michael@0 8
michael@0 9 Cu.import('resource://gre/modules/XPCOMUtils.jsm');
michael@0 10 Cu.import('resource://gre/modules/Services.jsm');
michael@0 11 Cu.import('resource://testing-common/httpd.js');
michael@0 12
michael@0 13 XPCOMUtils.defineLazyServiceGetter(this, 'gCaptivePortalDetector',
michael@0 14 '@mozilla.org/toolkit/captive-detector;1',
michael@0 15 'nsICaptivePortalDetector');
michael@0 16
michael@0 17 const kCanonicalSitePath = '/canonicalSite.html';
michael@0 18 const kCanonicalSiteContent = 'true';
michael@0 19 const kPrefsCanonicalURL = 'captivedetect.canonicalURL';
michael@0 20 const kPrefsCanonicalContent = 'captivedetect.canonicalContent';
michael@0 21 const kPrefsMaxWaitingTime = 'captivedetect.maxWaitingTime';
michael@0 22 const kPrefsPollingTime = 'captivedetect.pollingTime';
michael@0 23
michael@0 24 var gServer;
michael@0 25 var gServerURL;
michael@0 26
michael@0 27 function setupPrefs() {
michael@0 28 let prefs = Components.classes["@mozilla.org/preferences-service;1"]
michael@0 29 .getService(Components.interfaces.nsIPrefService)
michael@0 30 .QueryInterface(Components.interfaces.nsIPrefBranch);
michael@0 31 prefs.setCharPref(kPrefsCanonicalURL, gServerURL + kCanonicalSitePath);
michael@0 32 prefs.setCharPref(kPrefsCanonicalContent, kCanonicalSiteContent);
michael@0 33 prefs.setIntPref(kPrefsMaxWaitingTime, 0);
michael@0 34 prefs.setIntPref(kPrefsPollingTime, 1);
michael@0 35 }
michael@0 36
michael@0 37 function run_captivedetect_test(xhr_handler, fakeUIResponse, testfun)
michael@0 38 {
michael@0 39 gServer = new HttpServer();
michael@0 40 gServer.registerPathHandler(kCanonicalSitePath, xhr_handler);
michael@0 41 gServer.start(-1);
michael@0 42 gServerURL = 'http://localhost:' + gServer.identity.primaryPort;
michael@0 43
michael@0 44 setupPrefs();
michael@0 45
michael@0 46 fakeUIResponse();
michael@0 47
michael@0 48 testfun();
michael@0 49 }

mercurial