michael@0: var gNotifications = 0; michael@0: michael@0: var observer = { michael@0: QueryInterface: function(iid) { michael@0: if (Ci.nsIPrivacyTransitionObserver.equals(iid) || michael@0: Ci.nsISupportsWeakReference.equals(iid) || michael@0: Ci.nsISupports.equals(iid)) michael@0: return this; michael@0: throw Cr.NS_ERROR_NO_INTERFACE; michael@0: }, michael@0: michael@0: privateModeChanged: function(enabled) { michael@0: gNotifications++; michael@0: } michael@0: } michael@0: michael@0: function run_test() { michael@0: var docshell = Cc["@mozilla.org/docshell;1"].createInstance(Ci.nsIDocShell); michael@0: docshell.addWeakPrivacyTransitionObserver(observer); michael@0: docshell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing = true; michael@0: docshell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing = false; michael@0: do_check_eq(gNotifications, 2); michael@0: }