toolkit/components/captivedetect/test/unit/test_abort.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.

     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;
    11 var loginFinished = false;
    13 function xhr_handler(metadata, response) {
    14   response.setStatusLine(metadata.httpVersion, 200, 'OK');
    15   response.setHeader('Cache-Control', 'no-cache', false);
    16   response.setHeader('Content-Type', 'text/plain', false);
    17   if (loginFinished) {
    18     response.write('true');
    19   } else {
    20     response.write('false');
    21   }
    22 }
    24 function fakeUIResponse() {
    25   Services.obs.addObserver(function observe(subject, topic, data) {
    26     if (topic === 'captive-portal-login') {
    27       do_throw('should not receive captive-portal-login event');
    28     }
    29   }, 'captive-portal-login', false);
    30 }
    32 function test_abort() {
    33   do_test_pending();
    35   let callback = {
    36     QueryInterface: XPCOMUtils.generateQI([Ci.nsICaptivePortalCallback]),
    37     prepare: function prepare() {
    38       do_check_eq(++step, 1);
    39       gCaptivePortalDetector.finishPreparation(kInterfaceName);
    40     },
    41     complete: function complete(success) {
    42       do_throw('should not execute |complete| callback');
    43     },
    44   };
    46   gCaptivePortalDetector.checkCaptivePortal(kInterfaceName, callback);
    47   gCaptivePortalDetector.abort(kInterfaceName);
    48   gServer.stop(do_test_finished);
    49 }
    51 function run_test() {
    52   run_captivedetect_test(xhr_handler, fakeUIResponse, test_abort);
    53 }

mercurial