Open-source AI browser agent for Chrome and Firefox (monorepo) ðŸ§
JavaScript ai-agentai-agentsai-toolsbrowser-aibrowser-automationbrowser-extensionchrome-aichrome-devtoolschrome-extensionchrome-extensionsfirefox-addonfirefox-addonsfirefox-extensionfirefox-extensionsgemmagemma4minimaxoffline-aioffline-llmqwen
Keep fingerprint values as arrays; never remember an image submit
Clauded261664ecef8
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.jsindex 3d66ef543..2a6c29d17 100644--- a/src/chrome/src/agent/agent.js+++ b/src/chrome/src/agent/agent.js@@ -33404,6 +33404,9 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dconst submitter = owner && !typedField? (owner.closest?.('button,input,[role="button"]') || owner): defaultButton();+ // An image button also sends where it was clicked, which is not+ // known here: such a submission is never remembered.+ if (String(submitter?.tagName || '').toUpperCase() === 'INPUT' && String(submitter.type || '').toLowerCase() === 'image') return '';const controls = (() => {try {return String(form?.tagName || '').toUpperCase() === 'FORM'@@ -33418,10 +33421,11 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dconst existing = el?.isContentEditable && !('value' in el) ? String(el.textContent || '') : String(el?.value ?? '');return appended ? existing + String(pendingValue) : String(pendingValue);}+ // Arrays, not joined strings: a value may hold any separator.const type = String(el?.type || '').toLowerCase();- if (type === 'checkbox' || type === 'radio') return `${el.checked ? 1 : 0}:${el.value ?? ''}`;- if (type === 'file') return Array.from(el.files || []).map(file => [file.name, file.size, file.lastModified, file.type].join(':')).join('|');- if (type === 'select-multiple') return Array.from(el.selectedOptions || []).map(option => option.value).join('|');+ if (type === 'checkbox' || type === 'radio') return [el.checked === true, String(el.value ?? '')];+ if (type === 'file') return Array.from(el.files || []).map(file => [file.name, file.size, file.lastModified, file.type]);+ if (type === 'select-multiple') return Array.from(el.selectedOptions || []).map(option => option.value);if (el?.isContentEditable && !('value' in el)) return String(el.textContent || '');return String(el?.value ?? '');};diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.jsindex 194b98acf..bb8cfad99 100644--- a/src/firefox/src/agent/agent.js+++ b/src/firefox/src/agent/agent.js@@ -30308,6 +30308,9 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dconst submitter = owner && !typedField? (owner.closest?.('button,input,[role="button"]') || owner): defaultButton();+ // An image button also sends where it was clicked, which is not+ // known here: such a submission is never remembered.+ if (String(submitter?.tagName || '').toUpperCase() === 'INPUT' && String(submitter.type || '').toLowerCase() === 'image') return '';const controls = (() => {try {return String(form?.tagName || '').toUpperCase() === 'FORM'@@ -30322,10 +30325,11 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dconst existing = el?.isContentEditable && !('value' in el) ? String(el.textContent || '') : String(el?.value ?? '');return appended ? existing + String(pendingValue) : String(pendingValue);}+ // Arrays, not joined strings: a value may hold any separator.const type = String(el?.type || '').toLowerCase();- if (type === 'checkbox' || type === 'radio') return `${el.checked ? 1 : 0}:${el.value ?? ''}`;- if (type === 'file') return Array.from(el.files || []).map(file => [file.name, file.size, file.lastModified, file.type].join(':')).join('|');- if (type === 'select-multiple') return Array.from(el.selectedOptions || []).map(option => option.value).join('|');+ if (type === 'checkbox' || type === 'radio') return [el.checked === true, String(el.value ?? '')];+ if (type === 'file') return Array.from(el.files || []).map(file => [file.name, file.size, file.lastModified, file.type]);+ if (type === 'select-multiple') return Array.from(el.selectedOptions || []).map(option => option.value);if (el?.isContentEditable && !('value' in el)) return String(el.textContent || '');return String(el?.value ?? '');};diff --git a/test/declined-submission-identity.mjs b/test/declined-submission-identity.mjsindex d8b17fd41..f86c2367d 100644--- a/test/declined-submission-identity.mjs+++ b/test/declined-submission-identity.mjs@@ -98,6 +98,22 @@ for (const build of ['chrome', 'firefox']) {await page.evaluate(() => { document.querySelector('#extra').disabled = true; });assert.notEqual((await probe('click', { selector: '#go' })).submissionIdentity, enabled, 'a disabled field');});++ await t.test('selected values keep their boundaries, and an image button is never remembered', async () => {+ await page.setContent('<form method="post" action="/tags"><select id="tags" name="tags" multiple aria-label="Tags">'+ + '<option value="a|b">a|b</option><option value="a">a</option><option value="b">b</option></select>'+ + '<button id="go">Save</button><input id="map" type="image" name="map" alt="Pick on map" src="data:image/gif;base64,R0lGODlhAQABAAAAACw="></form>');+ const select = values => page.evaluate(chosen => {+ for (const option of document.querySelector('#tags').options) option.selected = chosen.includes(option.value);+ }, values);+ await select(['a|b']);+ const joined = (await probe('click', { selector: '#go' })).submissionIdentity;+ await select(['a', 'b']);+ assert.notEqual((await probe('click', { selector: '#go' })).submissionIdentity, joined, 'one option a|b is not options a and b');+ const image = await probe('click', { selector: '#map' });+ assert.equal(image?.isSubmit, true);+ assert.equal(image.submissionIdentity, '', 'an image button sends its click position');+ });} finally {await browser.close();}