toolkit/components/places/tests/unit/test_463863.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_463863.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,60 @@
     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 + * TEST DESCRIPTION:
    1.12 + *
    1.13 + * This test checks that in a basic history query all transition types visits
    1.14 + * appear but TRANSITION_EMBED and TRANSITION_FRAMED_LINK ones.
    1.15 + */
    1.16 +
    1.17 +let transitions = [
    1.18 +  TRANSITION_LINK
    1.19 +, TRANSITION_TYPED
    1.20 +, TRANSITION_BOOKMARK
    1.21 +, TRANSITION_EMBED
    1.22 +, TRANSITION_FRAMED_LINK
    1.23 +, TRANSITION_REDIRECT_PERMANENT
    1.24 +, TRANSITION_REDIRECT_TEMPORARY
    1.25 +, TRANSITION_DOWNLOAD
    1.26 +];
    1.27 +
    1.28 +function runQuery(aResultType) {
    1.29 +  let options = PlacesUtils.history.getNewQueryOptions();
    1.30 +  options.resultType = aResultType;
    1.31 +  let root = PlacesUtils.history.executeQuery(PlacesUtils.history.getNewQuery(),
    1.32 +                                              options).root;
    1.33 +  root.containerOpen = true;
    1.34 +  let cc = root.childCount;
    1.35 +  do_check_eq(cc, transitions.length - 2);
    1.36 +
    1.37 +  for (let i = 0; i < cc; i++) {
    1.38 +    let node = root.getChild(i);
    1.39 +    // Check that all transition types but EMBED and FRAMED appear in results
    1.40 +    do_check_neq(node.uri.substr(6,1), TRANSITION_EMBED);
    1.41 +    do_check_neq(node.uri.substr(6,1), TRANSITION_FRAMED_LINK);
    1.42 +  }
    1.43 +  root.containerOpen = false;
    1.44 +}
    1.45 +
    1.46 +function run_test()
    1.47 +{
    1.48 +  run_next_test();
    1.49 +}
    1.50 +
    1.51 +add_task(function test_execute()
    1.52 +{
    1.53 +  // add visits, one for each transition type
    1.54 +  for (let [, transition] in Iterator(transitions)) {
    1.55 +    yield promiseAddVisits({
    1.56 +      uri: uri("http://" + transition + ".mozilla.org/"),
    1.57 +      transition: transition
    1.58 +    });
    1.59 +  }
    1.60 +
    1.61 +  runQuery(Ci.nsINavHistoryQueryOptions.RESULTS_AS_VISIT);
    1.62 +  runQuery(Ci.nsINavHistoryQueryOptions.RESULTS_AS_URI);
    1.63 +});

mercurial