michael@0: /** michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ michael@0: */ michael@0: michael@0: const INITIAL_URL = "http://example.com/tests/toolkit/components/places/tests/browser/begin.html"; michael@0: const FINAL_URL = "http://example.com/tests/toolkit/components/places/tests/browser/final.html"; michael@0: michael@0: let gTab = gBrowser.selectedTab = gBrowser.addTab(); michael@0: michael@0: /** michael@0: * One-time observer callback. michael@0: */ michael@0: function waitForObserve(name, callback) michael@0: { michael@0: let observer = { michael@0: QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]), michael@0: observe: function(subject, topic, data) michael@0: { michael@0: Services.obs.removeObserver(observer, name); michael@0: callback(subject, topic, data); michael@0: } michael@0: }; michael@0: michael@0: Services.obs.addObserver(observer, name, false); michael@0: } michael@0: michael@0: /** michael@0: * One-time DOMContentLoaded callback. michael@0: */ michael@0: function waitForLoad(callback) michael@0: { michael@0: gTab.linkedBrowser.addEventListener("load", function() michael@0: { michael@0: gTab.linkedBrowser.removeEventListener("load", arguments.callee, true); michael@0: callback(); michael@0: }, true); michael@0: } michael@0: michael@0: function test() michael@0: { michael@0: waitForExplicitFinish(); michael@0: michael@0: Services.prefs.setBoolPref("places.history.enabled", false); michael@0: michael@0: waitForObserve("uri-visit-saved", function(subject, topic, data) michael@0: { michael@0: let uri = subject.QueryInterface(Ci.nsIURI); michael@0: is(uri.spec, FINAL_URL, "received expected visit"); michael@0: if (uri.spec != FINAL_URL) michael@0: return; michael@0: gBrowser.removeCurrentTab(); michael@0: promiseClearHistory().then(finish); michael@0: }); michael@0: michael@0: Services.prefs.setBoolPref("places.history.enabled", false); michael@0: content.location.href = INITIAL_URL; michael@0: waitForLoad(function() michael@0: { michael@0: try { michael@0: Services.prefs.clearUserPref("places.history.enabled"); michael@0: } catch(ex) {} michael@0: content.location.href = FINAL_URL; michael@0: }); michael@0: }