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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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 function run_test()
     8 {
     9   run_next_test();
    10 }
    12 add_task(function test_execute()
    13 {
    14   let count_visited_URIs = ["http://www.test-link.com/",
    15                             "http://www.test-typed.com/",
    16                             "http://www.test-bookmark.com/",
    17                             "http://www.test-redirect-permanent.com/",
    18                             "http://www.test-redirect-temporary.com/"];
    20   let notcount_visited_URIs = ["http://www.test-embed.com/",
    21                                "http://www.test-download.com/",
    22                                "http://www.test-framed.com/"];
    24   // add visits, one for each transition type
    25   yield promiseAddVisits([
    26     { uri: uri("http://www.test-link.com/"),
    27       transition: TRANSITION_LINK },
    28     { uri: uri("http://www.test-typed.com/"),
    29       transition: TRANSITION_TYPED },
    30     { uri: uri("http://www.test-bookmark.com/"),
    31       transition: TRANSITION_BOOKMARK },
    32     { uri: uri("http://www.test-embed.com/"),
    33       transition: TRANSITION_EMBED },
    34     { uri: uri("http://www.test-framed.com/"),
    35       transition: TRANSITION_FRAMED_LINK },
    36     { uri: uri("http://www.test-redirect-permanent.com/"),
    37       transition: TRANSITION_REDIRECT_PERMANENT },
    38     { uri: uri("http://www.test-redirect-temporary.com/"),
    39       transition: TRANSITION_REDIRECT_TEMPORARY },
    40     { uri: uri("http://www.test-download.com/"),
    41       transition: TRANSITION_DOWNLOAD },
    42   ]);
    44   // check that all links are marked as visited
    45   count_visited_URIs.forEach(function (visited_uri) {
    46     do_check_true(yield promiseIsURIVisited(uri(visited_uri)));
    47   });
    48   notcount_visited_URIs.forEach(function (visited_uri) {
    49     do_check_true(yield promiseIsURIVisited(uri(visited_uri)));
    50   });
    52   // check that visit_count does not take in count embed and downloads
    53   // maxVisits query are directly binded to visit_count
    54   let options = PlacesUtils.history.getNewQueryOptions();
    55   options.sortingMode = options.SORT_BY_VISITCOUNT_DESCENDING;
    56   options.resultType = options.RESULTS_AS_VISIT;
    57   options.includeHidden = true;
    58   let query = PlacesUtils.history.getNewQuery();
    59   query.minVisits = 1;
    60   let root = PlacesUtils.history.executeQuery(query, options).root;
    62   root.containerOpen = true;
    63   let cc = root.childCount;
    64   do_check_eq(cc, count_visited_URIs.length);
    66   for (let i = 0; i < cc; i++) {
    67     let node = root.getChild(i);
    68     do_check_neq(count_visited_URIs.indexOf(node.uri), -1);
    69   }
    70   root.containerOpen = false;
    71 });

mercurial