toolkit/components/places/tests/unit/test_415460.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 hs = Cc["@mozilla.org/browser/nav-history-service;1"].
     8          getService(Ci.nsINavHistoryService);
    10 /**
    11  * Checks to see that a search has exactly one result in the database.
    12  *
    13  * @param aTerms
    14  *        The terms to search for.
    15  * @returns true if the search returns one result, false otherwise.
    16  */
    17 function search_has_result(aTerms)
    18 {
    19   var options = hs.getNewQueryOptions();
    20   options.maxResults = 1;
    21   options.resultType = options.RESULTS_AS_URI;
    22   var query = hs.getNewQuery();
    23   query.searchTerms = aTerms;
    24   var result = hs.executeQuery(query, options);
    25   var root = result.root;
    26   root.containerOpen = true;
    27   var cc = root.childCount;
    28   root.containerOpen = false;
    29   return (cc == 1);
    30 }
    32 function run_test()
    33 {
    34   run_next_test();
    35 }
    37 add_task(function test_execute()
    38 {
    39   const SEARCH_TERM = "ユニコード";
    40   const TEST_URL = "http://example.com/" + SEARCH_TERM + "/";
    41   yield promiseAddVisits(uri(TEST_URL));
    42   do_check_true(search_has_result(SEARCH_TERM));
    43 });

mercurial