summaryrefslogtreecommitdiffstats
path: root/toolkit/components/autocomplete/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
commitd8bbc7858622b6d9c278469aab701ca0b609cddf (patch)
treeeff41dc61d9f714852212739e6b3738b82a2af87 /toolkit/components/autocomplete/tests
parentReleasing progress-linux version 125.0.3-1~progress7.99u1. (diff)
downloadfirefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz
firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/autocomplete/tests')
-rw-r--r--toolkit/components/autocomplete/tests/unit/head_autocomplete.js8
-rw-r--r--toolkit/components/autocomplete/tests/unit/test_378079.js8
-rw-r--r--toolkit/components/autocomplete/tests/unit/test_393191.js8
-rw-r--r--toolkit/components/autocomplete/tests/unit/test_440866.js8
-rw-r--r--toolkit/components/autocomplete/tests/unit/test_autocomplete_multiple.js8
-rw-r--r--toolkit/components/autocomplete/tests/unit/test_autocomplete_userContextId.js7
-rw-r--r--toolkit/components/autocomplete/tests/unit/test_immediate_search.js174
-rw-r--r--toolkit/components/autocomplete/tests/unit/test_previousResult.js8
-rw-r--r--toolkit/components/autocomplete/tests/unit/test_search_zerotimeout.js58
-rw-r--r--toolkit/components/autocomplete/tests/unit/test_stopSearch.js2
-rw-r--r--toolkit/components/autocomplete/tests/unit/xpcshell.toml4
11 files changed, 86 insertions, 207 deletions
diff --git a/toolkit/components/autocomplete/tests/unit/head_autocomplete.js b/toolkit/components/autocomplete/tests/unit/head_autocomplete.js
index 6aa0382d82..b11d02a855 100644
--- a/toolkit/components/autocomplete/tests/unit/head_autocomplete.js
+++ b/toolkit/components/autocomplete/tests/unit/head_autocomplete.js
@@ -101,7 +101,7 @@ AutoCompleteResultBase.prototype = {
return this._styles[aIndex];
},
- getImageAt(aIndex) {
+ getImageAt() {
return "";
},
@@ -109,11 +109,11 @@ AutoCompleteResultBase.prototype = {
return this._finalCompleteValues[aIndex] || this._values[aIndex];
},
- isRemovableAt(aRowIndex) {
+ isRemovableAt() {
return true;
},
- removeValueAt(aRowIndex) {},
+ removeValueAt() {},
// nsISupports implementation
QueryInterface: ChromeUtils.generateQI(["nsIAutoCompleteResult"]),
@@ -161,7 +161,7 @@ function AutocompletePopupBase(input) {
AutocompletePopupBase.prototype = {
selectedIndex: 0,
invalidate() {},
- selectBy(reverse, page) {
+ selectBy(reverse) {
let numRows = this.input.controller.matchCount;
if (numRows > 0) {
let delta = reverse ? -1 : 1;
diff --git a/toolkit/components/autocomplete/tests/unit/test_378079.js b/toolkit/components/autocomplete/tests/unit/test_378079.js
index 06819df40b..756783d17f 100644
--- a/toolkit/components/autocomplete/tests/unit/test_378079.js
+++ b/toolkit/components/autocomplete/tests/unit/test_378079.js
@@ -45,7 +45,7 @@ AutoCompleteInput.prototype = {
popupOpen: false,
popup: {
- setSelectedIndex(aIndex) {},
+ setSelectedIndex() {},
invalidate() {},
// nsISupports implementation
@@ -100,7 +100,7 @@ AutoCompleteResult.prototype = {
return this._styles[aIndex];
},
- getImageAt(aIndex) {
+ getImageAt() {
return "";
},
@@ -108,11 +108,11 @@ AutoCompleteResult.prototype = {
return this.getValueAt(aIndex);
},
- isRemovableAt(aRowIndex) {
+ isRemovableAt() {
return true;
},
- removeValueAt(aRowIndex) {},
+ removeValueAt() {},
// nsISupports implementation
QueryInterface: ChromeUtils.generateQI(["nsIAutoCompleteResult"]),
diff --git a/toolkit/components/autocomplete/tests/unit/test_393191.js b/toolkit/components/autocomplete/tests/unit/test_393191.js
index 9a0481718d..c39a7586e9 100644
--- a/toolkit/components/autocomplete/tests/unit/test_393191.js
+++ b/toolkit/components/autocomplete/tests/unit/test_393191.js
@@ -44,7 +44,7 @@ AutoCompleteInput.prototype = {
popupOpen: false,
popup: {
- setSelectedIndex(aIndex) {},
+ setSelectedIndex() {},
invalidate() {},
// nsISupports implementation
@@ -99,7 +99,7 @@ AutoCompleteResult.prototype = {
return this._styles[aIndex];
},
- getImageAt(aIndex) {
+ getImageAt() {
return "";
},
@@ -107,11 +107,11 @@ AutoCompleteResult.prototype = {
return this.getValueAt(aIndex);
},
- isRemovableAt(aRowIndex) {
+ isRemovableAt() {
return true;
},
- removeValueAt(aRowIndex) {},
+ removeValueAt() {},
// nsISupports implementation
QueryInterface: ChromeUtils.generateQI(["nsIAutoCompleteResult"]),
diff --git a/toolkit/components/autocomplete/tests/unit/test_440866.js b/toolkit/components/autocomplete/tests/unit/test_440866.js
index ef538cd931..fdc7850b28 100644
--- a/toolkit/components/autocomplete/tests/unit/test_440866.js
+++ b/toolkit/components/autocomplete/tests/unit/test_440866.js
@@ -43,7 +43,7 @@ AutoCompleteInput.prototype = {
popupOpen: false,
popup: {
- setSelectedIndex(aIndex) {},
+ setSelectedIndex() {},
invalidate() {},
// nsISupports implementation
@@ -98,7 +98,7 @@ AutoCompleteResult.prototype = {
return this._styles[aIndex];
},
- getImageAt(aIndex) {
+ getImageAt() {
return "";
},
@@ -106,11 +106,11 @@ AutoCompleteResult.prototype = {
return this.getValueAt(aIndex);
},
- isRemovableAt(aRowIndex) {
+ isRemovableAt() {
return true;
},
- removeValueAt(aRowIndex) {},
+ removeValueAt() {},
// nsISupports implementation
QueryInterface: ChromeUtils.generateQI(["nsIAutoCompleteResult"]),
diff --git a/toolkit/components/autocomplete/tests/unit/test_autocomplete_multiple.js b/toolkit/components/autocomplete/tests/unit/test_autocomplete_multiple.js
index 68885dc4ab..d94da5ae59 100644
--- a/toolkit/components/autocomplete/tests/unit/test_autocomplete_multiple.js
+++ b/toolkit/components/autocomplete/tests/unit/test_autocomplete_multiple.js
@@ -40,7 +40,7 @@ AutoCompleteInput.prototype = {
popupOpen: false,
popup: {
- setSelectedIndex(aIndex) {},
+ setSelectedIndex() {},
invalidate() {},
// nsISupports implementation
@@ -92,7 +92,7 @@ AutoCompleteResult.prototype = {
return this._styles[aIndex];
},
- getImageAt(aIndex) {
+ getImageAt() {
return "";
},
@@ -100,11 +100,11 @@ AutoCompleteResult.prototype = {
return this.getValueAt(aIndex);
},
- isRemovableAt(aRowIndex) {
+ isRemovableAt() {
return true;
},
- removeValueAt(aRowIndex) {},
+ removeValueAt() {},
// nsISupports implementation
QueryInterface: ChromeUtils.generateQI(["nsIAutoCompleteResult"]),
diff --git a/toolkit/components/autocomplete/tests/unit/test_autocomplete_userContextId.js b/toolkit/components/autocomplete/tests/unit/test_autocomplete_userContextId.js
index 4fbec408dc..6862e63ede 100644
--- a/toolkit/components/autocomplete/tests/unit/test_autocomplete_userContextId.js
+++ b/toolkit/components/autocomplete/tests/unit/test_autocomplete_userContextId.js
@@ -21,12 +21,7 @@ function doSearch(aString, aUserContextId) {
return new Promise(resolve => {
let search = new AutoCompleteSearch("test");
- search.startSearch = function (
- aSearchString,
- aSearchParam,
- aPreviousResult,
- aListener
- ) {
+ search.startSearch = function (aSearchString, aSearchParam) {
unregisterAutoCompleteSearch(search);
resolve(aSearchParam);
};
diff --git a/toolkit/components/autocomplete/tests/unit/test_immediate_search.js b/toolkit/components/autocomplete/tests/unit/test_immediate_search.js
deleted file mode 100644
index a4524ca5c9..0000000000
--- a/toolkit/components/autocomplete/tests/unit/test_immediate_search.js
+++ /dev/null
@@ -1,174 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this file,
- * You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-function AutoCompleteImmediateSearch(aName, aResult) {
- this.name = aName;
- this._result = aResult;
-}
-AutoCompleteImmediateSearch.prototype = Object.create(
- AutoCompleteSearchBase.prototype
-);
-AutoCompleteImmediateSearch.prototype.searchType =
- Ci.nsIAutoCompleteSearchDescriptor.SEARCH_TYPE_IMMEDIATE;
-AutoCompleteImmediateSearch.prototype.QueryInterface = ChromeUtils.generateQI([
- "nsIFactory",
- "nsIAutoCompleteSearch",
- "nsIAutoCompleteSearchDescriptor",
-]);
-
-function AutoCompleteDelayedSearch(aName, aResult) {
- this.name = aName;
- this._result = aResult;
-}
-AutoCompleteDelayedSearch.prototype = Object.create(
- AutoCompleteSearchBase.prototype
-);
-
-function AutoCompleteResult(aValues, aDefaultIndex) {
- this._values = aValues;
- this.defaultIndex = aDefaultIndex;
-}
-AutoCompleteResult.prototype = Object.create(AutoCompleteResultBase.prototype);
-
-/**
- * An immediate search should be executed synchronously.
- */
-add_test(function test_immediate_search() {
- let inputStr = "moz";
-
- let immediateSearch = new AutoCompleteImmediateSearch(
- "immediate",
- new AutoCompleteResult(["moz-immediate"], 0)
- );
- registerAutoCompleteSearch(immediateSearch);
- let delayedSearch = new AutoCompleteDelayedSearch(
- "delayed",
- new AutoCompleteResult(["moz-delayed"], 0)
- );
- registerAutoCompleteSearch(delayedSearch);
-
- let controller = Cc["@mozilla.org/autocomplete/controller;1"].getService(
- Ci.nsIAutoCompleteController
- );
-
- let input = new AutoCompleteInputBase([
- delayedSearch.name,
- immediateSearch.name,
- ]);
- input.completeDefaultIndex = true;
- input.textValue = inputStr;
-
- // Caret must be at the end. Autofill doesn't happen unless you're typing
- // characters at the end.
- let strLen = inputStr.length;
- input.selectTextRange(strLen, strLen);
-
- controller.input = input;
- controller.startSearch(inputStr);
-
- // Immediately check the result, the immediate search should have finished.
- Assert.equal(input.textValue, "moz-immediate");
-
- // Wait for both queries to finish.
- input.onSearchComplete = function () {
- // Sanity check.
- Assert.equal(input.textValue, "moz-immediate");
-
- unregisterAutoCompleteSearch(immediateSearch);
- unregisterAutoCompleteSearch(delayedSearch);
- run_next_test();
- };
-});
-
-/**
- * An immediate search should be executed before any delayed search.
- */
-add_test(function test_immediate_search_notimeout() {
- let inputStr = "moz";
-
- let immediateSearch = new AutoCompleteImmediateSearch(
- "immediate",
- new AutoCompleteResult(["moz-immediate"], 0)
- );
- registerAutoCompleteSearch(immediateSearch);
-
- let delayedSearch = new AutoCompleteDelayedSearch(
- "delayed",
- new AutoCompleteResult(["moz-delayed"], 0)
- );
- registerAutoCompleteSearch(delayedSearch);
-
- let controller = Cc["@mozilla.org/autocomplete/controller;1"].getService(
- Ci.nsIAutoCompleteController
- );
-
- let input = new AutoCompleteInputBase([
- delayedSearch.name,
- immediateSearch.name,
- ]);
- input.completeDefaultIndex = true;
- input.textValue = inputStr;
- input.timeout = 0;
-
- // Caret must be at the end. Autofill doesn't happen unless you're typing
- // characters at the end.
- let strLen = inputStr.length;
- input.selectTextRange(strLen, strLen);
-
- controller.input = input;
- let complete = false;
- input.onSearchComplete = function () {
- complete = true;
- };
- controller.startSearch(inputStr);
- Assert.ok(complete);
-
- // Immediately check the result, the immediate search should have finished.
- Assert.equal(input.textValue, "moz-immediate");
-
- unregisterAutoCompleteSearch(immediateSearch);
- unregisterAutoCompleteSearch(delayedSearch);
- run_next_test();
-});
-
-/**
- * A delayed search should be executed synchronously with a zero timeout.
- */
-add_test(function test_delayed_search_notimeout() {
- let inputStr = "moz";
-
- let delayedSearch = new AutoCompleteDelayedSearch(
- "delayed",
- new AutoCompleteResult(["moz-delayed"], 0)
- );
- registerAutoCompleteSearch(delayedSearch);
-
- let controller = Cc["@mozilla.org/autocomplete/controller;1"].getService(
- Ci.nsIAutoCompleteController
- );
-
- let input = new AutoCompleteInputBase([delayedSearch.name]);
- input.completeDefaultIndex = true;
- input.textValue = inputStr;
- input.timeout = 0;
-
- // Caret must be at the end. Autofill doesn't happen unless you're typing
- // characters at the end.
- let strLen = inputStr.length;
- input.selectTextRange(strLen, strLen);
-
- controller.input = input;
- let complete = false;
- input.onSearchComplete = function () {
- complete = true;
- };
- controller.startSearch(inputStr);
- Assert.ok(complete);
-
- // Immediately check the result, the delayed search should have finished.
- Assert.equal(input.textValue, "moz-delayed");
-
- unregisterAutoCompleteSearch(delayedSearch);
- run_next_test();
-});
diff --git a/toolkit/components/autocomplete/tests/unit/test_previousResult.js b/toolkit/components/autocomplete/tests/unit/test_previousResult.js
index 85db3f08c5..e015ff481e 100644
--- a/toolkit/components/autocomplete/tests/unit/test_previousResult.js
+++ b/toolkit/components/autocomplete/tests/unit/test_previousResult.js
@@ -45,7 +45,7 @@ AutoCompleteInput.prototype = {
popupOpen: false,
popup: {
- setSelectedIndex(aIndex) {},
+ setSelectedIndex() {},
invalidate() {},
// nsISupports implementation
@@ -100,7 +100,7 @@ AutoCompleteResult.prototype = {
return this._styles[aIndex];
},
- getImageAt(aIndex) {
+ getImageAt() {
return "";
},
@@ -108,11 +108,11 @@ AutoCompleteResult.prototype = {
return this.getValueAt(aIndex);
},
- isRemovableAt(aRowIndex) {
+ isRemovableAt() {
return true;
},
- removeValueAt(aRowIndex) {},
+ removeValueAt() {},
// nsISupports implementation
QueryInterface: ChromeUtils.generateQI(["nsIAutoCompleteResult"]),
diff --git a/toolkit/components/autocomplete/tests/unit/test_search_zerotimeout.js b/toolkit/components/autocomplete/tests/unit/test_search_zerotimeout.js
new file mode 100644
index 0000000000..a5a0f9aa0f
--- /dev/null
+++ b/toolkit/components/autocomplete/tests/unit/test_search_zerotimeout.js
@@ -0,0 +1,58 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+function AutoCompleteDelayedSearch(aName, aResult) {
+ this.name = aName;
+ this._result = aResult;
+}
+AutoCompleteDelayedSearch.prototype = Object.create(
+ AutoCompleteSearchBase.prototype
+);
+
+function AutoCompleteResult(aValues, aDefaultIndex) {
+ this._values = aValues;
+ this.defaultIndex = aDefaultIndex;
+}
+AutoCompleteResult.prototype = Object.create(AutoCompleteResultBase.prototype);
+
+/**
+ * A delayed search should be executed synchronously with a zero timeout.
+ */
+add_test(function test_delayed_search_notimeout() {
+ let inputStr = "moz";
+
+ let delayedSearch = new AutoCompleteDelayedSearch(
+ "delayed",
+ new AutoCompleteResult(["moz-delayed"], 0)
+ );
+ registerAutoCompleteSearch(delayedSearch);
+
+ let controller = Cc["@mozilla.org/autocomplete/controller;1"].getService(
+ Ci.nsIAutoCompleteController
+ );
+
+ let input = new AutoCompleteInputBase([delayedSearch.name]);
+ input.completeDefaultIndex = true;
+ input.textValue = inputStr;
+ input.timeout = 0;
+
+ // Caret must be at the end. Autofill doesn't happen unless you're typing
+ // characters at the end.
+ let strLen = inputStr.length;
+ input.selectTextRange(strLen, strLen);
+
+ controller.input = input;
+ let complete = false;
+ input.onSearchComplete = function () {
+ complete = true;
+ };
+ controller.startSearch(inputStr);
+ Assert.ok(complete);
+
+ // Immediately check the result, the delayed search should have finished.
+ Assert.equal(input.textValue, "moz-delayed");
+
+ unregisterAutoCompleteSearch(delayedSearch);
+ run_next_test();
+});
diff --git a/toolkit/components/autocomplete/tests/unit/test_stopSearch.js b/toolkit/components/autocomplete/tests/unit/test_stopSearch.js
index aecf572df0..01bd67d63b 100644
--- a/toolkit/components/autocomplete/tests/unit/test_stopSearch.js
+++ b/toolkit/components/autocomplete/tests/unit/test_stopSearch.js
@@ -60,7 +60,7 @@ function AutoCompleteSearch(aName) {
AutoCompleteSearch.prototype = {
constructor: AutoCompleteSearch,
stopSearchInvoked: true,
- startSearch(aSearchString, aSearchParam, aPreviousResult, aListener) {
+ startSearch() {
info("Check stop search has been called");
Assert.ok(this.stopSearchInvoked);
this.stopSearchInvoked = false;
diff --git a/toolkit/components/autocomplete/tests/unit/xpcshell.toml b/toolkit/components/autocomplete/tests/unit/xpcshell.toml
index 00d238cdf7..0c2e12495e 100644
--- a/toolkit/components/autocomplete/tests/unit/xpcshell.toml
+++ b/toolkit/components/autocomplete/tests/unit/xpcshell.toml
@@ -33,12 +33,12 @@ head = "head_autocomplete.js"
["test_finalDefaultCompleteValue.js"]
-["test_immediate_search.js"]
-
["test_insertMatchAt.js"]
["test_previousResult.js"]
["test_removeMatchAt.js"]
+["test_search_zerotimeout.js"]
+
["test_stopSearch.js"]