|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
|
2 * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ : |
|
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 /** |
|
8 * What this is aimed to test: |
|
9 * |
|
10 * Ensure that History (through category cache) notifies us just once. |
|
11 */ |
|
12 |
|
13 let os = Cc["@mozilla.org/observer-service;1"]. |
|
14 getService(Ci.nsIObserverService); |
|
15 let hs = Cc["@mozilla.org/browser/nav-history-service;1"]. |
|
16 getService(Ci.nsINavHistoryService); |
|
17 |
|
18 let gObserver = { |
|
19 notifications: 0, |
|
20 observe: function(aSubject, aTopic, aData) { |
|
21 this.notifications++; |
|
22 } |
|
23 }; |
|
24 os.addObserver(gObserver, PlacesUtils.TOPIC_EXPIRATION_FINISHED, false); |
|
25 |
|
26 function run_test() { |
|
27 // Set interval to a large value so we don't expire on it. |
|
28 setInterval(3600); // 1h |
|
29 |
|
30 hs.QueryInterface(Ci.nsIBrowserHistory).removeAllPages(); |
|
31 |
|
32 do_timeout(2000, check_result); |
|
33 do_test_pending(); |
|
34 } |
|
35 |
|
36 function check_result() { |
|
37 os.removeObserver(gObserver, PlacesUtils.TOPIC_EXPIRATION_FINISHED); |
|
38 do_check_eq(gObserver.notifications, 1); |
|
39 do_test_finished(); |
|
40 } |