toolkit/components/places/tests/queries/test_searchTerms_includeHidden.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 // Tests the interaction of includeHidden and searchTerms search options.
     9 let timeInMicroseconds = Date.now() * 1000;
    11 const VISITS = [
    12   { isVisit: true,
    13     transType: TRANSITION_TYPED,
    14     uri: "http://redirect.example.com/",
    15     title: "example",
    16     isRedirect: true,
    17     lastVisit: timeInMicroseconds--
    18   },
    19   { isVisit: true,
    20     transType: TRANSITION_TYPED,
    21     uri: "http://target.example.com/",
    22     title: "example",
    23     lastVisit: timeInMicroseconds--
    24   }
    25 ];
    27 const HIDDEN_VISITS = [
    28   { isVisit: true,
    29     transType: TRANSITION_FRAMED_LINK,
    30     uri: "http://hidden.example.com/",
    31     title: "red",
    32     lastVisit: timeInMicroseconds--
    33   },
    34 ];
    36 const TEST_DATA = [
    37   { searchTerms: "example",
    38     includeHidden: true,
    39     expectedResults: 2
    40   },
    41   { searchTerms: "example",
    42     includeHidden: false,
    43     expectedResults: 1
    44   },
    45   { searchTerms: "red",
    46     includeHidden: true,
    47     expectedResults: 1
    48   }
    49 ];
    51 function run_test()
    52 {
    53   run_next_test();
    54 }
    56 add_task(function test_initalize()
    57 {
    58   yield task_populateDB(VISITS);
    59 });
    61 add_task(function test_searchTerms_includeHidden()
    62 {
    63   for (let data of TEST_DATA) {
    64     let query = PlacesUtils.history.getNewQuery();
    65     query.searchTerms = data.searchTerms;
    66     let options = PlacesUtils.history.getNewQueryOptions();
    67     options.includeHidden = data.includeHidden;
    69     let root = PlacesUtils.history.executeQuery(query, options).root;
    70     root.containerOpen = true;
    72     let cc = root.childCount;
    73     // Live update with hidden visits.
    74     yield task_populateDB(HIDDEN_VISITS);
    75     let cc_update = root.childCount;
    77     root.containerOpen = false;
    79     do_check_eq(cc, data.expectedResults);
    80     do_check_eq(cc_update, data.expectedResults + (data.includeHidden ? 1 : 0));
    82     PlacesUtils.bhistory.removePage(uri("http://hidden.example.com/"));
    83   }
    84 });

mercurial