toolkit/components/places/tests/unit/test_multi_queries.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/places/tests/unit/test_multi_queries.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,53 @@
     1.4 +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim:set ts=2 sw=2 sts=2 et: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +/**
    1.11 + * Adds a test URI visit to history.
    1.12 + *
    1.13 + * @param aURI
    1.14 + *        The URI to add a visit for.
    1.15 + * @param aReferrer
    1.16 + *        The referring URI for the given URI.  This can be null.
    1.17 + */
    1.18 +function add_visit(aURI, aDayOffset, aTransition) {
    1.19 +  yield promiseAddVisits({
    1.20 +    uri: aURI,
    1.21 +    transition: aTransition,
    1.22 +    visitDate: (Date.now() + aDayOffset*86400000) * 1000
    1.23 +  });
    1.24 +}
    1.25 +
    1.26 +function run_test()
    1.27 +{
    1.28 +  run_next_test();
    1.29 +}
    1.30 +
    1.31 +add_task(function test_execute()
    1.32 +{
    1.33 +  yield add_visit(uri("http://mirror1.mozilla.com/a"), -1, TRANSITION_LINK);
    1.34 +  yield add_visit(uri("http://mirror2.mozilla.com/b"), -2, TRANSITION_LINK);
    1.35 +  yield add_visit(uri("http://mirror3.mozilla.com/c"), -4, TRANSITION_FRAMED_LINK);
    1.36 +  yield add_visit(uri("http://mirror1.google.com/b"), -1, TRANSITION_EMBED);
    1.37 +  yield add_visit(uri("http://mirror2.google.com/a"), -2, TRANSITION_LINK);
    1.38 +  yield add_visit(uri("http://mirror1.apache.org/b"), -3, TRANSITION_LINK);
    1.39 +  yield add_visit(uri("http://mirror2.apache.org/a"), -4, TRANSITION_FRAMED_LINK);
    1.40 +
    1.41 +  let queries = [
    1.42 +    PlacesUtils.history.getNewQuery(),
    1.43 +    PlacesUtils.history.getNewQuery()
    1.44 +  ];
    1.45 +  queries[0].domain = "mozilla.com";
    1.46 +  queries[1].domain = "google.com";
    1.47 +
    1.48 +  let root = PlacesUtils.history.executeQueries(
    1.49 +    queries, queries.length, PlacesUtils.history.getNewQueryOptions()
    1.50 +  ).root;
    1.51 +  root.containerOpen = true;
    1.52 +  let childCount = root.childCount;
    1.53 +  root.containerOpen = false;
    1.54 +
    1.55 +  do_check_eq(childCount, 3);
    1.56 +});

mercurial