michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ : 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: * What this is aimed to test: michael@0: * michael@0: * Ensure that History (through category cache) notifies us just once. michael@0: */ michael@0: michael@0: let os = Cc["@mozilla.org/observer-service;1"]. michael@0: getService(Ci.nsIObserverService); michael@0: let hs = Cc["@mozilla.org/browser/nav-history-service;1"]. michael@0: getService(Ci.nsINavHistoryService); michael@0: michael@0: let gObserver = { michael@0: notifications: 0, michael@0: observe: function(aSubject, aTopic, aData) { michael@0: this.notifications++; michael@0: } michael@0: }; michael@0: os.addObserver(gObserver, PlacesUtils.TOPIC_EXPIRATION_FINISHED, false); michael@0: michael@0: function run_test() { michael@0: // Set interval to a large value so we don't expire on it. michael@0: setInterval(3600); // 1h michael@0: michael@0: hs.QueryInterface(Ci.nsIBrowserHistory).removeAllPages(); michael@0: michael@0: do_timeout(2000, check_result); michael@0: do_test_pending(); michael@0: } michael@0: michael@0: function check_result() { michael@0: os.removeObserver(gObserver, PlacesUtils.TOPIC_EXPIRATION_FINISHED); michael@0: do_check_eq(gObserver.notifications, 1); michael@0: do_test_finished(); michael@0: }