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
track form and accessibility navigation changes
Barack Sokullu8dcc82cbfba8
diff --git a/src/chrome/src/agent/page-feedback.js b/src/chrome/src/agent/page-feedback.jsindex e18502050..f0dd72e17 100644--- a/src/chrome/src/agent/page-feedback.js+++ b/src/chrome/src/agent/page-feedback.js@@ -192,7 +192,7 @@ export const pageFeedbackMethods = {|| !['user', 'agent', 'page', 'unknown'].includes(feedback.source)) return { accepted: false, reason: 'invalid-observation' };frame.seq = seq;if (feedback.source === 'agent') {- if (feedback.operation === 'click') {+ if (['click', 'submit'].includes(feedback.operation)) {let url = '';try {const destination = new URL(String(feedback.navigationUrl || ''));@@ -216,7 +216,7 @@ export const pageFeedbackMethods = {if (matches.length === 1) destinationFrameId = matches[0][0];} else if (!target) destinationFrameId = frameId;}- run.navigation = url && Number.isSafeInteger(destinationFrameId) ? { at: Date.now(), url, kind: 'click',+ run.navigation = url && Number.isSafeInteger(destinationFrameId) ? { at: Date.now(), url, kind: feedback.operation,frameId: destinationFrameId,...(feedback.navigationFormGet === true ? { formGet: true } : {}),operationId: dispatchOwners.get(tabId)?.operationId || '' } : null;@@ -264,7 +264,7 @@ export const pageFeedbackMethods = {const navigation = run.navigation;const redirect = qualifiers.some(q => /redirect$/.test(q));const firstRedirect = type === 'committed' && !navigation?.redirectChain && redirect- && !!navigation?.url && ['click', 'navigate'].includes(navigation.kind);+ && !!navigation?.url && ['click', 'submit', 'navigate'].includes(navigation.kind);const formGetDestination = type === 'committed' && details.transitionType === 'form_submit'&& navigation?.formGet === true && navigation.frameId === frameId && sameOriginPath(navigation.url, details.url);const sameNavigation = navigation?.redirectChaindiff --git a/src/chrome/src/content/page-monitor.js b/src/chrome/src/content/page-monitor.jsindex 09d86b3d8..22a6da03f 100644--- a/src/chrome/src/content/page-monitor.js+++ b/src/chrome/src/content/page-monitor.js@@ -283,7 +283,8 @@const match = op => {if (event && !event.isTrusted && !op.synchronous) return null;if (event) {- if (op.eventTypes && !op.eventTypes.has(event.type)) return null;+ if (op.eventTypes && !op.eventTypes.has(event.type)+ && !(kind === 'click' && event.detail === 0 && op.submitTarget && related(op.submitTarget, el))) return null;// One native dispatch owns one occurrence of each input phase. A later// human action on the same target must not fit that expectation again.if (!op.synchronous && event.type !== 'pointermove' && op.seenEvents?.has(event.type)) return null;@@ -305,6 +306,9 @@if (!op.kinds.has(kind)) continue;if (['wheel', 'touchmove'].includes(event?.type) && !op.nativeWheel) continue;const target = op.target || (op.focused ? document.activeElement : null);+ if (kind === 'click' && event?.detail === 0 && op.submitTarget && related(op.submitTarget, el)) {+ const found = match(op); if (found) return found;+ }if (kind === 'scroll' && op.scrollAncestors?.has(el)) { const found = match(op); if (found) return found; }if (kind === 'scroll' && op.windowScroll && (el === document.documentElement || el === document.body)) { const found = match(op); if (found) return found; }if (related(target, el)) { const found = match(op); if (found) return found; }@@ -382,7 +386,7 @@.map(textSignature).reduce(([size, hash], [length, part, power]) =>[size + length, (Math.imul(hash, power) + part) >>> 0], [0, 0]);const controlValue = controlValueFingerprint(el);- return JSON.stringify([shown, content, el.children.length + (el.shadowRoot?.children.length || 0), el.getAttribute('role'), el.getAttribute('aria-label'),+ return JSON.stringify([shown, content, el.children.length + (el.shadowRoot?.children.length || 0), el.getAttribute('role'), el.getAttribute('aria-modal'), el.getAttribute('aria-label'),el.getAttribute('id'), el.getAttribute('for'), el.getAttribute('form'), el.getAttribute('name'), el.getAttribute('placeholder'), el.getAttribute('title'), el.getAttribute('alt'),el.getAttribute('aria-labelledby'), el.getAttribute('aria-required'), el.getAttribute('aria-readonly'),el.getAttribute('contenteditable'), el.getAttribute('tabindex'), el.getAttribute('onclick'), el.getAttribute('required'),@@ -489,7 +493,7 @@if (!root || roots.has(root) || !observer) return;roots.add(root);observer.observe(root, { childList: true, subtree: true, characterData: true, attributes: true, attributeOldValue: true,- attributeFilter: ['role', 'aria-label', 'id', 'for', 'form', 'name', 'placeholder', 'title', 'alt', 'aria-labelledby', 'rel', 'media', 'data-selected',+ attributeFilter: ['role', 'aria-modal', 'aria-label', 'id', 'for', 'form', 'name', 'placeholder', 'title', 'alt', 'aria-labelledby', 'rel', 'media', 'data-selected','aria-required', 'aria-readonly', 'contenteditable', 'tabindex', 'onclick', 'required','aria-expanded', 'aria-selected', 'aria-checked', 'aria-pressed', 'aria-disabled','type', 'href', 'target', 'download', 'action', 'method', 'formaction', 'formmethod', 'formtarget', 'novalidate', 'formnovalidate',@@ -546,8 +550,9 @@return false;}));}- function hasVisibleAriaLabelledbyConsumer(el) {+ function hasVisibleAriaLabelledbyConsumer(el, previousId = '') {const ids = new Set();+ if (previousId) ids.add(previousId);for (let node = el; node; node = node.parentElement || node.getRootNode?.().host) {if (node.id) ids.add(node.id);}@@ -716,8 +721,10 @@const accessibleNameContentMutation = ['characterData', 'childList'].includes(record.type);const nativeLabelAssociationMutation = record.type === 'attributes'&& record.attributeName === 'for' && el.tagName === 'LABEL';+ const hiddenAriaLabelIdMutation = record.type === 'attributes' && record.attributeName === 'id';const hiddenAccessibleNameChanged = !visible(el)&& ((accessibleNameContentMutation && hasVisibleAriaLabelledbyConsumer(el))+ || (hiddenAriaLabelIdMutation && hasVisibleAriaLabelledbyConsumer(el, record.oldValue))|| ((accessibleNameContentMutation || nativeLabelAssociationMutation)&& hasVisibleNativeLabelConsumer(el, nativeLabelAssociationMutation ? record.oldValue : '')));let identityChanged = (record.type === 'popover' && record.stateChanged)@@ -847,11 +854,19 @@if (['input', 'beforeinput', 'change'].includes(event.type)) rememberAgentLayout(op);const marker = { userAt: op.userAt };agentTurn = marker;- if (op.navigationCandidate && ['click', 'pointerdown'].includes(event.type)) {+ const enterFormSubmit = event.type === 'keydown' && event.key === 'Enter' && op.kind === 'input'+ && el?.tagName !== 'TEXTAREA' && !el?.isContentEditable && !!el?.form;+ if ((op.navigationCandidate && ['click', 'pointerdown'].includes(event.type)) || enterFormSubmit) {const path = event.composedPath();- const link = path.find(node => node instanceof Element && node.matches('a[href],area[href]'));- const submitter = path.find(node => node instanceof Element && node.matches('button,input[type="submit"],input[type="image"]') && node.form);- const form = submitter?.form;+ const link = enterFormSubmit ? null : path.find(node => node instanceof Element && node.matches('a[href],area[href]'));+ let submitter = path.find(node => node instanceof Element+ && node.matches('button:not([type]),button[type="submit"],input[type="submit"],input[type="image"]') && node.form);+ const form = submitter?.form || (enterFormSubmit ? el.form : null);+ if (enterFormSubmit && form && !submitter) {+ submitter = [...form.elements].find(node => !node.disabled && node.matches?.(+ 'button:not([type]),button[type="submit"],input[type="submit"],input[type="image"]')) || null;+ }+ if (enterFormSubmit && submitter) { op.submitTarget = submitter; op.kinds.add('click'); }const formMethod = submitter?.hasAttribute('formmethod') ? submitter.formMethod : form?.method;const navigationFormGet = !link && !!form && String(formMethod || 'get').toLowerCase() === 'get';const formTarget = submitter?.getAttribute('formtarget') || form?.getAttribute('target');@@ -860,13 +875,13 @@const normalizedTarget = navigationTarget.toLowerCase();let navigationUrl = '';try {- const rawUrl = link?.href || (form ? (submitter.hasAttribute('formaction') ? submitter.formAction : form.action) : '');+ const rawUrl = link?.href || (form ? (submitter?.hasAttribute('formaction') ? submitter.formAction : form.action) : '');const destination = new URL(rawUrl, document.baseURI);if (navigationFormGet) { destination.search = ''; destination.hash = ''; }if (['http:', 'https:'].includes(destination.protocol) && !destination.username && !destination.password&& destination.href.length <= 2000) navigationUrl = destination.href;} catch { /* Non-web and malformed targets are not navigation correlations. */ }- send({ kind: 'activity', source: 'agent', operation: 'click',+ send({ kind: 'activity', source: 'agent', operation: enterFormSubmit ? 'submit' : 'click',...(navigationUrl ? { navigationUrl } : {}),...(navigationUrl && navigationFormGet ? { navigationFormGet: true } : {}),...(['_top', '_parent', '_self', '_blank'].includes(normalizedTarget)diff --git a/src/firefox/src/agent/page-feedback.js b/src/firefox/src/agent/page-feedback.jsindex e18502050..f0dd72e17 100644--- a/src/firefox/src/agent/page-feedback.js+++ b/src/firefox/src/agent/page-feedback.js@@ -192,7 +192,7 @@ export const pageFeedbackMethods = {|| !['user', 'agent', 'page', 'unknown'].includes(feedback.source)) return { accepted: false, reason: 'invalid-observation' };frame.seq = seq;if (feedback.source === 'agent') {- if (feedback.operation === 'click') {+ if (['click', 'submit'].includes(feedback.operation)) {let url = '';try {const destination = new URL(String(feedback.navigationUrl || ''));@@ -216,7 +216,7 @@ export const pageFeedbackMethods = {if (matches.length === 1) destinationFrameId = matches[0][0];} else if (!target) destinationFrameId = frameId;}- run.navigation = url && Number.isSafeInteger(destinationFrameId) ? { at: Date.now(), url, kind: 'click',+ run.navigation = url && Number.isSafeInteger(destinationFrameId) ? { at: Date.now(), url, kind: feedback.operation,frameId: destinationFrameId,...(feedback.navigationFormGet === true ? { formGet: true } : {}),operationId: dispatchOwners.get(tabId)?.operationId || '' } : null;@@ -264,7 +264,7 @@ export const pageFeedbackMethods = {const navigation = run.navigation;const redirect = qualifiers.some(q => /redirect$/.test(q));const firstRedirect = type === 'committed' && !navigation?.redirectChain && redirect- && !!navigation?.url && ['click', 'navigate'].includes(navigation.kind);+ && !!navigation?.url && ['click', 'submit', 'navigate'].includes(navigation.kind);const formGetDestination = type === 'committed' && details.transitionType === 'form_submit'&& navigation?.formGet === true && navigation.frameId === frameId && sameOriginPath(navigation.url, details.url);const sameNavigation = navigation?.redirectChaindiff --git a/src/firefox/src/content/page-monitor.js b/src/firefox/src/content/page-monitor.jsindex 09d86b3d8..22a6da03f 100644--- a/src/firefox/src/content/page-monitor.js+++ b/src/firefox/src/content/page-monitor.js@@ -283,7 +283,8 @@const match = op => {if (event && !event.isTrusted && !op.synchronous) return null;if (event) {- if (op.eventTypes && !op.eventTypes.has(event.type)) return null;+ if (op.eventTypes && !op.eventTypes.has(event.type)+ && !(kind === 'click' && event.detail === 0 && op.submitTarget && related(op.submitTarget, el))) return null;// One native dispatch owns one occurrence of each input phase. A later// human action on the same target must not fit that expectation again.if (!op.synchronous && event.type !== 'pointermove' && op.seenEvents?.has(event.type)) return null;@@ -305,6 +306,9 @@if (!op.kinds.has(kind)) continue;if (['wheel', 'touchmove'].includes(event?.type) && !op.nativeWheel) continue;const target = op.target || (op.focused ? document.activeElement : null);+ if (kind === 'click' && event?.detail === 0 && op.submitTarget && related(op.submitTarget, el)) {+ const found = match(op); if (found) return found;+ }if (kind === 'scroll' && op.scrollAncestors?.has(el)) { const found = match(op); if (found) return found; }if (kind === 'scroll' && op.windowScroll && (el === document.documentElement || el === document.body)) { const found = match(op); if (found) return found; }if (related(target, el)) { const found = match(op); if (found) return found; }@@ -382,7 +386,7 @@.map(textSignature).reduce(([size, hash], [length, part, power]) =>[size + length, (Math.imul(hash, power) + part) >>> 0], [0, 0]);const controlValue = controlValueFingerprint(el);- return JSON.stringify([shown, content, el.children.length + (el.shadowRoot?.children.length || 0), el.getAttribute('role'), el.getAttribute('aria-label'),+ return JSON.stringify([shown, content, el.children.length + (el.shadowRoot?.children.length || 0), el.getAttribute('role'), el.getAttribute('aria-modal'), el.getAttribute('aria-label'),el.getAttribute('id'), el.getAttribute('for'), el.getAttribute('form'), el.getAttribute('name'), el.getAttribute('placeholder'), el.getAttribute('title'), el.getAttribute('alt'),el.getAttribute('aria-labelledby'), el.getAttribute('aria-required'), el.getAttribute('aria-readonly'),el.getAttribute('contenteditable'), el.getAttribute('tabindex'), el.getAttribute('onclick'), el.getAttribute('required'),@@ -489,7 +493,7 @@if (!root || roots.has(root) || !observer) return;roots.add(root);observer.observe(root, { childList: true, subtree: true, characterData: true, attributes: true, attributeOldValue: true,- attributeFilter: ['role', 'aria-label', 'id', 'for', 'form', 'name', 'placeholder', 'title', 'alt', 'aria-labelledby', 'rel', 'media', 'data-selected',+ attributeFilter: ['role', 'aria-modal', 'aria-label', 'id', 'for', 'form', 'name', 'placeholder', 'title', 'alt', 'aria-labelledby', 'rel', 'media', 'data-selected','aria-required', 'aria-readonly', 'contenteditable', 'tabindex', 'onclick', 'required','aria-expanded', 'aria-selected', 'aria-checked', 'aria-pressed', 'aria-disabled','type', 'href', 'target', 'download', 'action', 'method', 'formaction', 'formmethod', 'formtarget', 'novalidate', 'formnovalidate',@@ -546,8 +550,9 @@return false;}));}- function hasVisibleAriaLabelledbyConsumer(el) {+ function hasVisibleAriaLabelledbyConsumer(el, previousId = '') {const ids = new Set();+ if (previousId) ids.add(previousId);for (let node = el; node; node = node.parentElement || node.getRootNode?.().host) {if (node.id) ids.add(node.id);}@@ -716,8 +721,10 @@const accessibleNameContentMutation = ['characterData', 'childList'].includes(record.type);const nativeLabelAssociationMutation = record.type === 'attributes'&& record.attributeName === 'for' && el.tagName === 'LABEL';+ const hiddenAriaLabelIdMutation = record.type === 'attributes' && record.attributeName === 'id';const hiddenAccessibleNameChanged = !visible(el)&& ((accessibleNameContentMutation && hasVisibleAriaLabelledbyConsumer(el))+ || (hiddenAriaLabelIdMutation && hasVisibleAriaLabelledbyConsumer(el, record.oldValue))|| ((accessibleNameContentMutation || nativeLabelAssociationMutation)&& hasVisibleNativeLabelConsumer(el, nativeLabelAssociationMutation ? record.oldValue : '')));let identityChanged = (record.type === 'popover' && record.stateChanged)@@ -847,11 +854,19 @@if (['input', 'beforeinput', 'change'].includes(event.type)) rememberAgentLayout(op);const marker = { userAt: op.userAt };agentTurn = marker;- if (op.navigationCandidate && ['click', 'pointerdown'].includes(event.type)) {+ const enterFormSubmit = event.type === 'keydown' && event.key === 'Enter' && op.kind === 'input'+ && el?.tagName !== 'TEXTAREA' && !el?.isContentEditable && !!el?.form;+ if ((op.navigationCandidate && ['click', 'pointerdown'].includes(event.type)) || enterFormSubmit) {const path = event.composedPath();- const link = path.find(node => node instanceof Element && node.matches('a[href],area[href]'));- const submitter = path.find(node => node instanceof Element && node.matches('button,input[type="submit"],input[type="image"]') && node.form);- const form = submitter?.form;+ const link = enterFormSubmit ? null : path.find(node => node instanceof Element && node.matches('a[href],area[href]'));+ let submitter = path.find(node => node instanceof Element+ && node.matches('button:not([type]),button[type="submit"],input[type="submit"],input[type="image"]') && node.form);+ const form = submitter?.form || (enterFormSubmit ? el.form : null);+ if (enterFormSubmit && form && !submitter) {+ submitter = [...form.elements].find(node => !node.disabled && node.matches?.(+ 'button:not([type]),button[type="submit"],input[type="submit"],input[type="image"]')) || null;+ }+ if (enterFormSubmit && submitter) { op.submitTarget = submitter; op.kinds.add('click'); }const formMethod = submitter?.hasAttribute('formmethod') ? submitter.formMethod : form?.method;const navigationFormGet = !link && !!form && String(formMethod || 'get').toLowerCase() === 'get';const formTarget = submitter?.getAttribute('formtarget') || form?.getAttribute('target');@@ -860,13 +875,13 @@const normalizedTarget = navigationTarget.toLowerCase();let navigationUrl = '';try {- const rawUrl = link?.href || (form ? (submitter.hasAttribute('formaction') ? submitter.formAction : form.action) : '');+ const rawUrl = link?.href || (form ? (submitter?.hasAttribute('formaction') ? submitter.formAction : form.action) : '');const destination = new URL(rawUrl, document.baseURI);if (navigationFormGet) { destination.search = ''; destination.hash = ''; }if (['http:', 'https:'].includes(destination.protocol) && !destination.username && !destination.password&& destination.href.length <= 2000) navigationUrl = destination.href;} catch { /* Non-web and malformed targets are not navigation correlations. */ }- send({ kind: 'activity', source: 'agent', operation: 'click',+ send({ kind: 'activity', source: 'agent', operation: enterFormSubmit ? 'submit' : 'click',...(navigationUrl ? { navigationUrl } : {}),...(navigationUrl && navigationFormGet ? { navigationFormGet: true } : {}),...(['_top', '_parent', '_self', '_blank'].includes(normalizedTarget)diff --git a/test/page-feedback.mjs b/test/page-feedback.mjsindex fb6af5353..55a3a7446 100644--- a/test/page-feedback.mjs+++ b/test/page-feedback.mjs@@ -785,10 +785,11 @@ for (const build of ['chrome', 'firefox']) {try {await agent._beginPageFeedbackRun(tab, 'interactive');let binding = bind(agent, tab);- binding.send({ kind: 'activity', source: 'agent', operation: 'click', navigationUrl: 'https://example.com/search',+ binding.send({ kind: 'activity', source: 'agent', operation: 'submit', navigationUrl: 'https://example.com/search',navigationFormGet: true });const armed = agent._pageFeedbackRuns.get(tab).navigation;assert.equal(armed.url, 'https://example.com/search', 'The correlation marker contains only the action path');+ assert.equal(armed.kind, 'submit');assert.equal(armed.formGet, true);agent.observePageNavigation({ tabId: tab, frameId: 0, documentId: 'form-result',url: 'https://example.com/search?q=private-form-value', transitionType: 'form_submit' }, 'committed');@@ -796,7 +797,7 @@ for (const build of ['chrome', 'firefox']) {assert.equal(agent._pageFeedbackRuns.get(tab).navigation, null);binding = bind(agent, tab, 0, 'form-result', 'form-result-token');- binding.send({ kind: 'activity', source: 'agent', operation: 'click', navigationUrl: 'https://example.com/search',+ binding.send({ kind: 'activity', source: 'agent', operation: 'submit', navigationUrl: 'https://example.com/search',navigationFormGet: true });agent.observePageNavigation({ tabId: tab, frameId: 0, documentId: 'wrong-form-result',url: 'https://example.com/other?q=value', transitionType: 'form_submit' }, 'committed');diff --git a/test/page-monitor-ui.mjs b/test/page-monitor-ui.mjsindex 50ec1e7bc..b505a74d1 100644--- a/test/page-monitor-ui.mjs+++ b/test/page-monitor-ui.mjs@@ -2002,6 +2002,57 @@ for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {} finally { await browser.close(); }});+ test(`${build}: hidden aria-labelledby ID changes invalidate visible targets`, async () => {+ const { browser, page } = await fixture(engine, build);+ try {+ await page.evaluate(() => {+ const label = document.createElement('span'); label.id = 'hidden-id-label'; label.textContent = 'Accessible name';+ label.style.display = 'none';+ const button = document.createElement('button'); button.id = 'id-labelled-button'; button.setAttribute('aria-labelledby', label.id);+ document.body.append(label, button);+ });+ await page.waitForTimeout(180);+ await page.evaluate(() => {+ feedback = [];+ deliver('page_monitor_prepare', { operationId: 'hidden-label-id', tool: 'click', selector: '#id-labelled-button' });+ deliver('page_monitor_dispatch', { operationId: 'hidden-label-id', kind: 'click', selector: '#id-labelled-button', fenceOnly: true });+ document.getElementById('hidden-id-label').id = 'renamed-hidden-id-label';+ });+ await page.waitForFunction(() => feedback.some(event => event.kind === 'dom' && event.source === 'page'), null, { timeout: 1000 });+ const blocked = await page.evaluate(() => {+ try { __wbPageMonitor.activatePreparedDispatch({ operationId: 'hidden-label-id', kind: 'click' }); return null; }+ catch (error) { return error.code; }+ });+ assert.equal(blocked, 'page_feedback_pending', 'Changing a hidden referenced ID must stale the prepared action');+ assert.equal(JSON.stringify(await page.evaluate(() => feedback)).includes('Accessible name'), false,+ 'The hidden label text must stay out of feedback');+ } finally { await browser.close(); }+ });++ test(`${build}: aria-modal changes invalidate prepared page context`, async () => {+ const { browser, page } = await fixture(engine, build);+ try {+ await page.evaluate(() => {+ const modal = document.createElement('div'); modal.id = 'modal-container'; modal.setAttribute('role', 'dialog');+ modal.textContent = 'Dialog'; document.body.append(modal);+ });+ await page.waitForTimeout(180);+ await page.evaluate(() => {+ feedback = [];+ deliver('page_monitor_prepare', { operationId: 'aria-modal', tool: 'click', selector: '#agent' });+ deliver('page_monitor_dispatch', { operationId: 'aria-modal', kind: 'click', selector: '#agent', fenceOnly: true });+ document.getElementById('modal-container').setAttribute('aria-modal', 'true');+ });+ await page.waitForFunction(() => feedback.some(event => event.kind === 'dom' && event.source === 'page'+ && event.target === 'div#modal-container [dialog]'), null, { timeout: 1000 });+ const blocked = await page.evaluate(() => {+ try { __wbPageMonitor.activatePreparedDispatch({ operationId: 'aria-modal', kind: 'click' }); return null; }+ catch (error) { return error.code; }+ });+ assert.equal(blocked, 'page_feedback_pending', 'Changing modal semantics must stale a prepared action');+ } finally { await browser.close(); }+ });+test(`${build}: guarded synthetic file input events are attributed once`, async () => {const { browser, page } = await fixture(engine, build);try {@@ -2207,6 +2258,37 @@ for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {} finally { await browser.close(); }});+ test(`${build}: Enter-triggered form submissions carry agent navigation context`, async () => {+ const { browser, page } = await fixture(engine, build);+ try {+ await page.evaluate(() => {+ const form = document.createElement('form'); form.id = 'enter-submit-form';+ form.method = 'get'; form.action = '/enter-search?fixed=private-action-value#result'; form.target = '_parent';+ form.innerHTML = '<input id="enter-submit-input" name="query" value="private-form-value">'+ + '<button id="enter-submit-button" type="submit">Search</button>';+ form.addEventListener('submit', event => event.preventDefault());+ document.body.append(form);+ });+ await page.waitForTimeout(180);+ await page.evaluate(() => {+ feedback = [];+ deliver('page_monitor_prepare', { operationId: 'enter-submit', tool: 'press_keys', selector: '#enter-submit-input' });+ deliver('page_monitor_dispatch', { operationId: 'enter-submit', kind: 'input', selector: '#enter-submit-input' });+ });+ await page.locator('#enter-submit-input').press('Enter');+ await page.waitForFunction(() => feedback.some(event => event.source === 'agent' && event.operation === 'submit'), null, { timeout: 1000 });+ const marker = await page.evaluate(() => feedback.find(event => event.source === 'agent' && event.operation === 'submit'));+ assert.equal(marker.navigationUrl, 'https://monitor.test/enter-search');+ assert.equal(marker.navigationFormGet, true);+ assert.equal(marker.navigationTarget, '_parent');+ const events = await page.evaluate(() => feedback);+ assert.equal(JSON.stringify(events).includes('private-form-value'), false);+ assert.equal(JSON.stringify(events).includes('private-action-value'), false);+ assert.equal(events.some(event => event.kind === 'click' && event.source === 'user'), false,+ `The browser-generated default submit click stays attributed to the agent Enter action: ${JSON.stringify(events)}`);+ } finally { await browser.close(); }+ });+test(`${build}: stylesheet text changes invalidate prepared actions without exposing CSS`, async () => {const { browser, page } = await fixture(engine, build);try {