summaryrefslogtreecommitdiffstats
path: root/toolkit/components/satchel
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:33 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:33 +0000
commit086c044dc34dfc0f74fbe41f4ecb402b2cd34884 (patch)
treea4f824bd33cb075dd5aa3eb5a0a94af221bbe83a /toolkit/components/satchel
parentAdding debian version 124.0.1-1. (diff)
downloadfirefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.tar.xz
firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.zip
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/satchel')
-rw-r--r--toolkit/components/satchel/FormHandlerChild.sys.mjs72
-rw-r--r--toolkit/components/satchel/FormHistoryChild.sys.mjs7
-rw-r--r--toolkit/components/satchel/FormHistoryStartup.sys.mjs2
-rw-r--r--toolkit/components/satchel/moz.build1
-rw-r--r--toolkit/components/satchel/nsFormFillController.cpp2
-rw-r--r--toolkit/components/satchel/test/browser/browser_close_tab.js5
-rw-r--r--toolkit/components/satchel/test/browser/browser_privbrowsing_perwindowpb.js2
-rw-r--r--toolkit/components/satchel/test/test_form_submission.html16
-rw-r--r--toolkit/components/satchel/test/test_popup_enter_event.html4
-rw-r--r--toolkit/components/satchel/test/unit/test_db_corrupt.js2
10 files changed, 92 insertions, 21 deletions
diff --git a/toolkit/components/satchel/FormHandlerChild.sys.mjs b/toolkit/components/satchel/FormHandlerChild.sys.mjs
new file mode 100644
index 0000000000..6b1af3dbc3
--- /dev/null
+++ b/toolkit/components/satchel/FormHandlerChild.sys.mjs
@@ -0,0 +1,72 @@
+/* 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/. */
+
+/**
+ * The FormHandlerChild is the place to implement logic that is shared
+ * by child actors like FormAutofillChild, LoginManagerChild and FormHistoryChild
+ * or in general components that deal with form data.
+ */
+
+export const FORM_SUBMISSION_REASON = {
+ FORM_SUBMIT_EVENT: "form-submit-event",
+ FORM_REMOVAL_AFTER_FETCH: "form-removal-after-fetch",
+ IFRAME_PAGEHIDE: "iframe-pagehide",
+ PAGE_NAVIGATION: "page-navigation",
+};
+
+export class FormHandlerChild extends JSWindowActorChild {
+ handleEvent(event) {
+ if (!event.isTrusted) {
+ return;
+ }
+ switch (event.type) {
+ case "DOMFormBeforeSubmit":
+ this.processDOMFormBeforeSubmitEvent(event);
+ break;
+ default:
+ throw new Error("Unexpected event type");
+ }
+ }
+
+ /**
+ * Process the DOMFormBeforeSubmitEvent that is dispatched
+ * after a form submit event. Extract event data
+ * that is relevant to the form submission listeners
+ *
+ * @param {Event} event DOMFormBeforeSubmit
+ */
+ processDOMFormBeforeSubmitEvent(event) {
+ const form = event.target;
+ const formSubmissionReason = FORM_SUBMISSION_REASON.FORM_SUBMIT_EVENT;
+
+ this.#dispatchFormSubmissionEvent(form, formSubmissionReason);
+ }
+
+ // handle form-removal-after-fetch
+ processFormRemovalAfterFetch(params) {}
+
+ // handle iframe-pagehide
+ processIframePagehide(params) {}
+
+ // handle page-navigation
+ processPageNavigation(params) {}
+
+ /**
+ * Dispatch the CustomEvent form-submission-detected also transfer
+ * the information:
+ * detail.form - the form that is being submitted
+ * detail.reason - the heuristic that detected the form submission
+ * (see FORM_SUBMISSION_REASON)
+ *
+ * @param {HTMLFormElement} form
+ * @param {string} reason
+ */
+ #dispatchFormSubmissionEvent(form, reason) {
+ const formSubmissionEvent = new CustomEvent("form-submission-detected", {
+ detail: { form, reason },
+ bubbles: true,
+ });
+ this.document.dispatchEvent(formSubmissionEvent);
+ }
+}
diff --git a/toolkit/components/satchel/FormHistoryChild.sys.mjs b/toolkit/components/satchel/FormHistoryChild.sys.mjs
index 242d8f2e29..e97b5238e8 100644
--- a/toolkit/components/satchel/FormHistoryChild.sys.mjs
+++ b/toolkit/components/satchel/FormHistoryChild.sys.mjs
@@ -35,15 +35,16 @@ function log(message) {
export class FormHistoryChild extends JSWindowActorChild {
handleEvent(event) {
switch (event.type) {
- case "DOMFormBeforeSubmit":
- this.#onDOMFormBeforeSubmit(event.target);
+ case "form-submission-detected":
+ this.#onFormSubmission(event);
break;
default:
throw new Error("Unexpected event");
}
}
- #onDOMFormBeforeSubmit(form) {
+ #onFormSubmission(event) {
+ const form = event.detail.form;
if (
!lazy.gEnabled ||
lazy.PrivateBrowsingUtils.isContentWindowPrivate(form.ownerGlobal)
diff --git a/toolkit/components/satchel/FormHistoryStartup.sys.mjs b/toolkit/components/satchel/FormHistoryStartup.sys.mjs
index 104756c583..aa76f16dc5 100644
--- a/toolkit/components/satchel/FormHistoryStartup.sys.mjs
+++ b/toolkit/components/satchel/FormHistoryStartup.sys.mjs
@@ -67,7 +67,7 @@ export class FormHistoryStartup {
target,
}) {
// This case is only used for the search field. There is a
- // similar algorithm in FormHistoryParent.jsm that uses
+ // similar algorithm in FormHistoryParent.sys.mjs that uses
// sendQuery for other form fields.
const instance = (this._queryInstance = {});
diff --git a/toolkit/components/satchel/moz.build b/toolkit/components/satchel/moz.build
index 90dbd9ad2d..4b6d08cdbf 100644
--- a/toolkit/components/satchel/moz.build
+++ b/toolkit/components/satchel/moz.build
@@ -50,6 +50,7 @@ TESTING_JS_MODULES += [
include("/ipc/chromium/chromium-config.mozbuild")
FINAL_TARGET_FILES.actors += [
+ "FormHandlerChild.sys.mjs",
"FormHistoryChild.sys.mjs",
"FormHistoryParent.sys.mjs",
]
diff --git a/toolkit/components/satchel/nsFormFillController.cpp b/toolkit/components/satchel/nsFormFillController.cpp
index 7872ab36c8..1bcbde08df 100644
--- a/toolkit/components/satchel/nsFormFillController.cpp
+++ b/toolkit/components/satchel/nsFormFillController.cpp
@@ -85,7 +85,7 @@ nsFormFillController::nsFormFillController()
mListNode(nullptr),
// The amount of time a context menu event supresses showing a
// popup from a focus event in ms. This matches the threshold in
- // toolkit/components/passwordmgr/LoginManagerChild.jsm.
+ // toolkit/components/passwordmgr/LoginManagerChild.sys.mjs.
mFocusAfterRightClickThreshold(400),
mTimeout(50),
mMinResultsForPopup(1),
diff --git a/toolkit/components/satchel/test/browser/browser_close_tab.js b/toolkit/components/satchel/test/browser/browser_close_tab.js
index 37962d37d8..f0ed806b3b 100644
--- a/toolkit/components/satchel/test/browser/browser_close_tab.js
+++ b/toolkit/components/satchel/test/browser/browser_close_tab.js
@@ -10,10 +10,7 @@ add_task(async function test() {
const url = `data:text/html,<input type="text" name="field1">`;
// Open a dummy tab.
- await BrowserTestUtils.withNewTab(
- { gBrowser, url },
- async function (browser) {}
- );
+ await BrowserTestUtils.withNewTab({ gBrowser, url }, async function () {});
await BrowserTestUtils.withNewTab(
{ gBrowser, url },
diff --git a/toolkit/components/satchel/test/browser/browser_privbrowsing_perwindowpb.js b/toolkit/components/satchel/test/browser/browser_privbrowsing_perwindowpb.js
index 3abc6ebe54..2cf755cd6b 100644
--- a/toolkit/components/satchel/test/browser/browser_privbrowsing_perwindowpb.js
+++ b/toolkit/components/satchel/test/browser/browser_privbrowsing_perwindowpb.js
@@ -30,7 +30,7 @@ add_task(async function test() {
}
}
- function testOnWindow(aOptions, aCallback) {
+ function testOnWindow(aOptions) {
return BrowserTestUtils.openNewBrowserWindow(aOptions).then(win => {
windowsToClose.push(win);
return win;
diff --git a/toolkit/components/satchel/test/test_form_submission.html b/toolkit/components/satchel/test/test_form_submission.html
index d1c0542609..b838f138bc 100644
--- a/toolkit/components/satchel/test/test_form_submission.html
+++ b/toolkit/components/satchel/test/test_form_submission.html
@@ -306,10 +306,10 @@ function setScriptInput(formNumber, inputName, value) {
getFormElementByName(formNumber, inputName).value = value;
}
-function checkSubmitDoesNotSave(formNumber, inputName, value) {
- return new Promise((resolve, reject) => {
+function checkSubmitDoesNotSave(formNumber) {
+ return new Promise(resolve => {
const form = document.getElementById("form" + formNumber);
- form.addEventListener("submit", async e => {
+ form.addEventListener("submit", async () => {
const historyEntriesCount = await countEntries(null, null);
ok(!historyEntriesCount, form.getAttribute("purpose"));
resolve();
@@ -319,11 +319,11 @@ function checkSubmitDoesNotSave(formNumber, inputName, value) {
});
}
-function checkInvalidFirstInputDoesNotSave(formNumber, value) {
- return new Promise((resolve, reject) => {
+function checkInvalidFirstInputDoesNotSave(formNumber) {
+ return new Promise((resolve) => {
const form = document.getElementById("form" + formNumber);
const input = form.querySelector("input");
- input.addEventListener("invalid", async e => {
+ input.addEventListener("invalid", async _e => {
const historyEntriesCount = await countEntries(null, null);
ok(!historyEntriesCount, form.getAttribute("purpose"));
resolve();
@@ -479,12 +479,12 @@ add_task(async function form19_does_not_save() {
add_task(async function form20_does_not_save() {
setUserInput(20, "test1", "dontSaveThis");
- await checkInvalidFirstInputDoesNotSave(20, "invalid");
+ await checkInvalidFirstInputDoesNotSave(20);
});
add_task(async function form21_does_not_save() {
setUserInput(21, "test1", "dontSaveThis");
- await checkInvalidFirstInputDoesNotSave(21, "invalid");
+ await checkInvalidFirstInputDoesNotSave(21);
});
add_task(async function form22_does_not_save() {
diff --git a/toolkit/components/satchel/test/test_popup_enter_event.html b/toolkit/components/satchel/test/test_popup_enter_event.html
index 6150a8a57a..8dfbe71e67 100644
--- a/toolkit/components/satchel/test/test_popup_enter_event.html
+++ b/toolkit/components/satchel/test/test_popup_enter_event.html
@@ -49,11 +49,11 @@ add_task(async function popupEnterEvent() {
}
const submitTested = new Promise(resolve => {
- SpecialPowers.addSystemEventListener(input, "keypress", handleEnter, true);
+ SpecialPowers.wrap(input).addEventListener("keypress", handleEnter, { capture: true, mozSystemGroup: true });
form.addEventListener("submit", e => {
e.preventDefault();
is(input.value, expectedValue, "Check input value in the submit handler");
- SpecialPowers.removeSystemEventListener(input, "keypress", handleEnter, true);
+ SpecialPowers.wrap(input).removeEventListener("keypress", handleEnter, { capture: true, mozSystemGroup: true });
resolve();
}, { once: true });
});
diff --git a/toolkit/components/satchel/test/unit/test_db_corrupt.js b/toolkit/components/satchel/test/unit/test_db_corrupt.js
index b53b5cd6d0..df0d1fae51 100644
--- a/toolkit/components/satchel/test/unit/test_db_corrupt.js
+++ b/toolkit/components/satchel/test/unit/test_db_corrupt.js
@@ -52,7 +52,7 @@ add_test(function test_corruptFormHistoryDB_emptyInit() {
count = await FormHistory.count({ fieldname: "name-A", value: "value-A" });
Assert.equal(count, 0);
run_next_test();
- })().catch(error => {
+ })().catch(_error => {
do_throw("DB initialized after reading a corrupt DB file is not empty.");
});
});