summaryrefslogtreecommitdiffstats
path: root/toolkit/components/autocomplete/tests/unit/test_autofillSelectedPopupIndex.js
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-02-25 15:07:00 -0500
committerwolfbeast <mcwerewolf@wolfbeast.com>2020-04-14 12:55:19 +0200
commiteb70e6e3d0bff11c25f14b1196025791bf2308fb (patch)
tree5ef4ce17db83c74d7b05ec12c8f59e095a6dd5bd /toolkit/components/autocomplete/tests/unit/test_autofillSelectedPopupIndex.js
parent32ead795290b3399d56b4708fc75b77d296f6a1a (diff)
downloadUXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.gz
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.lz
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.xz
UXP-eb70e6e3d0bff11c25f14b1196025791bf2308fb.zip
Issue #439 - Remove tests from toolkit/
Diffstat (limited to 'toolkit/components/autocomplete/tests/unit/test_autofillSelectedPopupIndex.js')
-rw-r--r--toolkit/components/autocomplete/tests/unit/test_autofillSelectedPopupIndex.js78
1 files changed, 0 insertions, 78 deletions
diff --git a/toolkit/components/autocomplete/tests/unit/test_autofillSelectedPopupIndex.js b/toolkit/components/autocomplete/tests/unit/test_autofillSelectedPopupIndex.js
deleted file mode 100644
index 5fb93abc1..000000000
--- a/toolkit/components/autocomplete/tests/unit/test_autofillSelectedPopupIndex.js
+++ /dev/null
@@ -1,78 +0,0 @@
-"use strict";
-
-add_task(function* sameCaseAsMatch() {
- yield runTest("moz");
-});
-
-add_task(function* differentCaseFromMatch() {
- yield runTest("MOZ");
-});
-
-function* runTest(searchStr) {
- let matches = [
- "mozilla.org",
- "example.com",
- ];
- let result = new AutoCompleteResultBase(matches);
- result.defaultIndex = 0;
-
- let search = new AutoCompleteSearchBase("search", result);
- registerAutoCompleteSearch(search);
-
- let input = new AutoCompleteInputBase([search.name]);
- input.completeSelectedIndex = true;
- input.completeDefaultIndex = true;
-
- // Start off with the search string in the input. The selection must be
- // collapsed and the caret must be at the end to trigger autofill below.
- input.textValue = searchStr;
- input.selectTextRange(searchStr.length, searchStr.length);
- Assert.equal(input.selectionStart, searchStr.length,
- "Selection should start at the end of the input");
- Assert.equal(input.selectionEnd, searchStr.length,
- "Selection should end at the end of the input");
-
- let controller = Cc["@mozilla.org/autocomplete/controller;1"].
- createInstance(Ci.nsIAutoCompleteController);
- controller.input = input;
- input.controller = controller;
-
- // Start a search.
- yield new Promise(resolve => {
- controller.startSearch(searchStr);
- input.onSearchComplete = () => {
- // The first match should have autofilled, but the case of the search
- // string should be preserved.
- let expectedValue = searchStr + matches[0].substr(searchStr.length);
- Assert.equal(input.textValue, expectedValue,
- "Should have autofilled");
- Assert.equal(input.selectionStart, searchStr.length,
- "Selection should start after search string");
- Assert.equal(input.selectionEnd, expectedValue.length,
- "Selection should end at the end of the input");
- resolve();
- };
- });
-
- // Key down to select the second match in the popup.
- controller.handleKeyNavigation(Ci.nsIDOMKeyEvent.DOM_VK_DOWN);
- let expectedValue = matches[1];
- Assert.equal(input.textValue, expectedValue,
- "Should have filled second match");
- Assert.equal(input.selectionStart, expectedValue.length,
- "Selection should start at the end of the input");
- Assert.equal(input.selectionEnd, expectedValue.length,
- "Selection should end at the end of the input");
-
- // Key up to select the first match again. The input should be restored
- // exactly as it was when the first match was autofilled above: the search
- // string's case should be preserved, and the selection should be preserved.
- controller.handleKeyNavigation(Ci.nsIDOMKeyEvent.DOM_VK_UP);
- expectedValue = searchStr + matches[0].substr(searchStr.length);
- Assert.equal(input.textValue, expectedValue,
- "Should have filled first match again");
- Assert.equal(input.selectionStart, searchStr.length,
- "Selection should start after search string again");
- Assert.equal(input.selectionEnd, expectedValue.length,
- "Selection should end at the end of the input again");
-}