toolkit/components/places/tests/unit/test_536081.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 let hs = Cc["@mozilla.org/browser/nav-history-service;1"].
     8          getService(Ci.nsINavHistoryService);
     9 let bh = hs.QueryInterface(Ci.nsIBrowserHistory);
    10 let db = hs.QueryInterface(Ci.nsPIPlacesDatabase).DBConnection;
    12 const URLS = [
    13   { u: "http://www.google.com/search?q=testing%3Bthis&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:unofficial&client=firefox-a",
    14     s: "goog" },
    15 ];
    17 function run_test()
    18 {
    19   run_next_test();
    20 }
    22 add_task(function test_execute()
    23 {
    24   for (let [, url] in Iterator(URLS)) {
    25     yield task_test_url(url);
    26   }
    27 });
    29 function task_test_url(aURL) {
    30   print("Testing url: " + aURL.u);
    31   yield promiseAddVisits(uri(aURL.u));
    32   let query = hs.getNewQuery();
    33   query.searchTerms = aURL.s;
    34   let options = hs.getNewQueryOptions();
    35   let root = hs.executeQuery(query, options).root;
    36   root.containerOpen = true;
    37   let cc = root.childCount;
    38   do_check_eq(cc, 1);
    39   print("Checking url is in the query.");
    40   let node = root.getChild(0);
    41   print("Found " + node.uri);
    42   root.containerOpen = false;
    43   bh.removePage(uri(node.uri));
    44 }
    46 function check_empty_table(table_name) {
    47   print("Checking url has been removed.");
    48   let stmt = db.createStatement("SELECT count(*) FROM " + table_name);
    49   try {
    50     stmt.executeStep();
    51     do_check_eq(stmt.getInt32(0), 0);
    52   }
    53   finally {
    54     stmt.finalize();
    55   }
    56 }

mercurial