michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: const TEST_URI = NetUtil.newURI("http://mochi.test:8888/notFoundPage.html"); michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: gBrowser.selectedTab = gBrowser.addTab(); michael@0: registerCleanupFunction(function() { michael@0: gBrowser.removeCurrentTab(); michael@0: }); michael@0: michael@0: // First add a visit to the page, this will ensure that later we skip michael@0: // updating the frecency for a newly not-found page. michael@0: addVisits({ uri: TEST_URI }, window, () => { michael@0: info("Added visit"); michael@0: fieldForUrl(TEST_URI, "frecency", aFrecency => { michael@0: ok(aFrecency > 0, "Frecency should be > 0"); michael@0: continueTest(aFrecency); michael@0: }); michael@0: }); michael@0: } michael@0: michael@0: function continueTest(aOldFrecency) { michael@0: // Used to verify errors are not marked as typed. michael@0: PlacesUtils.history.markPageAsTyped(TEST_URI); michael@0: gBrowser.selectedTab.linkedBrowser.loadURI(TEST_URI.spec); michael@0: michael@0: // Create and add history observer. michael@0: let historyObserver = { michael@0: __proto__: NavHistoryObserver.prototype, michael@0: onVisit: function (aURI, aVisitID, aTime, aSessionID, aReferringID, michael@0: aTransitionType) { michael@0: PlacesUtils.history.removeObserver(historyObserver); michael@0: info("Received onVisit: " + aURI.spec); michael@0: fieldForUrl(aURI, "frecency", function (aFrecency) { michael@0: is(aFrecency, aOldFrecency, "Frecency should be unchanged"); michael@0: fieldForUrl(aURI, "hidden", function (aHidden) { michael@0: is(aHidden, 0, "Page should not be hidden"); michael@0: fieldForUrl(aURI, "typed", function (aTyped) { michael@0: is(aTyped, 0, "page should not be marked as typed"); michael@0: promiseClearHistory().then(finish); michael@0: }); michael@0: }); michael@0: }); michael@0: } michael@0: }; michael@0: PlacesUtils.history.addObserver(historyObserver, false); michael@0: }