Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 3 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | const TEST_URI = NetUtil.newURI("http://mochi.test:8888/notFoundPage.html"); |
michael@0 | 6 | |
michael@0 | 7 | function test() { |
michael@0 | 8 | waitForExplicitFinish(); |
michael@0 | 9 | |
michael@0 | 10 | gBrowser.selectedTab = gBrowser.addTab(); |
michael@0 | 11 | registerCleanupFunction(function() { |
michael@0 | 12 | gBrowser.removeCurrentTab(); |
michael@0 | 13 | }); |
michael@0 | 14 | |
michael@0 | 15 | // First add a visit to the page, this will ensure that later we skip |
michael@0 | 16 | // updating the frecency for a newly not-found page. |
michael@0 | 17 | addVisits({ uri: TEST_URI }, window, () => { |
michael@0 | 18 | info("Added visit"); |
michael@0 | 19 | fieldForUrl(TEST_URI, "frecency", aFrecency => { |
michael@0 | 20 | ok(aFrecency > 0, "Frecency should be > 0"); |
michael@0 | 21 | continueTest(aFrecency); |
michael@0 | 22 | }); |
michael@0 | 23 | }); |
michael@0 | 24 | } |
michael@0 | 25 | |
michael@0 | 26 | function continueTest(aOldFrecency) { |
michael@0 | 27 | // Used to verify errors are not marked as typed. |
michael@0 | 28 | PlacesUtils.history.markPageAsTyped(TEST_URI); |
michael@0 | 29 | gBrowser.selectedTab.linkedBrowser.loadURI(TEST_URI.spec); |
michael@0 | 30 | |
michael@0 | 31 | // Create and add history observer. |
michael@0 | 32 | let historyObserver = { |
michael@0 | 33 | __proto__: NavHistoryObserver.prototype, |
michael@0 | 34 | onVisit: function (aURI, aVisitID, aTime, aSessionID, aReferringID, |
michael@0 | 35 | aTransitionType) { |
michael@0 | 36 | PlacesUtils.history.removeObserver(historyObserver); |
michael@0 | 37 | info("Received onVisit: " + aURI.spec); |
michael@0 | 38 | fieldForUrl(aURI, "frecency", function (aFrecency) { |
michael@0 | 39 | is(aFrecency, aOldFrecency, "Frecency should be unchanged"); |
michael@0 | 40 | fieldForUrl(aURI, "hidden", function (aHidden) { |
michael@0 | 41 | is(aHidden, 0, "Page should not be hidden"); |
michael@0 | 42 | fieldForUrl(aURI, "typed", function (aTyped) { |
michael@0 | 43 | is(aTyped, 0, "page should not be marked as typed"); |
michael@0 | 44 | promiseClearHistory().then(finish); |
michael@0 | 45 | }); |
michael@0 | 46 | }); |
michael@0 | 47 | }); |
michael@0 | 48 | } |
michael@0 | 49 | }; |
michael@0 | 50 | PlacesUtils.history.addObserver(historyObserver, false); |
michael@0 | 51 | } |