Skip to content

Open-source AI browser agent for Chrome and Firefox (monorepo) 🧠

Include where a submission goes in its decline fingerprint

Claudeb325593428e2
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index 38e5c9ed6..7f7194f17 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -33364,15 +33364,15 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
};
const transactionOrderSite = /(?:^|\.)12306\.cn$/i.test(host);
// The form and the button a submission goes through, as identities of
- // the elements this frame holds, and every value the form would send, as
- // a fingerprint keyed by a secret that never leaves this frame. A
- // declined submission is remembered by them, so another form or button
- // with the same fields and action (per-row forms told apart only by
- // hidden IDs, Reject beside Approve), or the same form with any value
- // changed (a field past the summary's first eight, a password, another
- // file, a hidden record ID), still gets its own card. An Enter in a
- // field, or set_field({submit}), submits through the form's default
- // button.
+ // the elements this frame holds, and every value the form would send and
+ // where it would send them, as a fingerprint keyed by a secret that never
+ // leaves this frame. A declined submission is remembered by them, so
+ // another form or button with the same fields and action (per-row forms
+ // told apart only by hidden IDs, Reject beside Approve), or the same form
+ // with any value or destination changed (a field past the summary's
+ // first eight, a password, another file, a hidden record ID, a button's
+ // new formaction), still gets its own card. An Enter in a field, or
+ // set_field({submit}), submits through the form's default button.
const submissionIdentity = (form, submitControl, pendingEl = null, pendingValue = null) => {
try {
if (!(window.__wbSubmissionIdentities instanceof WeakMap)) {
@@ -33420,8 +33420,13 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
if (el?.isContentEditable && !('value' in el)) return String(el.textContent || '');
return String(el?.value ?? '');
};
- const sent = window.__wbSubmissionValueKey + JSON.stringify(controls.map(el => [
- String(el?.getAttribute?.('name') || ''), String(el?.type || el?.tagName || ''), valueOf(el)]));
+ // Where it goes: the button's own formaction, formmethod, formenctype
+ // and formtarget override the form's, read as attributes so a field
+ // named "action" cannot stand in for the form's.
+ const destination = ['formaction', 'formmethod', 'formenctype', 'formtarget']
+ .map(name => [submitter?.getAttribute?.(name) ?? null, form?.getAttribute?.(name.slice(4)) ?? null]);
+ const sent = window.__wbSubmissionValueKey + JSON.stringify([destination, controls.map(el => [
+ String(el?.getAttribute?.('name') || ''), String(el?.type || el?.tagName || ''), valueOf(el)])]);
// cyrb53, a 53-bit string hash; the frame's key makes it opaque.
let h1 = 0xdeadbeef;
let h2 = 0x41c6ce57;
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index 9330a6fe5..0d77da164 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -30268,15 +30268,15 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
};
const transactionOrderSite = /(?:^|\.)12306\.cn$/i.test(host);
// The form and the button a submission goes through, as identities of
- // the elements this frame holds, and every value the form would send, as
- // a fingerprint keyed by a secret that never leaves this frame. A
- // declined submission is remembered by them, so another form or button
- // with the same fields and action (per-row forms told apart only by
- // hidden IDs, Reject beside Approve), or the same form with any value
- // changed (a field past the summary's first eight, a password, another
- // file, a hidden record ID), still gets its own card. An Enter in a
- // field, or set_field({submit}), submits through the form's default
- // button.
+ // the elements this frame holds, and every value the form would send and
+ // where it would send them, as a fingerprint keyed by a secret that never
+ // leaves this frame. A declined submission is remembered by them, so
+ // another form or button with the same fields and action (per-row forms
+ // told apart only by hidden IDs, Reject beside Approve), or the same form
+ // with any value or destination changed (a field past the summary's
+ // first eight, a password, another file, a hidden record ID, a button's
+ // new formaction), still gets its own card. An Enter in a field, or
+ // set_field({submit}), submits through the form's default button.
const submissionIdentity = (form, submitControl, pendingEl = null, pendingValue = null) => {
try {
if (!(window.__wbSubmissionIdentities instanceof WeakMap)) {
@@ -30324,8 +30324,13 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
if (el?.isContentEditable && !('value' in el)) return String(el.textContent || '');
return String(el?.value ?? '');
};
- const sent = window.__wbSubmissionValueKey + JSON.stringify(controls.map(el => [
- String(el?.getAttribute?.('name') || ''), String(el?.type || el?.tagName || ''), valueOf(el)]));
+ // Where it goes: the button's own formaction, formmethod, formenctype
+ // and formtarget override the form's, read as attributes so a field
+ // named "action" cannot stand in for the form's.
+ const destination = ['formaction', 'formmethod', 'formenctype', 'formtarget']
+ .map(name => [submitter?.getAttribute?.(name) ?? null, form?.getAttribute?.(name.slice(4)) ?? null]);
+ const sent = window.__wbSubmissionValueKey + JSON.stringify([destination, controls.map(el => [
+ String(el?.getAttribute?.('name') || ''), String(el?.type || el?.tagName || ''), valueOf(el)])]);
// cyrb53, a 53-bit string hash; the frame's key makes it opaque.
let h1 = 0xdeadbeef;
let h2 = 0x41c6ce57;
diff --git a/test/declined-submission-identity.mjs b/test/declined-submission-identity.mjs
index bd59596a4..320a62805 100644
--- a/test/declined-submission-identity.mjs
+++ b/test/declined-submission-identity.mjs
@@ -74,6 +74,12 @@ for (const build of ['chrome', 'firefox']) {
assert.notEqual(after.submissionIdentity, previous, `a change to ${selector}`);
assert.equal(after.submissionIdentity.split('/').slice(0, 2).join('/'), previous.split('/').slice(0, 2).join('/'), 'the same form and button');
}
+ // So does the button sending the form somewhere else.
+ for (const [name, value] of [['formaction', '/profile/delete'], ['formmethod', 'get']]) {
+ const previous = (await probe('click', { selector: '#go' })).submissionIdentity;
+ await page.evaluate(([attribute, text]) => document.querySelector('#go').setAttribute(attribute, text), [name, value]);
+ assert.notEqual((await probe('click', { selector: '#go' })).submissionIdentity, previous, `a new ${name}`);
+ }
});
} finally {
await browser.close();