summaryrefslogtreecommitdiffstats
path: root/toolkit/components/satchel/test
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/components/satchel/test')
-rw-r--r--toolkit/components/satchel/test/browser/browser.toml11
-rw-r--r--toolkit/components/satchel/test/browser/browser_autocomplete.js403
-rw-r--r--toolkit/components/satchel/test/browser/browser_popup_mouseover.js8
-rw-r--r--toolkit/components/satchel/test/browser/formhistory_autocomplete.sqlitebin0 -> 72704 bytes
-rw-r--r--toolkit/components/satchel/test/unit/test_autocomplete.js388
-rw-r--r--toolkit/components/satchel/test/unit/test_previous_result.js25
-rw-r--r--toolkit/components/satchel/test/unit/xpcshell.toml15
7 files changed, 428 insertions, 422 deletions
diff --git a/toolkit/components/satchel/test/browser/browser.toml b/toolkit/components/satchel/test/browser/browser.toml
index 7207c27f34..d70757f983 100644
--- a/toolkit/components/satchel/test/browser/browser.toml
+++ b/toolkit/components/satchel/test/browser/browser.toml
@@ -1,10 +1,19 @@
[DEFAULT]
-support-files = ["!/toolkit/components/satchel/test/subtst_privbrowsing.html"]
+support-files = [
+ "!/toolkit/components/satchel/test/subtst_privbrowsing.html",
+ "formhistory_autocomplete.sqlite",
+]
+
+["browser_autocomplete.js"]
+lineno = "7"
["browser_close_tab.js"]
+lineno = "10"
["browser_popup_mouseover.js"]
skip-if = ["verify"]
+lineno = "13"
["browser_privbrowsing_perwindowpb.js"]
skip-if = ["verify"]
+lineno = "17"
diff --git a/toolkit/components/satchel/test/browser/browser_autocomplete.js b/toolkit/components/satchel/test/browser/browser_autocomplete.js
new file mode 100644
index 0000000000..808833187b
--- /dev/null
+++ b/toolkit/components/satchel/test/browser/browser_autocomplete.js
@@ -0,0 +1,403 @@
+/* Any copyright is dedicated to the Public Domain.
+ https://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const { FormHistory } = ChromeUtils.importESModule(
+ "resource://gre/modules/FormHistory.sys.mjs"
+);
+
+function padLeft(number, length) {
+ let str = number + "";
+ while (str.length < length) {
+ str = "0" + str;
+ }
+ return str;
+}
+
+function getFormExpiryDays() {
+ if (Services.prefs.prefHasUserValue("browser.formfill.expire_days")) {
+ return Services.prefs.getIntPref("browser.formfill.expire_days");
+ }
+ return DEFAULT_EXPIRE_DAYS;
+}
+
+async function countEntries(name, value) {
+ let obj = {};
+ if (name) {
+ obj.fieldname = name;
+ }
+ if (value) {
+ obj.value = value;
+ }
+
+ return await FormHistory.count(obj);
+}
+
+const DEFAULT_EXPIRE_DAYS = 180;
+let gTimeGroupingSize;
+let gNumRecords;
+let gNow;
+
+add_setup(async function () {
+ gTimeGroupingSize =
+ Services.prefs.getIntPref("browser.formfill.timeGroupingSize") *
+ 1000 *
+ 1000;
+
+ const maxTimeGroupings = Services.prefs.getIntPref(
+ "browser.formfill.maxTimeGroupings"
+ );
+ const bucketSize = Services.prefs.getIntPref("browser.formfill.bucketSize");
+
+ // ===== Tests with constant timesUsed and varying lastUsed date =====
+ // insert 2 records per bucket to check alphabetical sort within
+ gNow = 1000 * Date.now();
+ gNumRecords = Math.ceil(maxTimeGroupings / bucketSize) * 2;
+
+ let changes = [];
+ for (let i = 0; i < gNumRecords; i += 2) {
+ let useDate = gNow - (i / 2) * bucketSize * gTimeGroupingSize;
+
+ changes.push({
+ op: "add",
+ fieldname: "field1",
+ value: "value" + padLeft(gNumRecords - 1 - i, 2),
+ timesUsed: 1,
+ firstUsed: useDate,
+ lastUsed: useDate,
+ });
+ changes.push({
+ op: "add",
+ fieldname: "field1",
+ value: "value" + padLeft(gNumRecords - 2 - i, 2),
+ timesUsed: 1,
+ firstUsed: useDate,
+ lastUsed: useDate,
+ });
+ }
+
+ await FormHistory.update(changes);
+
+ Assert.ok(
+ (await countEntries("field1", null)) > 0,
+ "Check initial state is as expected"
+ );
+
+ registerCleanupFunction(async () => {
+ await FormHistory.update([
+ {
+ op: "remove",
+ firstUsedStart: 0,
+ },
+ ]);
+ });
+});
+
+async function focusAndWaitForPopupOpen(browser) {
+ await SpecialPowers.spawn(browser, [], async function () {
+ const input = content.document.querySelector("input");
+ input.focus();
+ });
+
+ await BrowserTestUtils.synthesizeKey("VK_DOWN", {}, browser);
+
+ await BrowserTestUtils.waitForCondition(() => {
+ return browser.autoCompletePopup.popupOpen;
+ });
+}
+
+async function unfocusAndWaitForPopupClose(browser) {
+ await SpecialPowers.spawn(browser, [], async function () {
+ const input = content.document.querySelector("input");
+ input.blur();
+ });
+
+ await BrowserTestUtils.waitForCondition(() => {
+ return !browser.autoCompletePopup.popupOpen;
+ });
+}
+
+add_task(async function test_search_contains_all_entries() {
+ const url = `data:text/html,<input type="text" name="field1">`;
+ await BrowserTestUtils.withNewTab(
+ { gBrowser, url },
+ async function (browser) {
+ const { autoCompletePopup } = browser;
+
+ await focusAndWaitForPopupOpen(browser);
+
+ Assert.equal(
+ gNumRecords,
+ autoCompletePopup.matchCount,
+ "Check search contains all entries"
+ );
+
+ info("Check search result ordering with empty search term");
+ let lastFound = gNumRecords;
+ for (let i = 0; i < gNumRecords; i += 2) {
+ Assert.equal(
+ parseInt(autoCompletePopup.view.getValueAt(i + 1).substr(5), 10),
+ --lastFound
+ );
+ Assert.equal(
+ parseInt(autoCompletePopup.view.getValueAt(i).substr(5), 10),
+ --lastFound
+ );
+ }
+
+ await unfocusAndWaitForPopupClose(browser);
+ await SpecialPowers.spawn(browser, [], async function () {
+ content.document.querySelector("input").setUserInput("v");
+ });
+
+ await focusAndWaitForPopupOpen(browser);
+
+ info('Check search result ordering with "v"');
+ lastFound = gNumRecords;
+ for (let i = 0; i < gNumRecords; i += 2) {
+ Assert.equal(
+ parseInt(autoCompletePopup.view.getValueAt(i + 1).substr(5), 10),
+ --lastFound
+ );
+ Assert.equal(
+ parseInt(autoCompletePopup.view.getValueAt(i).substr(5), 10),
+ --lastFound
+ );
+ }
+ }
+ );
+});
+
+add_task(async function test_times_used_samples() {
+ info("Begin tests with constant use dates and varying timesUsed");
+
+ const timesUsedSamples = 20;
+
+ let changes = [];
+ for (let i = 0; i < timesUsedSamples; i++) {
+ let timesUsed = timesUsedSamples - i;
+ let change = {
+ op: "add",
+ fieldname: "field2",
+ value: "value" + (timesUsedSamples - 1 - i),
+ timesUsed: timesUsed * gTimeGroupingSize,
+ firstUsed: gNow,
+ lastUsed: gNow,
+ };
+ changes.push(change);
+ }
+ await FormHistory.update(changes);
+
+ const url = `data:text/html,<input type="text" name="field2">`;
+ await BrowserTestUtils.withNewTab(
+ { gBrowser, url },
+ async function (browser) {
+ await focusAndWaitForPopupOpen(browser);
+
+ info("Check search result ordering with empty search term");
+ let lastFound = timesUsedSamples;
+ for (let i = 0; i < timesUsedSamples; i++) {
+ Assert.equal(
+ parseInt(browser.autoCompletePopup.view.getValueAt(i).substr(5), 10),
+ --lastFound
+ );
+ }
+
+ await unfocusAndWaitForPopupClose(browser);
+ await SpecialPowers.spawn(browser, [], async function () {
+ content.document.querySelector("input").setUserInput("v");
+ });
+ await focusAndWaitForPopupOpen(browser);
+
+ info('Check search result ordering with "v"');
+ lastFound = timesUsedSamples;
+ for (let i = 0; i < timesUsedSamples; i++) {
+ Assert.equal(
+ parseInt(browser.autoCompletePopup.view.getValueAt(i).substr(5), 10),
+ --lastFound
+ );
+ }
+ }
+ );
+});
+
+add_task(async function test_age_bonus() {
+ info(
+ 'Check that "senior citizen" entries get a bonus (browser.formfill.agedBonus)'
+ );
+
+ const agedDate =
+ 1000 * (Date.now() - getFormExpiryDays() * 24 * 60 * 60 * 1000);
+
+ let changes = [];
+ changes.push({
+ op: "add",
+ fieldname: "field3",
+ value: "old but not senior",
+ timesUsed: 100,
+ firstUsed: agedDate + 60 * 1000 * 1000,
+ lastUsed: gNow,
+ });
+ changes.push({
+ op: "add",
+ fieldname: "field3",
+ value: "senior citizen",
+ timesUsed: 100,
+ firstUsed: agedDate - 60 * 1000 * 1000,
+ lastUsed: gNow,
+ });
+ await FormHistory.update(changes);
+
+ const url = `data:text/html,<input type="text" name="field3">`;
+ await BrowserTestUtils.withNewTab(
+ { gBrowser, url },
+ async function (browser) {
+ const { autoCompletePopup } = browser;
+
+ await focusAndWaitForPopupOpen(browser);
+
+ Assert.equal(autoCompletePopup.view.getValueAt(0), "senior citizen");
+ Assert.equal(autoCompletePopup.view.getValueAt(1), "old but not senior");
+ }
+ );
+});
+
+add_task(async function test_search_entry_past_future() {
+ info("Check entries that are really old or in the future");
+
+ let changes = [];
+ changes.push({
+ op: "add",
+ fieldname: "field4",
+ value: "date of 0",
+ timesUsed: 1,
+ firstUsed: 0,
+ lastUsed: 0,
+ });
+ changes.push({
+ op: "add",
+ fieldname: "field4",
+ value: "in the future 1",
+ timesUsed: 1,
+ firstUsed: 0,
+ lastUsed: gNow * 2,
+ });
+ changes.push({
+ op: "add",
+ fieldname: "field4",
+ value: "in the future 2",
+ timesUsed: 1,
+ firstUsed: gNow * 2,
+ lastUsed: gNow * 2,
+ });
+
+ await FormHistory.update(changes);
+
+ const url = `data:text/html,<input type="text" name="field4">`;
+ await BrowserTestUtils.withNewTab(
+ { gBrowser, url },
+ async function (browser) {
+ await focusAndWaitForPopupOpen(browser);
+
+ Assert.equal(browser.autoCompletePopup.matchCount, 3);
+ }
+ );
+});
+
+add_task(async function test_old_synchronous_api() {
+ info("Check old synchronous api");
+
+ const syncValues = ["sync1", "sync1a", "sync2", "sync3"];
+ let changes = [];
+ for (const value of syncValues) {
+ changes.push({ op: "add", fieldname: "field5", value });
+ }
+ await FormHistory.update(changes);
+});
+
+add_task(async function test_token_limit_db() {
+ let changes = [];
+ changes.push({
+ op: "add",
+ fieldname: "field6",
+ // value with 15 unique tokens
+ value: "a b c d e f g h i j k l m n o",
+ timesUsed: 1,
+ firstUsed: 0,
+ lastUsed: 0,
+ });
+ changes.push({
+ op: "add",
+ fieldname: "field6",
+ value: "a b c d e f g h i j .",
+ timesUsed: 1,
+ firstUsed: 0,
+ lastUsed: gNow * 2,
+ });
+
+ await FormHistory.update(changes);
+
+ const url = `data:text/html,<input type="text" name="field6">`;
+ await BrowserTestUtils.withNewTab(
+ { gBrowser, url },
+ async function (browser) {
+ info(
+ "Check that the number of tokens used in a search is capped to MAX_SEARCH_TOKENS for performance when querying the DB"
+ );
+
+ await SpecialPowers.spawn(browser, [], async function () {
+ const input = content.document.querySelector("input[name=field6]");
+ input.setUserInput("a b c d e f g h i j .");
+ });
+
+ await focusAndWaitForPopupOpen(browser);
+
+ Assert.equal(
+ browser.autoCompletePopup.matchCount,
+ 2,
+ "Only the first MAX_SEARCH_TOKENS tokens should be used for DB queries"
+ );
+
+ await unfocusAndWaitForPopupClose(browser);
+
+ info(
+ "Check that the number of tokens used in a search is not capped to MAX_SEARCH_TOKENS when using a previousResult"
+ );
+
+ await focusAndWaitForPopupOpen(browser);
+
+ Assert.equal(
+ browser.autoCompletePopup.matchCount,
+ 1,
+ "All search tokens should be used with previous results"
+ );
+ }
+ );
+});
+
+add_task(async function test_can_search_escape_marker() {
+ await FormHistory.update({
+ op: "add",
+ fieldname: "field7",
+ value: "/* Further reading */ test",
+ timesUsed: 1,
+ firstUsed: gNow,
+ lastUsed: gNow,
+ });
+
+ const url = `data:text/html,<input type="text" name="field7">`;
+ await BrowserTestUtils.withNewTab(
+ { gBrowser, url },
+ async function (browser) {
+ await SpecialPowers.spawn(browser, [], async function () {
+ const input = content.document.querySelector("input");
+ input.setUserInput("/* Further reading */ t");
+ });
+
+ await focusAndWaitForPopupOpen(browser);
+
+ Assert.equal(browser.autoCompletePopup.matchCount, 1);
+ }
+ );
+});
diff --git a/toolkit/components/satchel/test/browser/browser_popup_mouseover.js b/toolkit/components/satchel/test/browser/browser_popup_mouseover.js
index 2b293ab983..3b18e814f2 100644
--- a/toolkit/components/satchel/test/browser/browser_popup_mouseover.js
+++ b/toolkit/components/satchel/test/browser/browser_popup_mouseover.js
@@ -34,11 +34,8 @@ add_task(async function test() {
await BrowserTestUtils.waitForCondition(() => {
return autoCompletePopup.popupOpen;
});
- const listItemElems = itemsBox.querySelectorAll(
- ".autocomplete-richlistitem"
- );
Assert.equal(
- listItemElems.length,
+ autoCompletePopup.matchCount,
mockHistory.length,
"ensure result length"
);
@@ -57,6 +54,9 @@ add_task(async function test() {
);
// mouseover the second item
+ const listItemElems = itemsBox.querySelectorAll(
+ ".autocomplete-richlistitem"
+ );
EventUtils.synthesizeMouseAtCenter(listItemElems[1], {
type: "mouseover",
});
diff --git a/toolkit/components/satchel/test/browser/formhistory_autocomplete.sqlite b/toolkit/components/satchel/test/browser/formhistory_autocomplete.sqlite
new file mode 100644
index 0000000000..724cff73f6
--- /dev/null
+++ b/toolkit/components/satchel/test/browser/formhistory_autocomplete.sqlite
Binary files differ
diff --git a/toolkit/components/satchel/test/unit/test_autocomplete.js b/toolkit/components/satchel/test/unit/test_autocomplete.js
deleted file mode 100644
index e64d34ea50..0000000000
--- a/toolkit/components/satchel/test/unit/test_autocomplete.js
+++ /dev/null
@@ -1,388 +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/. */
-
-"use strict";
-
-var fac;
-
-var numRecords, timeGroupingSize, now;
-
-const DEFAULT_EXPIRE_DAYS = 180;
-
-function padLeft(number, length) {
- let str = number + "";
- while (str.length < length) {
- str = "0" + str;
- }
- return str;
-}
-
-function getFormExpiryDays() {
- if (Services.prefs.prefHasUserValue("browser.formfill.expire_days")) {
- return Services.prefs.getIntPref("browser.formfill.expire_days");
- }
- return DEFAULT_EXPIRE_DAYS;
-}
-
-function run_test() {
- // ===== test init =====
- let testfile = do_get_file("formhistory_autocomplete.sqlite");
- let profileDir = Services.dirsvc.get("ProfD", Ci.nsIFile);
-
- // Cleanup from any previous tests or failures.
- let destFile = profileDir.clone();
- destFile.append("formhistory.sqlite");
- if (destFile.exists()) {
- destFile.remove(false);
- }
-
- testfile.copyTo(profileDir, "formhistory.sqlite");
-
- fac = Cc["@mozilla.org/satchel/form-history-autocomplete;1"].getService(
- Ci.nsIFormHistoryAutoComplete
- );
-
- timeGroupingSize =
- Services.prefs.getIntPref("browser.formfill.timeGroupingSize") *
- 1000 *
- 1000;
-
- run_next_test();
-}
-
-add_test(function test0() {
- let maxTimeGroupings = Services.prefs.getIntPref(
- "browser.formfill.maxTimeGroupings"
- );
- let bucketSize = Services.prefs.getIntPref("browser.formfill.bucketSize");
-
- // ===== Tests with constant timesUsed and varying lastUsed date =====
- // insert 2 records per bucket to check alphabetical sort within
- now = 1000 * Date.now();
- numRecords = Math.ceil(maxTimeGroupings / bucketSize) * 2;
-
- let changes = [];
- for (let i = 0; i < numRecords; i += 2) {
- let useDate = now - (i / 2) * bucketSize * timeGroupingSize;
-
- changes.push({
- op: "add",
- fieldname: "field1",
- value: "value" + padLeft(numRecords - 1 - i, 2),
- timesUsed: 1,
- firstUsed: useDate,
- lastUsed: useDate,
- });
- changes.push({
- op: "add",
- fieldname: "field1",
- value: "value" + padLeft(numRecords - 2 - i, 2),
- timesUsed: 1,
- firstUsed: useDate,
- lastUsed: useDate,
- });
- }
-
- updateFormHistory(changes, run_next_test);
-});
-
-add_test(function test1() {
- do_log_info("Check initial state is as expected");
-
- countEntries(null, null, function () {
- countEntries("field1", null, function (count) {
- Assert.ok(count > 0);
- run_next_test();
- });
- });
-});
-
-add_test(function test2() {
- do_log_info("Check search contains all entries");
-
- fac.autoCompleteSearchAsync("field1", "", null, null, false, {
- onSearchCompletion(aResults) {
- Assert.equal(numRecords, aResults.matchCount);
- run_next_test();
- },
- });
-});
-
-add_test(function test3() {
- do_log_info("Check search result ordering with empty search term");
-
- let lastFound = numRecords;
- fac.autoCompleteSearchAsync("field1", "", null, null, false, {
- onSearchCompletion(aResults) {
- for (let i = 0; i < numRecords; i += 2) {
- Assert.equal(
- parseInt(aResults.getValueAt(i + 1).substr(5), 10),
- --lastFound
- );
- Assert.equal(
- parseInt(aResults.getValueAt(i).substr(5), 10),
- --lastFound
- );
- }
- run_next_test();
- },
- });
-});
-
-add_test(function test4() {
- do_log_info('Check search result ordering with "v"');
-
- let lastFound = numRecords;
- fac.autoCompleteSearchAsync("field1", "v", null, null, false, {
- onSearchCompletion(aResults) {
- for (let i = 0; i < numRecords; i += 2) {
- Assert.equal(
- parseInt(aResults.getValueAt(i + 1).substr(5), 10),
- --lastFound
- );
- Assert.equal(
- parseInt(aResults.getValueAt(i).substr(5), 10),
- --lastFound
- );
- }
- run_next_test();
- },
- });
-});
-
-const timesUsedSamples = 20;
-
-add_test(function test5() {
- do_log_info("Begin tests with constant use dates and varying timesUsed");
-
- let changes = [];
- for (let i = 0; i < timesUsedSamples; i++) {
- let timesUsed = timesUsedSamples - i;
- let change = {
- op: "add",
- fieldname: "field2",
- value: "value" + (timesUsedSamples - 1 - i),
- timesUsed: timesUsed * timeGroupingSize,
- firstUsed: now,
- lastUsed: now,
- };
- changes.push(change);
- }
- updateFormHistory(changes, run_next_test);
-});
-
-add_test(function test6() {
- do_log_info("Check search result ordering with empty search term");
-
- let lastFound = timesUsedSamples;
- fac.autoCompleteSearchAsync("field2", "", null, null, false, {
- onSearchCompletion(aResults) {
- for (let i = 0; i < timesUsedSamples; i++) {
- Assert.equal(
- parseInt(aResults.getValueAt(i).substr(5), 10),
- --lastFound
- );
- }
- run_next_test();
- },
- });
-});
-
-add_test(function test7() {
- do_log_info('Check search result ordering with "v"');
-
- let lastFound = timesUsedSamples;
- fac.autoCompleteSearchAsync("field2", "v", null, null, false, {
- onSearchCompletion(aResults) {
- for (let i = 0; i < timesUsedSamples; i++) {
- Assert.equal(
- parseInt(aResults.getValueAt(i).substr(5), 10),
- --lastFound
- );
- }
- run_next_test();
- },
- });
-});
-
-add_test(function test8() {
- do_log_info(
- 'Check that "senior citizen" entries get a bonus (browser.formfill.agedBonus)'
- );
-
- let agedDate =
- 1000 * (Date.now() - getFormExpiryDays() * 24 * 60 * 60 * 1000);
-
- let changes = [];
- changes.push({
- op: "add",
- fieldname: "field3",
- value: "old but not senior",
- timesUsed: 100,
- firstUsed: agedDate + 60 * 1000 * 1000,
- lastUsed: now,
- });
- changes.push({
- op: "add",
- fieldname: "field3",
- value: "senior citizen",
- timesUsed: 100,
- firstUsed: agedDate - 60 * 1000 * 1000,
- lastUsed: now,
- });
- updateFormHistory(changes, run_next_test);
-});
-
-add_test(function test9() {
- fac.autoCompleteSearchAsync("field3", "", null, null, false, {
- onSearchCompletion(aResults) {
- Assert.equal(aResults.getValueAt(0), "senior citizen");
- Assert.equal(aResults.getValueAt(1), "old but not senior");
- run_next_test();
- },
- });
-});
-
-add_test(function test10() {
- do_log_info("Check entries that are really old or in the future");
-
- let changes = [];
- changes.push({
- op: "add",
- fieldname: "field4",
- value: "date of 0",
- timesUsed: 1,
- firstUsed: 0,
- lastUsed: 0,
- });
- changes.push({
- op: "add",
- fieldname: "field4",
- value: "in the future 1",
- timesUsed: 1,
- firstUsed: 0,
- lastUsed: now * 2,
- });
- changes.push({
- op: "add",
- fieldname: "field4",
- value: "in the future 2",
- timesUsed: 1,
- firstUsed: now * 2,
- lastUsed: now * 2,
- });
- updateFormHistory(changes, run_next_test);
-});
-
-add_test(function test11() {
- fac.autoCompleteSearchAsync("field4", "", null, null, false, {
- onSearchCompletion(aResults) {
- Assert.equal(aResults.matchCount, 3);
- run_next_test();
- },
- });
-});
-
-var syncValues = ["sync1", "sync1a", "sync2", "sync3"];
-
-add_test(function test12() {
- do_log_info("Check old synchronous api");
-
- let changes = [];
- for (let value of syncValues) {
- changes.push({ op: "add", fieldname: "field5", value });
- }
- updateFormHistory(changes, run_next_test);
-});
-
-add_test(function test_token_limit_DB() {
- function test_token_limit_previousResult(previousResult) {
- do_log_info(
- "Check that the number of tokens used in a search is not capped to " +
- "MAX_SEARCH_TOKENS when using a previousResult"
- );
- // This provide more accuracy since performance is less of an issue.
- // Search for a string where the first 10 tokens match the previous value but the 11th does not
- // when re-using a previous result.
- fac.autoCompleteSearchAsync(
- "field_token_cap",
- "a b c d e f g h i j .",
- null,
- previousResult,
- false,
- {
- onSearchCompletion(aResults) {
- Assert.equal(
- aResults.matchCount,
- 0,
- "All search tokens should be used with previous results"
- );
- run_next_test();
- },
- }
- );
- }
-
- do_log_info(
- "Check that the number of tokens used in a search is capped to MAX_SEARCH_TOKENS " +
- "for performance when querying the DB"
- );
- let changes = [];
- changes.push({
- op: "add",
- fieldname: "field_token_cap",
- // value with 15 unique tokens
- value: "a b c d e f g h i j k l m n o",
- timesUsed: 1,
- firstUsed: 0,
- lastUsed: 0,
- });
- updateFormHistory(changes, () => {
- // Search for a string where the first 10 tokens match the value above but the 11th does not
- // (which would prevent the result from being returned if the 11th term was used).
- fac.autoCompleteSearchAsync(
- "field_token_cap",
- "a b c d e f g h i j .",
- null,
- null,
- false,
- {
- onSearchCompletion(aResults) {
- Assert.equal(
- aResults.matchCount,
- 1,
- "Only the first MAX_SEARCH_TOKENS tokens " +
- "should be used for DB queries"
- );
- test_token_limit_previousResult(aResults);
- },
- }
- );
- });
-});
-
-add_test(async function can_search_escape_marker() {
- await promiseUpdate({
- op: "add",
- fieldname: "field1",
- value: "/* Further reading */ test",
- timesUsed: 1,
- firstUsed: now,
- lastUsed: now,
- });
-
- fac.autoCompleteSearchAsync(
- "field1",
- "/* Further reading */ t",
- null,
- null,
- false,
- {
- onSearchCompletion(aResults) {
- Assert.equal(1, aResults.matchCount);
- run_next_test();
- },
- }
- );
-});
diff --git a/toolkit/components/satchel/test/unit/test_previous_result.js b/toolkit/components/satchel/test/unit/test_previous_result.js
deleted file mode 100644
index a782832db7..0000000000
--- a/toolkit/components/satchel/test/unit/test_previous_result.js
+++ /dev/null
@@ -1,25 +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/. */
-
-var aaaListener = {
- onSearchResult(search, result) {
- Assert.equal(result.searchString, "aaa");
- do_test_finished();
- },
-};
-
-var aaListener = {
- onSearchResult(search, result) {
- Assert.equal(result.searchString, "aa");
- search.startSearch("aaa", "", result, aaaListener);
- },
-};
-
-function run_test() {
- do_test_pending();
- let search = Cc[
- "@mozilla.org/autocomplete/search;1?name=form-history"
- ].getService(Ci.nsIAutoCompleteSearch);
- search.startSearch("aa", "", null, aaListener);
-}
diff --git a/toolkit/components/satchel/test/unit/xpcshell.toml b/toolkit/components/satchel/test/unit/xpcshell.toml
index 68a379e74d..0151f9252c 100644
--- a/toolkit/components/satchel/test/unit/xpcshell.toml
+++ b/toolkit/components/satchel/test/unit/xpcshell.toml
@@ -15,29 +15,36 @@ support-files = [
]
["test_async_expire.js"]
-
-["test_autocomplete.js"]
+lineno = "17"
["test_db_access_denied.js"]
skip-if = ["os != 'linux'"] # simulates insufficiant file permissions
+lineno = "20"
["test_db_corrupt.js"]
+lineno = "24"
["test_db_update_v4.js"]
+lineno = "27"
["test_db_update_v4b.js"]
+lineno = "30"
["test_db_update_v5.js"]
skip-if = ["condprof"] # Bug 1769154 - not supported
+lineno = "33"
["test_db_update_v999a.js"]
+lineno = "37"
["test_db_update_v999b.js"]
+lineno = "40"
["test_history_api.js"]
+lineno = "43"
["test_history_sources.js"]
+lineno = "46"
["test_notify.js"]
-
-["test_previous_result.js"]
+lineno = "49"