Sat, 03 Jan 2015 20:18:00 +0100
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 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
5 function AutoCompleteResult(aValues, aFinalCompleteValues) {
6 this._values = aValues;
7 this._finalCompleteValues = aFinalCompleteValues;
8 this.defaultIndex = 0;
9 }
10 AutoCompleteResult.prototype = Object.create(AutoCompleteResultBase.prototype);
12 function AutoCompleteInput(aSearches) {
13 this.searches = aSearches;
14 this.popup.selectedIndex = -1;
15 this.completeDefaultIndex = true;
16 }
17 AutoCompleteInput.prototype = Object.create(AutoCompleteInputBase.prototype);
19 function run_test() {
20 run_next_test();
21 }
23 add_test(function test_keyNavigation() {
24 doSearch("moz", "mozilla.com", "http://www.mozilla.com", function(aController) {
25 do_check_eq(aController.input.textValue, "mozilla.com");
26 aController.handleKeyNavigation(Ci.nsIDOMKeyEvent.DOM_VK_RIGHT);
27 do_check_eq(aController.input.textValue, "mozilla.com");
28 });
29 });
31 add_test(function test_handleEnter() {
32 doSearch("moz", "mozilla.com", "http://www.mozilla.com", function(aController) {
33 do_check_eq(aController.input.textValue, "mozilla.com");
34 aController.handleEnter(false);
35 do_check_eq(aController.input.textValue, "http://www.mozilla.com");
36 });
37 });
39 function doSearch(aSearchString, aResultValue, aFinalCompleteValue, aOnCompleteCallback) {
40 let search = new AutoCompleteSearchBase(
41 "search",
42 new AutoCompleteResult([ aResultValue ], [ aFinalCompleteValue ])
43 );
44 registerAutoCompleteSearch(search);
46 let controller = Cc["@mozilla.org/autocomplete/controller;1"].
47 getService(Ci.nsIAutoCompleteController);
49 // Make an AutoCompleteInput that uses our searches and confirms results.
50 let input = new AutoCompleteInput([ search.name ]);
51 input.textValue = aSearchString;
53 // Caret must be at the end for autofill to happen.
54 let strLen = aSearchString.length;
55 input.selectTextRange(strLen, strLen);
56 controller.input = input;
57 controller.startSearch(aSearchString);
59 input.onSearchComplete = function onSearchComplete() {
60 aOnCompleteCallback(controller);
62 // Clean up.
63 unregisterAutoCompleteSearch(search);
64 run_next_test();
65 };
66 }