toolkit/components/autocomplete/tests/unit/test_330578.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 /* vim:set ts=2 sw=2 sts=2 et: */
     3 /* This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 var gResultListener = {
     8   _lastResult: null,
     9   _lastValue: "",
    10   _lastRemoveFromDb: false,
    12   onValueRemoved: function(aResult, aValue, aRemoveFromDb) {
    13     this._lastResult = aResult;
    14     this._lastValue = aValue;
    15     this._lastRemoveFromDb = aRemoveFromDb;
    16   }
    17 };
    20 // main
    21 function run_test() {
    22   var result = Cc["@mozilla.org/autocomplete/simple-result;1"].
    23                createInstance(Ci.nsIAutoCompleteSimpleResult);
    24   result.appendMatch("a", "");
    25   result.appendMatch("b", "");
    26   result.appendMatch("c", "");
    27   result.setListener(gResultListener);
    28   do_check_eq(result.matchCount, 3);
    29   result.removeValueAt(0, true);
    30   do_check_eq(result.matchCount, 2);
    31   do_check_eq(gResultListener._lastResult, result);
    32   do_check_eq(gResultListener._lastValue, "a");
    33   do_check_eq(gResultListener._lastRemoveFromDb, true);
    35   result.removeValueAt(0, false);
    36   do_check_eq(result.matchCount, 1);
    37   do_check_eq(gResultListener._lastValue, "b");
    38   do_check_eq(gResultListener._lastRemoveFromDb, false);
    40   // check that we don't get notified if the listener is unset
    41   result.setListener(null);
    42   result.removeValueAt(0, true); // "c"
    43   do_check_eq(result.matchCount, 0);
    44   do_check_eq(gResultListener._lastValue, "b");
    45 }

mercurial