1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/places/tests/expiration/test_notifications.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,40 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- 1.5 + * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ : 1.6 + * This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +/** 1.11 + * What this is aimed to test: 1.12 + * 1.13 + * Ensure that History (through category cache) notifies us just once. 1.14 + */ 1.15 + 1.16 +let os = Cc["@mozilla.org/observer-service;1"]. 1.17 + getService(Ci.nsIObserverService); 1.18 +let hs = Cc["@mozilla.org/browser/nav-history-service;1"]. 1.19 + getService(Ci.nsINavHistoryService); 1.20 + 1.21 +let gObserver = { 1.22 + notifications: 0, 1.23 + observe: function(aSubject, aTopic, aData) { 1.24 + this.notifications++; 1.25 + } 1.26 +}; 1.27 +os.addObserver(gObserver, PlacesUtils.TOPIC_EXPIRATION_FINISHED, false); 1.28 + 1.29 +function run_test() { 1.30 + // Set interval to a large value so we don't expire on it. 1.31 + setInterval(3600); // 1h 1.32 + 1.33 + hs.QueryInterface(Ci.nsIBrowserHistory).removeAllPages(); 1.34 + 1.35 + do_timeout(2000, check_result); 1.36 + do_test_pending(); 1.37 +} 1.38 + 1.39 +function check_result() { 1.40 + os.removeObserver(gObserver, PlacesUtils.TOPIC_EXPIRATION_FINISHED); 1.41 + do_check_eq(gObserver.notifications, 1); 1.42 + do_test_finished(); 1.43 +}