toolkit/components/places/tests/unit/test_413784.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 /*
     9 Test autocomplete for non-English URLs
    11 - add a visit for a page with a non-English URL
    12 - search
    13 - test number of matches (should be exactly one)
    15 */
    17 var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
    18               getService(Ci.nsINavHistoryService);
    19 var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].
    20             getService(Ci.nsINavBookmarksService);
    22 // create test data
    23 var searchTerm = "ユニコード";
    24 var decoded = "http://www.foobar.com/" + searchTerm + "/";
    25 var url = uri(decoded);
    27 function AutoCompleteInput(aSearches) {
    28   this.searches = aSearches;
    29 }
    31 AutoCompleteInput.prototype = {
    32   constructor: AutoCompleteInput, 
    34   searches: null,
    36   minResultsForPopup: 0,
    37   timeout: 10,
    38   searchParam: "",
    39   textValue: "",
    40   disableAutoComplete: false,  
    41   completeDefaultIndex: false,
    43   get searchCount() {
    44     return this.searches.length;
    45   },
    47   getSearchAt: function(aIndex) {
    48     return this.searches[aIndex];
    49   },
    51   onSearchBegin: function() {},
    52   onSearchComplete: function() {},
    54   popupOpen: false,
    56   popup: {
    57     setSelectedIndex: function(aIndex) {},
    58     invalidate: function() {},
    60     // nsISupports implementation
    61     QueryInterface: function(iid) {
    62       if (iid.equals(Ci.nsISupports) ||
    63           iid.equals(Ci.nsIAutoCompletePopup))
    64         return this;
    66       throw Components.results.NS_ERROR_NO_INTERFACE;
    67     }
    68   },
    70   // nsISupports implementation
    71   QueryInterface: function(iid) {
    72     if (iid.equals(Ci.nsISupports) ||
    73         iid.equals(Ci.nsIAutoCompleteInput))
    74       return this;
    76     throw Components.results.NS_ERROR_NO_INTERFACE;
    77   }
    78 }
    80 function run_test()
    81 {
    82   do_test_pending();
    83   promiseAddVisits(url).then(continue_test);
    84 }
    86 function continue_test()
    87 {
    88   var controller = Components.classes["@mozilla.org/autocomplete/controller;1"].
    89                    getService(Components.interfaces.nsIAutoCompleteController);
    91   // Make an AutoCompleteInput that uses our searches
    92   // and confirms results on search complete
    93   var input = new AutoCompleteInput(["history"]);
    95   controller.input = input;
    97   var numSearchesStarted = 0;
    98   input.onSearchBegin = function() {
    99     numSearchesStarted++;
   100     do_check_eq(numSearchesStarted, 1);
   101   };
   103   input.onSearchComplete = function() {
   104     do_check_eq(numSearchesStarted, 1);
   105     do_check_eq(controller.searchStatus,
   106                 Ci.nsIAutoCompleteController.STATUS_COMPLETE_MATCH);
   108     // test that we found the entry we added
   109     do_check_eq(controller.matchCount, 1);
   111     // Make sure the url is the same according to spec, so it can be deleted
   112     do_check_eq(controller.getValueAt(0), url.spec);
   114     do_test_finished();
   115   };
   117   controller.startSearch(searchTerm);
   118 }

mercurial