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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/places/tests/unit/nsDummyObserver.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,53 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
     1.9 +
    1.10 +const Cc = Components.classes;
    1.11 +const Ci = Components.interfaces;
    1.12 +
    1.13 +// Dummy boomark/history observer
    1.14 +function DummyObserver() {
    1.15 +  let os = Cc["@mozilla.org/observer-service;1"].
    1.16 +           getService(Ci.nsIObserverService);
    1.17 +  os.notifyObservers(null, "dummy-observer-created", null);
    1.18 +}
    1.19 +
    1.20 +DummyObserver.prototype = {
    1.21 +  // history observer
    1.22 +  onBeginUpdateBatch: function () {},
    1.23 +  onEndUpdateBatch: function () {},
    1.24 +  onVisit: function (aURI, aVisitID, aTime, aSessionID, aReferringID, aTransitionType) {
    1.25 +    let os = Cc["@mozilla.org/observer-service;1"].
    1.26 +             getService(Ci.nsIObserverService);
    1.27 +    os.notifyObservers(null, "dummy-observer-visited", null);
    1.28 +  },
    1.29 +  onTitleChanged: function () {},
    1.30 +  onDeleteURI: function () {},
    1.31 +  onClearHistory: function () {},
    1.32 +  onPageChanged: function () {},
    1.33 +  onDeleteVisits: function () {},
    1.34 +
    1.35 +  // bookmark observer
    1.36 +  //onBeginUpdateBatch: function() {},
    1.37 +  //onEndUpdateBatch: function() {},
    1.38 +  onItemAdded: function(aItemId, aParentId, aIndex, aItemType, aURI) {
    1.39 +    let os = Cc["@mozilla.org/observer-service;1"].
    1.40 +             getService(Ci.nsIObserverService);
    1.41 +    os.notifyObservers(null, "dummy-observer-item-added", null);
    1.42 +  },
    1.43 +  onItemChanged: function () {},
    1.44 +  onItemRemoved: function() {},
    1.45 +  onItemVisited: function() {},
    1.46 +  onItemMoved: function() {},
    1.47 +
    1.48 +  classID: Components.ID("62e221d3-68c3-4e1a-8943-a27beb5005fe"),
    1.49 +
    1.50 +  QueryInterface: XPCOMUtils.generateQI([
    1.51 +    Ci.nsINavBookmarkObserver,
    1.52 +    Ci.nsINavHistoryObserver,
    1.53 +  ])
    1.54 +};
    1.55 +
    1.56 +this.NSGetFactory = XPCOMUtils.generateNSGetFactory([DummyObserver]);

mercurial