toolkit/components/places/tests/unit/test_markpageas.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* vim:set ts=2 sw=2 sts=2 et: */
     3 /* This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 var gVisits = [{url: "http://www.mozilla.com/",
     8                 transition: TRANSITION_TYPED},
     9                {url: "http://www.google.com/",
    10                 transition: TRANSITION_BOOKMARK},
    11                {url: "http://www.espn.com/",
    12                 transition: TRANSITION_LINK}];
    14 function run_test()
    15 {
    16   run_next_test();
    17 }
    19 add_task(function test_execute()
    20 {
    21   let observer;
    22   let completionPromise = new Promise(resolveCompletionPromise => {
    23     observer = {
    24       __proto__: NavHistoryObserver.prototype,
    25       _visitCount: 0,
    26       onVisit: function (aURI, aVisitID, aTime, aSessionID, aReferringID,
    27                          aTransitionType, aAdded)
    28       {
    29         do_check_eq(aURI.spec, gVisits[this._visitCount].url);
    30         do_check_eq(aTransitionType, gVisits[this._visitCount].transition);
    31         this._visitCount++;
    33         if (this._visitCount == gVisits.length) {
    34           resolveCompletionPromise();
    35         }
    36       },
    37     };
    38   });
    40   PlacesUtils.history.addObserver(observer, false);
    42   for each (var visit in gVisits) {
    43     if (visit.transition == TRANSITION_TYPED)
    44       PlacesUtils.history.markPageAsTyped(uri(visit.url));
    45     else if (visit.transition == TRANSITION_BOOKMARK)
    46       PlacesUtils.history.markPageAsFollowedBookmark(uri(visit.url))
    47     else {
    48      // because it is a top level visit with no referrer,
    49      // it will result in TRANSITION_LINK
    50     }
    51     yield promiseAddVisits({uri: uri(visit.url),
    52                             transition: visit.transition});
    53   }
    55   yield completionPromise;
    57   PlacesUtils.history.removeObserver(observer);
    58 });

mercurial