toolkit/components/places/tests/bookmarks/test_388695.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 // Get bookmark service
     8 try {
     9   var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
    10               getService(Ci.nsINavBookmarksService);
    11 } catch(ex) {
    12   do_throw("Could not get nav-bookmarks-service\n");
    13 }
    15 var gTestRoot;
    16 var gURI;
    17 var gItemId1;
    18 var gItemId2;
    20 // main
    21 function run_test() {
    22   gURI = uri("http://foo.tld.com/");
    23   gTestRoot = bmsvc.createFolder(bmsvc.placesRoot, "test folder",
    24                                  bmsvc.DEFAULT_INDEX);
    26   // test getBookmarkIdsForURI
    27   // getBookmarkIdsForURI sorts by the most recently added/modified (descending)
    28   //
    29   // we cannot rely on dateAdded growing when doing so in a simple iteration,
    30   // see PR_Now() documentation
    31   do_test_pending();
    33   gItemId1 = bmsvc.insertBookmark(gTestRoot, gURI, bmsvc.DEFAULT_INDEX, "");
    34   do_timeout(100, phase2);
    35 }
    37 function phase2() {
    38   gItemId2 = bmsvc.insertBookmark(gTestRoot, gURI, bmsvc.DEFAULT_INDEX, "");  
    39   var b = bmsvc.getBookmarkIdsForURI(gURI);
    40   do_check_eq(b[0], gItemId2);
    41   do_check_eq(b[1], gItemId1);
    42   do_timeout(100, phase3);
    43 }
    45 function phase3() {
    46   // trigger last modified change
    47   bmsvc.setItemTitle(gItemId1, "");
    48   var b = bmsvc.getBookmarkIdsForURI(gURI);
    49   do_check_eq(b[0], gItemId1);
    50   do_check_eq(b[1], gItemId2);
    51   do_test_finished();
    52 }

mercurial