toolkit/components/places/tests/unit/test_405497.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.

michael@0 1 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim:set ts=2 sw=2 sts=2 et: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
michael@0 8
michael@0 9 var hs = Cc["@mozilla.org/browser/nav-history-service;1"].
michael@0 10 getService(Ci.nsINavHistoryService);
michael@0 11 var bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
michael@0 12 getService(Ci.nsINavBookmarksService);
michael@0 13
michael@0 14 /**
michael@0 15 * The callback object for runInBatchMode.
michael@0 16 *
michael@0 17 * @param aService
michael@0 18 * Takes a reference to the history service or the bookmark service.
michael@0 19 * This determines which service should be called when calling the second
michael@0 20 * runInBatchMode the second time.
michael@0 21 */
michael@0 22 function callback(aService)
michael@0 23 {
michael@0 24 this.callCount = 0;
michael@0 25 this.service = aService;
michael@0 26 }
michael@0 27 callback.prototype = {
michael@0 28 //////////////////////////////////////////////////////////////////////////////
michael@0 29 //// nsINavHistoryBatchCallback
michael@0 30
michael@0 31 runBatched: function(aUserData)
michael@0 32 {
michael@0 33 this.callCount++;
michael@0 34
michael@0 35 if (this.callCount == 1) {
michael@0 36 // We want to call run in batched once more.
michael@0 37 this.service.runInBatchMode(this, null);
michael@0 38 return;
michael@0 39 }
michael@0 40
michael@0 41 do_check_eq(this.callCount, 2);
michael@0 42 do_test_finished();
michael@0 43 },
michael@0 44
michael@0 45 //////////////////////////////////////////////////////////////////////////////
michael@0 46 //// nsISupports
michael@0 47
michael@0 48 QueryInterface: XPCOMUtils.generateQI([Ci.nsINavHistoryBatchCallback])
michael@0 49 };
michael@0 50
michael@0 51 function run_test() {
michael@0 52 // checking the history service
michael@0 53 do_test_pending();
michael@0 54 hs.runInBatchMode(new callback(hs), null);
michael@0 55
michael@0 56 // checking the bookmark service
michael@0 57 do_test_pending();
michael@0 58 bs.runInBatchMode(new callback(bs), null);
michael@0 59 }

mercurial