toolkit/components/places/tests/expiration/test_notifications.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.

     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/. */
     7 /**
     8  * What this is aimed to test:
     9  *
    10  * Ensure that History (through category cache) notifies us just once.
    11  */
    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);
    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);
    26 function run_test() {
    27   // Set interval to a large value so we don't expire on it.
    28   setInterval(3600); // 1h
    30   hs.QueryInterface(Ci.nsIBrowserHistory).removeAllPages();
    32   do_timeout(2000, check_result);
    33   do_test_pending();
    34 }
    36 function check_result() {
    37   os.removeObserver(gObserver, PlacesUtils.TOPIC_EXPIRATION_FINISHED);
    38   do_check_eq(gObserver.notifications, 1);
    39   do_test_finished();
    40 }

mercurial