michael@0: /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim:set ts=2 sw=2 sts=2 et: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* michael@0: * TEST DESCRIPTION: michael@0: * michael@0: * This test checks that in a basic history query all transition types visits michael@0: * appear but TRANSITION_EMBED and TRANSITION_FRAMED_LINK ones. michael@0: */ michael@0: michael@0: let transitions = [ michael@0: TRANSITION_LINK michael@0: , TRANSITION_TYPED michael@0: , TRANSITION_BOOKMARK michael@0: , TRANSITION_EMBED michael@0: , TRANSITION_FRAMED_LINK michael@0: , TRANSITION_REDIRECT_PERMANENT michael@0: , TRANSITION_REDIRECT_TEMPORARY michael@0: , TRANSITION_DOWNLOAD michael@0: ]; michael@0: michael@0: function runQuery(aResultType) { michael@0: let options = PlacesUtils.history.getNewQueryOptions(); michael@0: options.resultType = aResultType; michael@0: let root = PlacesUtils.history.executeQuery(PlacesUtils.history.getNewQuery(), michael@0: options).root; michael@0: root.containerOpen = true; michael@0: let cc = root.childCount; michael@0: do_check_eq(cc, transitions.length - 2); michael@0: michael@0: for (let i = 0; i < cc; i++) { michael@0: let node = root.getChild(i); michael@0: // Check that all transition types but EMBED and FRAMED appear in results michael@0: do_check_neq(node.uri.substr(6,1), TRANSITION_EMBED); michael@0: do_check_neq(node.uri.substr(6,1), TRANSITION_FRAMED_LINK); michael@0: } michael@0: root.containerOpen = false; michael@0: } michael@0: michael@0: function run_test() michael@0: { michael@0: run_next_test(); michael@0: } michael@0: michael@0: add_task(function test_execute() michael@0: { michael@0: // add visits, one for each transition type michael@0: for (let [, transition] in Iterator(transitions)) { michael@0: yield promiseAddVisits({ michael@0: uri: uri("http://" + transition + ".mozilla.org/"), michael@0: transition: transition michael@0: }); michael@0: } michael@0: michael@0: runQuery(Ci.nsINavHistoryQueryOptions.RESULTS_AS_VISIT); michael@0: runQuery(Ci.nsINavHistoryQueryOptions.RESULTS_AS_URI); michael@0: });