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