toolkit/components/places/tests/unit/test_multi_queries.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 /* vim:set ts=2 sw=2 sts=2 et: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 /**
michael@0 8 * Adds a test URI visit to history.
michael@0 9 *
michael@0 10 * @param aURI
michael@0 11 * The URI to add a visit for.
michael@0 12 * @param aReferrer
michael@0 13 * The referring URI for the given URI. This can be null.
michael@0 14 */
michael@0 15 function add_visit(aURI, aDayOffset, aTransition) {
michael@0 16 yield promiseAddVisits({
michael@0 17 uri: aURI,
michael@0 18 transition: aTransition,
michael@0 19 visitDate: (Date.now() + aDayOffset*86400000) * 1000
michael@0 20 });
michael@0 21 }
michael@0 22
michael@0 23 function run_test()
michael@0 24 {
michael@0 25 run_next_test();
michael@0 26 }
michael@0 27
michael@0 28 add_task(function test_execute()
michael@0 29 {
michael@0 30 yield add_visit(uri("http://mirror1.mozilla.com/a"), -1, TRANSITION_LINK);
michael@0 31 yield add_visit(uri("http://mirror2.mozilla.com/b"), -2, TRANSITION_LINK);
michael@0 32 yield add_visit(uri("http://mirror3.mozilla.com/c"), -4, TRANSITION_FRAMED_LINK);
michael@0 33 yield add_visit(uri("http://mirror1.google.com/b"), -1, TRANSITION_EMBED);
michael@0 34 yield add_visit(uri("http://mirror2.google.com/a"), -2, TRANSITION_LINK);
michael@0 35 yield add_visit(uri("http://mirror1.apache.org/b"), -3, TRANSITION_LINK);
michael@0 36 yield add_visit(uri("http://mirror2.apache.org/a"), -4, TRANSITION_FRAMED_LINK);
michael@0 37
michael@0 38 let queries = [
michael@0 39 PlacesUtils.history.getNewQuery(),
michael@0 40 PlacesUtils.history.getNewQuery()
michael@0 41 ];
michael@0 42 queries[0].domain = "mozilla.com";
michael@0 43 queries[1].domain = "google.com";
michael@0 44
michael@0 45 let root = PlacesUtils.history.executeQueries(
michael@0 46 queries, queries.length, PlacesUtils.history.getNewQueryOptions()
michael@0 47 ).root;
michael@0 48 root.containerOpen = true;
michael@0 49 let childCount = root.childCount;
michael@0 50 root.containerOpen = false;
michael@0 51
michael@0 52 do_check_eq(childCount, 3);
michael@0 53 });

mercurial