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

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:9cf99dcefec9
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/. */
6
7 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
8
9 var hs = Cc["@mozilla.org/browser/nav-history-service;1"].
10 getService(Ci.nsINavHistoryService);
11 var bs = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
12 getService(Ci.nsINavBookmarksService);
13
14 /**
15 * The callback object for runInBatchMode.
16 *
17 * @param aService
18 * Takes a reference to the history service or the bookmark service.
19 * This determines which service should be called when calling the second
20 * runInBatchMode the second time.
21 */
22 function callback(aService)
23 {
24 this.callCount = 0;
25 this.service = aService;
26 }
27 callback.prototype = {
28 //////////////////////////////////////////////////////////////////////////////
29 //// nsINavHistoryBatchCallback
30
31 runBatched: function(aUserData)
32 {
33 this.callCount++;
34
35 if (this.callCount == 1) {
36 // We want to call run in batched once more.
37 this.service.runInBatchMode(this, null);
38 return;
39 }
40
41 do_check_eq(this.callCount, 2);
42 do_test_finished();
43 },
44
45 //////////////////////////////////////////////////////////////////////////////
46 //// nsISupports
47
48 QueryInterface: XPCOMUtils.generateQI([Ci.nsINavHistoryBatchCallback])
49 };
50
51 function run_test() {
52 // checking the history service
53 do_test_pending();
54 hs.runInBatchMode(new callback(hs), null);
55
56 // checking the bookmark service
57 do_test_pending();
58 bs.runInBatchMode(new callback(bs), null);
59 }

mercurial