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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/components/places/tests/unit/test_536081.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,56 @@
     1.4 +/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim:set ts=2 sw=2 sts=2 et: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +let hs = Cc["@mozilla.org/browser/nav-history-service;1"].
    1.11 +         getService(Ci.nsINavHistoryService);
    1.12 +let bh = hs.QueryInterface(Ci.nsIBrowserHistory);
    1.13 +let db = hs.QueryInterface(Ci.nsPIPlacesDatabase).DBConnection;
    1.14 +
    1.15 +const URLS = [
    1.16 +  { 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",
    1.17 +    s: "goog" },
    1.18 +];
    1.19 +
    1.20 +function run_test()
    1.21 +{
    1.22 +  run_next_test();
    1.23 +}
    1.24 +
    1.25 +add_task(function test_execute()
    1.26 +{
    1.27 +  for (let [, url] in Iterator(URLS)) {
    1.28 +    yield task_test_url(url);
    1.29 +  }
    1.30 +});
    1.31 +
    1.32 +function task_test_url(aURL) {
    1.33 +  print("Testing url: " + aURL.u);
    1.34 +  yield promiseAddVisits(uri(aURL.u));
    1.35 +  let query = hs.getNewQuery();
    1.36 +  query.searchTerms = aURL.s;
    1.37 +  let options = hs.getNewQueryOptions();
    1.38 +  let root = hs.executeQuery(query, options).root;
    1.39 +  root.containerOpen = true;
    1.40 +  let cc = root.childCount;
    1.41 +  do_check_eq(cc, 1);
    1.42 +  print("Checking url is in the query.");
    1.43 +  let node = root.getChild(0);
    1.44 +  print("Found " + node.uri);
    1.45 +  root.containerOpen = false;
    1.46 +  bh.removePage(uri(node.uri));
    1.47 +}
    1.48 +
    1.49 +function check_empty_table(table_name) {
    1.50 +  print("Checking url has been removed.");
    1.51 +  let stmt = db.createStatement("SELECT count(*) FROM " + table_name);
    1.52 +  try {
    1.53 +    stmt.executeStep();
    1.54 +    do_check_eq(stmt.getInt32(0), 0);
    1.55 +  }
    1.56 +  finally {
    1.57 +    stmt.finalize();
    1.58 +  }
    1.59 +}

mercurial