toolkit/components/autocomplete/tests/unit/test_finalCompleteValue_forceComplete.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.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 function AutoCompleteResult(aValues, aFinalCompleteValues) {
michael@0 6 this._values = aValues;
michael@0 7 this._finalCompleteValues = aFinalCompleteValues;
michael@0 8 this.defaultIndex = 0;
michael@0 9 }
michael@0 10 AutoCompleteResult.prototype = Object.create(AutoCompleteResultBase.prototype);
michael@0 11
michael@0 12 function AutoCompleteInput(aSearches) {
michael@0 13 this.searches = aSearches;
michael@0 14 this.popup.selectedIndex = -1;
michael@0 15 }
michael@0 16 AutoCompleteInput.prototype = Object.create(AutoCompleteInputBase.prototype);
michael@0 17
michael@0 18 function run_test() {
michael@0 19 run_next_test();
michael@0 20 }
michael@0 21
michael@0 22 add_test(function test_handleEnter() {
michael@0 23 doSearch("", "mozilla.com", "http://www.mozilla.com", function(aController) {
michael@0 24 do_check_eq(aController.input.textValue, "");
michael@0 25 do_check_eq(aController.getFinalCompleteValueAt(0), "http://www.mozilla.com");
michael@0 26 aController.input.forceComplete = true;
michael@0 27 aController.handleEnter(false);
michael@0 28 do_check_eq(aController.input.textValue, "http://www.mozilla.com");
michael@0 29 });
michael@0 30 });
michael@0 31
michael@0 32 function doSearch(aSearchString, aResultValue, aFinalCompleteValue, aOnCompleteCallback) {
michael@0 33 let search = new AutoCompleteSearchBase(
michael@0 34 "search",
michael@0 35 new AutoCompleteResult([ aResultValue ], [ aFinalCompleteValue ])
michael@0 36 );
michael@0 37 registerAutoCompleteSearch(search);
michael@0 38
michael@0 39 let controller = Cc["@mozilla.org/autocomplete/controller;1"].
michael@0 40 getService(Ci.nsIAutoCompleteController);
michael@0 41
michael@0 42 // Make an AutoCompleteInput that uses our searches and confirms results.
michael@0 43 let input = new AutoCompleteInput([ search.name ]);
michael@0 44 input.textValue = aSearchString;
michael@0 45
michael@0 46 controller.input = input;
michael@0 47 controller.startSearch(aSearchString);
michael@0 48
michael@0 49 input.onSearchComplete = function onSearchComplete() {
michael@0 50 aOnCompleteCallback(controller);
michael@0 51
michael@0 52 // Clean up.
michael@0 53 unregisterAutoCompleteSearch(search);
michael@0 54 run_next_test();
michael@0 55 };
michael@0 56 }

mercurial