toolkit/components/places/tests/browser/browser_visited_notfound.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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/. */
     5 const TEST_URI = NetUtil.newURI("http://mochi.test:8888/notFoundPage.html");
     7 function test() {
     8   waitForExplicitFinish();
    10   gBrowser.selectedTab = gBrowser.addTab();
    11   registerCleanupFunction(function() {
    12     gBrowser.removeCurrentTab();
    13   });
    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 }
    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);
    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 }

mercurial