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: Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); michael@0: michael@0: var hs = Cc["@mozilla.org/browser/nav-history-service;1"]. michael@0: getService(Ci.nsINavHistoryService); michael@0: var bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"]. michael@0: getService(Ci.nsINavBookmarksService); michael@0: michael@0: /** michael@0: * The callback object for runInBatchMode. michael@0: * michael@0: * @param aService michael@0: * Takes a reference to the history service or the bookmark service. michael@0: * This determines which service should be called when calling the second michael@0: * runInBatchMode the second time. michael@0: */ michael@0: function callback(aService) michael@0: { michael@0: this.callCount = 0; michael@0: this.service = aService; michael@0: } michael@0: callback.prototype = { michael@0: ////////////////////////////////////////////////////////////////////////////// michael@0: //// nsINavHistoryBatchCallback michael@0: michael@0: runBatched: function(aUserData) michael@0: { michael@0: this.callCount++; michael@0: michael@0: if (this.callCount == 1) { michael@0: // We want to call run in batched once more. michael@0: this.service.runInBatchMode(this, null); michael@0: return; michael@0: } michael@0: michael@0: do_check_eq(this.callCount, 2); michael@0: do_test_finished(); michael@0: }, michael@0: michael@0: ////////////////////////////////////////////////////////////////////////////// michael@0: //// nsISupports michael@0: michael@0: QueryInterface: XPCOMUtils.generateQI([Ci.nsINavHistoryBatchCallback]) michael@0: }; michael@0: michael@0: function run_test() { michael@0: // checking the history service michael@0: do_test_pending(); michael@0: hs.runInBatchMode(new callback(hs), null); michael@0: michael@0: // checking the bookmark service michael@0: do_test_pending(); michael@0: bs.runInBatchMode(new callback(bs), null); michael@0: }