Skip to content

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

Address review regressions in text targeting and LinkedIn guards

Emre Sokullu4872b61e3f0a
diff --git a/src/chrome/src/content/content.js b/src/chrome/src/content/content.js
index 17e9f1996..1187d03e1 100644
--- a/src/chrome/src/content/content.js
+++ b/src/chrome/src/content/content.js
@@ -1594,6 +1594,29 @@
}
}
+ function _primaryClickText(el) {
+ const tag = String(el.tagName || '').toLowerCase();
+ if (tag === 'textarea') return '';
+ if (tag === 'input') {
+ const type = String(el.getAttribute?.('type') || 'text').toLowerCase();
+ return /^(button|submit|reset)$/.test(type) ? String(el.value || '').trim().toLowerCase() : '';
+ }
+ return String(el.innerText || '').trim().toLowerCase();
+ }
+
+ // A painted passive label is not a competing control. Collapse primary
+ // labels to their actionable owner before dispatch and preflight choose it.
+ function _preferredPrimaryTextClickMatch(matches) {
+ const controls = new Map();
+ for (const match of matches) {
+ if (match.primary !== true) continue;
+ const actionable = _resolveInteractiveAncestor(match.e) || match.e;
+ if (!_isInteractive(actionable) || !_isEligibleTextClickTarget(actionable)) continue;
+ if (!controls.has(actionable)) controls.set(actionable, match);
+ }
+ return controls.size === 1 ? [...controls.values()][0] : null;
+ }
+
const _textCandidateCache = new WeakMap();
function _clickTextCandidates(scope) {
_ensureDomRevisionObserver();
@@ -1626,7 +1649,9 @@
for (const e of candidates) {
if (!_hasVisibleBox(e)) continue;
const text = _siteInteractionText(e).toLowerCase();
- if (text) out.push({ e, txt: text, primary: true });
+ const primaryText = _primaryClickText(e);
+ if (text) out.push({ e, txt: text, primary: !!primaryText && text === primaryText });
+ if (primaryText && primaryText !== text) out.push({ e, txt: primaryText, primary: true });
// A control's aria-label / title / placeholder often names it far better
// than its visible glyphs β€” icon-only buttons and combobox-style fields
// ("Search for contacts") are unreachable by visible text alone. Offer
@@ -1817,7 +1842,10 @@
const collapsedByAncestor = new Map();
for (const m of matches) {
const actionable = _resolveInteractiveAncestor(m.e) || m.e;
- if (!collapsedByAncestor.has(actionable)) collapsedByAncestor.set(actionable, m);
+ if (!collapsedByAncestor.has(actionable)
+ || (m.primary === true && collapsedByAncestor.get(actionable).primary !== true)) {
+ collapsedByAncestor.set(actionable, m);
+ }
}
if (collapsedByAncestor.size < matches.length) {
matches = [...collapsedByAncestor.values()];
@@ -1828,27 +1856,14 @@
}
}
if (!el && matches.length > 1) {
- // A control's own visible text outranks an attribute-derived needle
- // (aria-label, title, placeholder, data-tooltip) on a DIFFERENT
- // control. An input's competing aria-label must not turn a genuinely
- // labeled submit button into a false ambiguity β€” the submit probe in
- // agent.js ranks aria-label below innerText/value/placeholder for
- // exactly this reason. Icon-only controls are unaffected: with no
- // visible glyphs their aria-label is their primary text.
- const eligibleMatches = matches.filter(m => _isEligibleTextClickTarget(m.e));
- const primaryMatches = eligibleMatches.filter(m => m.primary === true);
- if (primaryMatches.length > 0 && primaryMatches.length < matches.length) {
- const primaryCollapsed = new Map();
- for (const m of primaryMatches) {
- const actionable = _resolveInteractiveAncestor(m.e) || m.e;
- if (!primaryCollapsed.has(actionable)) primaryCollapsed.set(actionable, m);
- }
- if (primaryCollapsed.size === 1) {
- const [entry] = primaryCollapsed.values();
- el = _resolveInteractiveAncestor(entry.e) || entry.e;
- textResolvedExact = (usedMode === 'exact');
- matches = [entry];
- }
+ // Prefer a unique visible caption only when its actionable owner can
+ // receive the click. Passive text and attribute-only names retain the
+ // existing interactive-target and ambiguity rules.
+ const entry = _preferredPrimaryTextClickMatch(matches);
+ if (entry) {
+ el = _resolveInteractiveAncestor(entry.e) || entry.e;
+ textResolvedExact = (usedMode === 'exact');
+ matches = [entry];
}
}
if (!el && matches.length > 1) {
@@ -5695,10 +5710,8 @@
if (matches.length > 1) {
const eligibleMatches = matches.filter(({ e }) => _isEligibleTextClickTarget(e));
if (eligibleMatches.length) matches = eligibleMatches;
- const primaryMatches = eligibleMatches.filter(({ primary }) => primary === true);
- if (primaryMatches.length > 0 && primaryMatches.length < matches.length) {
- matches = primaryMatches;
- }
+ const primaryMatch = _preferredPrimaryTextClickMatch(matches);
+ if (primaryMatch) matches = [primaryMatch];
const interactiveMatches = matches.filter(({ e }) => _isInteractive(e));
if (interactiveMatches.length === 1) matches = interactiveMatches;
}
@@ -6085,12 +6098,19 @@
// exposes a send control or a verified LinkedIn public-post control.
const dialogSelector = 'dialog,[role="dialog"],[role="alertdialog"],[aria-modal="true"]';
const layoutDialog = layoutCandidate?.closest?.(dialogSelector);
+ // Empty Gmail drafts can have a disabled Send button. Their dedicated
+ // body editor is compose evidence; a generic filter textarea is not.
+ const verifiedGmailBody = params.adapterName === 'gmail'
+ && layoutCandidate?.matches?.('[contenteditable="true"][role="textbox"]')
+ && (layoutCandidate.getAttribute('g_editable') === 'true'
+ || !!layoutDialog?.querySelector?.('input[name="subjectbox"]'));
const layoutInComposeDialog = !!layoutDialog
&& !verifiedNavigationEditable(layoutCandidate)
&& layoutCandidate.matches?.('textarea,[contenteditable="true"],[role="textbox"]:not(input)')
&& Array.from(layoutDialog.querySelectorAll('button,[role="button"],input[type="submit"],input[type="button"],[data-action]'))
.some(control => visible(control) && control.closest(dialogSelector) === layoutDialog
- && (_hasMessageCommitName(control.getAttribute('aria-label') || control.value || control.innerText || control.textContent)
+ && ((_hasMessageCommitName(control.getAttribute('aria-label') || control.value || control.innerText || control.textContent)
+ && (_isEligibleTextClickTarget(control) || verifiedGmailBody))
|| verifiedLinkedInPublicPostControl(control)));
const layoutComposer = layoutCandidate
&& (layoutInComposeDialog
@@ -6227,14 +6247,17 @@
// still commit without a composer β€” a send/commit-labelled control,
// a messaging app's Reply/Reply all/Forward opener, or anything
// inside the app's messaging surface β€” stay fail-closed.
- // LinkedIn is the strictest contract: every control that may act
- // without a composer has a verified classifier above (post entry,
- // public Post, navigation). A control that matched none of them is
- // unverified, so it is NOT proven non-message. A button-like
- // control or a link the classifier saw but declined to verify
- // (fragment, script:, mailto:, profile, unknown route) fails closed
- // instead of being approved.
- const linkedInUnverified = params.adapterName === 'linkedin' && (
+ // Known compose surfaces and unverified composer openers stay protected.
+ // Ordinary feed/profile controls do not become message actions merely
+ // because LinkedIn's navigation classifier has no matching route.
+ const composeDialog = _composedClosestElement(control, 'dialog,[role="dialog"],[role="alertdialog"]');
+ const linkedInComposeSurface = params.adapterName === 'linkedin' && (
+ /^start a post$/i.test(actionLabel)
+ || /^\/(?:messaging(?:\/|$)|sharing\/compose(?:\/|$))/.test(location.pathname)
+ || !!_composedClosestElement(control, '.share-box,[class*="msg-"],[class*="messaging"],[id*="messaging"],[data-messaging],[data-test-messaging],[role="log"]')
+ || (composeDialog && Array.from(composeDialog.querySelectorAll('[contenteditable="true"],textarea')).some(visible))
+ );
+ const linkedInUnverified = linkedInComposeSurface && (
control.matches?.('button,[role="button"],input[type="submit"],input[type="button"],[data-action]') === true
|| (control.matches?.('a[href]') === true && linkedInNavigation === 'none')
);
diff --git a/src/firefox/src/content/content.js b/src/firefox/src/content/content.js
index 116eb071f..f5e1a9c06 100644
--- a/src/firefox/src/content/content.js
+++ b/src/firefox/src/content/content.js
@@ -1558,6 +1558,29 @@
}
}
+ function _primaryClickText(el) {
+ const tag = String(el.tagName || '').toLowerCase();
+ if (tag === 'textarea') return '';
+ if (tag === 'input') {
+ const type = String(el.getAttribute?.('type') || 'text').toLowerCase();
+ return /^(button|submit|reset)$/.test(type) ? String(el.value || '').trim().toLowerCase() : '';
+ }
+ return String(el.innerText || '').trim().toLowerCase();
+ }
+
+ // A painted passive label is not a competing control. Collapse primary
+ // labels to their actionable owner before dispatch and preflight choose it.
+ function _preferredPrimaryTextClickMatch(matches) {
+ const controls = new Map();
+ for (const match of matches) {
+ if (match.primary !== true) continue;
+ const actionable = _resolveInteractiveAncestor(match.e) || match.e;
+ if (!_isInteractive(actionable) || !_isEligibleTextClickTarget(actionable)) continue;
+ if (!controls.has(actionable)) controls.set(actionable, match);
+ }
+ return controls.size === 1 ? [...controls.values()][0] : null;
+ }
+
const _textCandidateCache = new WeakMap();
function _clickTextCandidates(scope) {
_observeDomRevisionRoot(document);
@@ -1626,7 +1649,9 @@
const list = [];
for (const e of all) {
const text = _normTxt(e);
- if (text) list.push({ e, txt: text, primary: true });
+ const primaryText = _primaryClickText(e);
+ if (text) list.push({ e, txt: text, primary: !!primaryText && text === primaryText });
+ if (primaryText && primaryText !== text) list.push({ e, txt: primaryText, primary: true });
// Secondary needles (primary: false): in ambiguity resolution a
// visible-text match on a different control must not lose to them.
for (const attr of ['aria-label', 'title', 'placeholder', 'data-tooltip']) {
@@ -2131,7 +2156,10 @@
const collapsedByAncestor = new Map();
for (const match of matches) {
const actionable = _resolveInteractiveAncestor(match.e) || match.e;
- if (!collapsedByAncestor.has(actionable)) collapsedByAncestor.set(actionable, match);
+ if (!collapsedByAncestor.has(actionable)
+ || (match.primary === true && collapsedByAncestor.get(actionable).primary !== true)) {
+ collapsedByAncestor.set(actionable, match);
+ }
}
if (collapsedByAncestor.size < matches.length) matches = [...collapsedByAncestor.values()];
if (matches.length === 1) {
@@ -2140,27 +2168,14 @@
}
}
if (!el && matches.length > 1) {
- // A control's own visible text outranks an attribute-derived needle
- // (aria-label, title, placeholder, data-tooltip) on a DIFFERENT
- // control. An input's competing aria-label must not turn a genuinely
- // labeled submit button into a false ambiguity β€” the submit probe in
- // agent.js ranks aria-label below innerText/value/placeholder for
- // exactly this reason. Icon-only controls are unaffected: with no
- // visible glyphs their aria-label is their primary text.
- const eligibleMatches = matches.filter(m => _isEligibleTextClickTarget(m.e));
- const primaryMatches = eligibleMatches.filter(m => m.primary === true);
- if (primaryMatches.length > 0 && primaryMatches.length < matches.length) {
- const primaryCollapsed = new Map();
- for (const m of primaryMatches) {
- const actionable = _resolveInteractiveAncestor(m.e) || m.e;
- if (!primaryCollapsed.has(actionable)) primaryCollapsed.set(actionable, m);
- }
- if (primaryCollapsed.size === 1) {
- const [entry] = primaryCollapsed.values();
- el = _resolveInteractiveAncestor(entry.e) || entry.e;
- textResolvedExact = (usedMode === 'exact');
- matches = [entry];
- }
+ // Prefer a unique visible caption only when its actionable owner can
+ // receive the click. Passive text and attribute-only names retain the
+ // existing interactive-target and ambiguity rules.
+ const entry = _preferredPrimaryTextClickMatch(matches);
+ if (entry) {
+ el = _resolveInteractiveAncestor(entry.e) || entry.e;
+ textResolvedExact = (usedMode === 'exact');
+ matches = [entry];
}
}
if (!el && matches.length > 1) {
@@ -4783,10 +4798,8 @@
if (matches.length > 1) {
const eligibleMatches = matches.filter(({ e }) => _isEligibleTextClickTarget(e));
if (eligibleMatches.length) matches = eligibleMatches;
- const primaryMatches = eligibleMatches.filter(({ primary }) => primary === true);
- if (primaryMatches.length > 0 && primaryMatches.length < matches.length) {
- matches = primaryMatches;
- }
+ const primaryMatch = _preferredPrimaryTextClickMatch(matches);
+ if (primaryMatch) matches = [primaryMatch];
const interactiveMatches = matches.filter(({ e }) => _isInteractive(e));
if (interactiveMatches.length === 1) matches = interactiveMatches;
}
@@ -5173,12 +5186,19 @@
// exposes a send control or a verified LinkedIn public-post control.
const dialogSelector = 'dialog,[role="dialog"],[role="alertdialog"],[aria-modal="true"]';
const layoutDialog = layoutCandidate?.closest?.(dialogSelector);
+ // Empty Gmail drafts can have a disabled Send button. Their dedicated
+ // body editor is compose evidence; a generic filter textarea is not.
+ const verifiedGmailBody = params.adapterName === 'gmail'
+ && layoutCandidate?.matches?.('[contenteditable="true"][role="textbox"]')
+ && (layoutCandidate.getAttribute('g_editable') === 'true'
+ || !!layoutDialog?.querySelector?.('input[name="subjectbox"]'));
const layoutInComposeDialog = !!layoutDialog
&& !verifiedNavigationEditable(layoutCandidate)
&& layoutCandidate.matches?.('textarea,[contenteditable="true"],[role="textbox"]:not(input)')
&& Array.from(layoutDialog.querySelectorAll('button,[role="button"],input[type="submit"],input[type="button"],[data-action]'))
.some(control => visible(control) && control.closest(dialogSelector) === layoutDialog
- && (_hasMessageCommitName(control.getAttribute('aria-label') || control.value || control.innerText || control.textContent)
+ && ((_hasMessageCommitName(control.getAttribute('aria-label') || control.value || control.innerText || control.textContent)
+ && (_isEligibleTextClickTarget(control) || verifiedGmailBody))
|| verifiedLinkedInPublicPostControl(control)));
const layoutComposer = layoutCandidate
&& (layoutInComposeDialog
@@ -5299,14 +5319,17 @@
return !!control.closest?.('[class*="msg-"],[class*="messaging"],[id*="messaging"],[data-messaging],[data-test-messaging],[role="log"]');
} catch { return false; }
})();
- // LinkedIn is the strictest contract: every control that may act
- // without a composer has a verified classifier above (post entry,
- // public Post, navigation). A control that matched none of them is
- // unverified, so it is NOT proven non-message. A button-like
- // control or a link the classifier saw but declined to verify
- // (fragment, script:, mailto:, profile, unknown route) fails closed
- // instead of being approved.
- const linkedInUnverified = params.adapterName === 'linkedin' && (
+ // Known compose surfaces and unverified composer openers stay protected.
+ // Ordinary feed/profile controls do not become message actions merely
+ // because LinkedIn's navigation classifier has no matching route.
+ const composeDialog = _composedClosestElement(control, 'dialog,[role="dialog"],[role="alertdialog"]');
+ const linkedInComposeSurface = params.adapterName === 'linkedin' && (
+ /^start a post$/i.test(actionLabel)
+ || /^\/(?:messaging(?:\/|$)|sharing\/compose(?:\/|$))/.test(location.pathname)
+ || !!_composedClosestElement(control, '.share-box,[class*="msg-"],[class*="messaging"],[id*="messaging"],[data-messaging],[data-test-messaging],[role="log"]')
+ || (composeDialog && Array.from(composeDialog.querySelectorAll('[contenteditable="true"],textarea')).some(visible))
+ );
+ const linkedInUnverified = linkedInComposeSurface && (
control.matches?.('button,[role="button"],input[type="submit"],input[type="button"],[data-action]') === true
|| (control.matches?.('a[href]') === true && linkedInNavigation === 'none')
);
diff --git a/test/fixtures/interaction-review-regressions.mjs b/test/fixtures/interaction-review-regressions.mjs
index f7a96c502..4517fb38c 100644
--- a/test/fixtures/interaction-review-regressions.mjs
+++ b/test/fixtures/interaction-review-regressions.mjs
@@ -7,6 +7,94 @@ export function registerInteractionReviewRegressions({
['chrome', test, Agent],
['firefox', firefoxTest, FirefoxAgent],
]) {
+ register(`${kind}: passive primary text cannot outrank an actionable Search button`, async page => {
+ await setupContentHtml(page, `<!doctype html><style>
+ #banner { position:fixed;top:40px;left:40px;width:100px;height:40px }
+ #composer { position:fixed;bottom:20px;left:40px;width:260px;height:40px }
+ #go { position:fixed;bottom:20px;left:320px;width:100px;height:40px }
+ </style>
+ <div id="banner" aria-label="Search">Search</div>
+ <textarea id="composer">Draft</textarea>
+ <button id="go" aria-label="Search">πŸ”</button>`, kind);
+ await page.evaluate(() => {
+ window.fixtureClicks = [];
+ for (const id of ['banner', 'go']) {
+ document.getElementById(id).addEventListener('click', () => window.fixtureClicks.push(id));
+ }
+ });
+ const args = { text: 'Search', textMatch: 'exact' };
+ const probe = await call(page, 'probe_message_recipient_guard', { tool: 'click', args, adapterName: 'gmail' });
+ // Only the real button is adjacent to the composer. This also verifies
+ // that preflight and dispatch resolve the same control.
+ assert.equal(probe.messageSend, true, JSON.stringify(probe));
+ assert.equal((await call(page, 'click', args)).success, true);
+ assert.deepEqual(await page.evaluate(() => window.fixtureClicks), ['go']);
+ });
+
+ register(`${kind}: attribute fallback text retains ambiguity between different controls`, async page => {
+ for (const attribute of ['placeholder', 'title', 'aria-label']) {
+ await setupContentHtml(page, `<!doctype html>
+ <input id="q" ${attribute}="Search" ${attribute !== 'aria-label' ? 'aria-label="Search people"' : ''}>
+ <button id="go" aria-label="Search">πŸ”</button>`, kind);
+ await page.evaluate(() => {
+ window.fixtureClicks = [];
+ document.addEventListener('click', event => window.fixtureClicks.push(event.target.id));
+ });
+ const args = { text: 'Search', textMatch: 'exact' };
+ const probe = await call(page, 'probe_message_recipient_guard', { tool: 'click', args, adapterName: 'gmail' });
+ assert.equal(probe.conclusive, false, JSON.stringify({ attribute, probe }));
+ const clicked = await call(page, 'click', args);
+ assert.equal(clicked.success, false, JSON.stringify({ attribute, clicked }));
+ assert.match(clicked.error, /ambiguous/i);
+ assert.equal(clicked.candidates.length, 2, JSON.stringify(clicked));
+ assert.deepEqual(await page.evaluate(() => window.fixtureClicks), []);
+ }
+ });
+
+ register(`${kind}: LinkedIn ordinary browsing remains available without a composer`, async page => {
+ await page.route('**/*', route => route.fulfill({ contentType: 'text/html', body: '<!doctype html>' }));
+ await page.goto('https://www.linkedin.com/feed/');
+ await setupContentHtml(page, `<!doctype html><main>
+ <button id="follow">Follow</button><button id="like">Like</button>
+ <button id="connect">Connect</button><button id="filters" data-action="filters">Filters</button>
+ <input id="apply" type="submit" value="Apply">
+ <a id="profile" href="/in/jane-doe/">Jane Doe</a>
+ <a id="job" href="/jobs/view/123/">Job details</a>
+ <a id="fragment" href="#details">Details</a>
+ <a id="script" href="javascript:void(0)">Menu</a>
+ <a id="email" href="mailto:[email protected]">Email Jane</a>
+ <div class="msg-form"><button id="message-action">Confirm delivery</button></div>
+ <button id="send">Send invitation</button>
+ </main>`, kind);
+ await page.evaluate(() => {
+ window.fixtureClicks = [];
+ document.addEventListener('click', event => {
+ event.preventDefault();
+ window.fixtureClicks.push(event.target.id);
+ });
+ });
+ const agent = new AgentClass({ getActive: () => ({ supportsVision: false }) });
+ agent._messageRecipientContentProbe = (_, params) => call(page, 'probe_message_recipient_guard', params);
+ const ids = ['follow', 'like', 'connect', 'filters', 'apply', 'profile', 'job', 'fragment', 'script', 'email'];
+ for (const route of ['/feed/', '/in/jane-doe/', '/jobs/']) {
+ await page.evaluate(route => history.replaceState({}, '', route), route);
+ for (const id of ids) {
+ const args = { selector: '#' + id };
+ const probe = await call(page, 'probe_message_recipient_guard', { tool: 'click', args, adapterName: 'linkedin' });
+ assert.equal(probe.messageSend, false, JSON.stringify({ route, id, probe }));
+ assert.equal(probe.conclusive, true, JSON.stringify({ route, id, probe }));
+ assert.equal(await agent._messageRecipientGuardBlock(1, 'click', args, page.url()), null, id);
+ assert.equal((await call(page, 'click', args)).success, true, id);
+ }
+ for (const id of ['message-action', 'send']) {
+ assert.equal((await agent._messageRecipientGuardBlock(1, 'click', { selector: '#' + id }, page.url()))?.noDispatch, true, id);
+ }
+ }
+ assert.deepEqual(await page.evaluate(() => window.fixtureClicks), [...ids, ...ids, ...ids]);
+ await page.evaluate(() => history.replaceState({}, '', '/messaging/'));
+ assert.equal((await agent._messageRecipientGuardBlock(1, 'click', { selector: '#filters' }, page.url()))?.noDispatch, true);
+ });
+
register(`${kind}: text clicks prefer eligible controls before visible text`, async page => {
for (const variant of ['disabled', 'aria-disabled', 'fieldset', 'covered', 'enabled']) {
await setupContentHtml(page, `<!doctype html>
@@ -83,6 +171,22 @@ export function registerInteractionReviewRegressions({
tool: 'click', args: { selector: '#search' }, adapterName: 'gmail',
});
assert.equal(searchProbe.messageSend, false, JSON.stringify(searchProbe));
+ for (const disabled of ['disabled', 'aria-disabled', 'fieldset']) {
+ await page.evaluate(disabled => {
+ const decoy = document.createElement('div');
+ decoy.id = 'decoy';
+ decoy.innerHTML = disabled === 'fieldset'
+ ? '<fieldset disabled><button>Send</button></fieldset>'
+ : '<button ' + (disabled === 'disabled' ? 'disabled' : 'aria-disabled="true"') + '>Send</button>';
+ document.querySelector('[role=dialog]').append(decoy);
+ }, disabled);
+ const probe = await call(page, 'probe_message_recipient_guard', {
+ tool: 'click', args: { selector: '#search' }, adapterName: 'gmail',
+ });
+ assert.equal(probe.messageSend, false, JSON.stringify({ disabled, probe }));
+ assert.equal(await agent._messageRecipientGuardBlock(1, 'click', { selector: '#search' }, page.url()), null);
+ await page.locator('#decoy').evaluate(el => el.remove());
+ }
// A real upper-page composer must still require a recipient.
await page.evaluate(() => {
document.querySelector('[role=dialog]').setAttribute('aria-label', 'New Message');
@@ -96,6 +200,24 @@ export function registerInteractionReviewRegressions({
assert.equal(sendProbe.messageSend, true, JSON.stringify(sendProbe));
assert.equal(sendProbe.composerAvailable, true, JSON.stringify(sendProbe));
assert.equal((await agent._messageRecipientGuardBlock(1, 'click', { selector: '#send' }, page.url()))?.noDispatch, true);
+ // A disabled Send button is valid in an empty real Gmail draft, where
+ // the dedicated body editor supplies the missing compose evidence.
+ await page.evaluate(() => {
+ const editor = document.createElement('div');
+ editor.contentEditable = 'true';
+ editor.setAttribute('role', 'textbox');
+ editor.setAttribute('g_editable', 'true');
+ editor.style.cssText = 'width:300px;height:40px';
+ document.querySelector('#words').replaceWith(editor);
+ document.querySelector('#send').disabled = true;
+ editor.focus();
+ });
+ const emptyDraft = await call(page, 'probe_message_recipient_guard', {
+ tool: 'observe_active_conversation', adapterName: 'gmail',
+ });
+ assert.equal(emptyDraft.composerAvailable, true, JSON.stringify(emptyDraft));
+ assert.equal(emptyDraft.composerEmpty, true, JSON.stringify(emptyDraft));
+ assert.equal((await agent._messageRecipientGuardBlock(1, 'press_keys', { key: 'Enter' }, page.url()))?.noDispatch, true);
});
}
}
diff --git a/test/fixtures/message-recipient-navigation.mjs b/test/fixtures/message-recipient-navigation.mjs
index f0fa578d1..fa948800c 100644
--- a/test/fixtures/message-recipient-navigation.mjs
+++ b/test/fixtures/message-recipient-navigation.mjs
@@ -553,18 +553,20 @@ export function registerMessageRecipientNavigationFixtures({
});
register(`${kind}: LinkedIn post entry classification rejects send and publish lookalikes`, async (page) => {
- const { guard } = await setup(page);
+ const { guard, probe } = await setup(page);
await addPostEntry(page);
for (const [attribute, value] of [
['type', 'submit'], ['aria-label', 'Send'], ['form', 'chat'], ['disabled', ''], ['aria-disabled', 'true'],
]) {
await page.locator('#start-post').evaluate((el, [key, value]) => el.setAttribute(key, value), [attribute, value]);
- assert.equal((await guard('click', { selector: '#start-post' }))?.noDispatch, true, attribute);
+ assert.notEqual((await probe('click', { selector: '#start-post' })).composerSetup, true, attribute);
+ if (attribute === 'aria-label') assert.equal((await guard('click', { selector: '#start-post' }))?.noDispatch, true);
await page.locator('#start-post').evaluate((el, key) => el.removeAttribute(key), attribute);
}
for (const label of ['Post', 'Send', 'Start a post and send', 'Photo']) {
await page.locator('#start-post').evaluate((el, text) => { el.textContent = text; }, label);
- assert.equal((await guard('click', { selector: '#start-post' }))?.noDispatch, true, label);
+ assert.notEqual((await probe('click', { selector: '#start-post' })).composerSetup, true, label);
+ if (/Send|send/.test(label)) assert.equal((await guard('click', { selector: '#start-post' }))?.noDispatch, true, label);
}
await page.locator('#start-post').evaluate(el => { el.textContent = 'Start a post'; });
await page.evaluate(() => history.replaceState(null, '', '/messaging/'));
@@ -578,14 +580,14 @@ export function registerMessageRecipientNavigationFixtures({
document.querySelector('main').append(wrapper);
wrapper.firstChild.append(document.querySelector('#post-entry'));
}, markup);
- assert.equal((await guard('click', { text: 'Start a post' }))?.noDispatch, true, markup);
+ assert.notEqual((await probe('click', { text: 'Start a post' })).composerSetup, true, markup);
await page.evaluate(() => {
document.querySelector('main').append(document.querySelector('#post-entry'));
document.querySelector('#entry-wrapper').remove();
});
}
await page.evaluate(() => document.body.append(document.querySelector('#post-entry')));
- assert.equal((await guard('click', { text: 'Start a post' }))?.noDispatch, true, 'outside feed main');
+ assert.notEqual((await probe('click', { text: 'Start a post' })).composerSetup, true, 'outside feed main');
assert.deepEqual(await page.evaluate(() => window.fixtureClicks), []);
});
@@ -612,7 +614,7 @@ export function registerMessageRecipientNavigationFixtures({
const result = await guard('click', { selector: '#close-contact-info' });
// Use a visible unresolved action so this is a classification failure,
// not a stale/missing target that a fresh page read could repair.
- await page.evaluate(() => document.querySelector('main').insertAdjacentHTML('beforeend', '<button id="unknown">Unknown action</button>'));
+ await page.evaluate(() => document.querySelector('main').insertAdjacentHTML('beforeend', '<div class="msg-form"><button id="unknown">Unknown action</button></div>'));
const missingComposer = await guard('click', { selector: '#unknown' });
assert.equal(missingComposer?.noDispatch, true);
assert.equal(missingComposer?.reasonCode, 'message_send_classification_inconclusive');
@@ -941,10 +943,6 @@ export function registerMessageRecipientNavigationFixtures({
}
await page.evaluate(() => { document.querySelector('#chat').hidden = true; });
for (const href of [
- '#',
- 'javascript:void(0)',
- 'mailto:[email protected]',
- '/in/alice/',
'/safety/go/?url=https%3A%2F%2Fportfolio.example%2F',
'/safety/go/',
'/safety/go/?url=javascript%3Aalert(1)',