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
Accept an article named only by its own label as an owner only when its text is covered
Claude947a32b7befa
diff --git a/src/chrome/src/content/page-monitor.js b/src/chrome/src/content/page-monitor.jsindex fad587170..07a1424ea 100644--- a/src/chrome/src/content/page-monitor.js+++ b/src/chrome/src/content/page-monitor.js@@ -1671,8 +1671,14 @@// page names and lets take focus as one item (namedFocusableArticle).const feedItem = owner.matches('article[aria-posinset],[role="article"][aria-posinset]')&& !!owner.parentElement?.closest('[role="feed"]');+ // A page-named article is accepted only on its name when nothing else+ // identifies it, and its name does not bind the post's own text: that+ // text must be covered below, or a re-rendered article keeping the name+ // and the controls could carry the earlier post's decision.+ const namedArticleOnly = !meaningfulOwner && headings.length === 0 && identities.length === 0+ && !owner.matches(modelEntityIdentitySelector) && !feedItem && !namedItemOwner && namedFocusableArticle(owner);meaningfulOwner ||= headings.length > 0 || identities.length > 0 || owner.matches(modelEntityIdentitySelector) || feedItem- || namedItemOwner || namedFocusableArticle(owner);+ || namedItemOwner || namedArticleOnly;if (meaningfulOwner) {const images = [...owner.querySelectorAll('img')].filter(node => belongs(node, navigationOwner)&& !node.closest('input,textarea,[contenteditable]:not([contenteditable="false"])')@@ -1716,6 +1722,7 @@for (const link of inlinePostOwner.accountLinks) if (!addNode(link, { text: true, control: true })) return null;} else if (navigationOwner) meaningfulOwner = dialogTextIsCovered(owner, boundTextNodes, addNode, dialogIdentities, form, namedNavigationControls, visualImages) && !uncoveredLabel;else if (nativeFileSection) meaningfulOwner = dialogTextIsCovered(owner, boundTextNodes, addNode, dialogIdentities, form, null, visualImages) && !uncoveredLabel;+ else if (namedArticleOnly) meaningfulOwner = dialogTextIsCovered(owner, boundTextNodes, addNode, dialogIdentities, form, null, visualImages) && !uncoveredLabel;else meaningfulOwner ||= (headingFreeDialog || headingFreeNamedScope)&& dialogTextIsCovered(owner, boundTextNodes, addNode, dialogIdentities, form, null, visualImages) && !uncoveredLabel;}diff --git a/src/firefox/src/content/page-monitor.js b/src/firefox/src/content/page-monitor.jsindex fad587170..07a1424ea 100644--- a/src/firefox/src/content/page-monitor.js+++ b/src/firefox/src/content/page-monitor.js@@ -1671,8 +1671,14 @@// page names and lets take focus as one item (namedFocusableArticle).const feedItem = owner.matches('article[aria-posinset],[role="article"][aria-posinset]')&& !!owner.parentElement?.closest('[role="feed"]');+ // A page-named article is accepted only on its name when nothing else+ // identifies it, and its name does not bind the post's own text: that+ // text must be covered below, or a re-rendered article keeping the name+ // and the controls could carry the earlier post's decision.+ const namedArticleOnly = !meaningfulOwner && headings.length === 0 && identities.length === 0+ && !owner.matches(modelEntityIdentitySelector) && !feedItem && !namedItemOwner && namedFocusableArticle(owner);meaningfulOwner ||= headings.length > 0 || identities.length > 0 || owner.matches(modelEntityIdentitySelector) || feedItem- || namedItemOwner || namedFocusableArticle(owner);+ || namedItemOwner || namedArticleOnly;if (meaningfulOwner) {const images = [...owner.querySelectorAll('img')].filter(node => belongs(node, navigationOwner)&& !node.closest('input,textarea,[contenteditable]:not([contenteditable="false"])')@@ -1716,6 +1722,7 @@for (const link of inlinePostOwner.accountLinks) if (!addNode(link, { text: true, control: true })) return null;} else if (navigationOwner) meaningfulOwner = dialogTextIsCovered(owner, boundTextNodes, addNode, dialogIdentities, form, namedNavigationControls, visualImages) && !uncoveredLabel;else if (nativeFileSection) meaningfulOwner = dialogTextIsCovered(owner, boundTextNodes, addNode, dialogIdentities, form, null, visualImages) && !uncoveredLabel;+ else if (namedArticleOnly) meaningfulOwner = dialogTextIsCovered(owner, boundTextNodes, addNode, dialogIdentities, form, null, visualImages) && !uncoveredLabel;else meaningfulOwner ||= (headingFreeDialog || headingFreeNamedScope)&& dialogTextIsCovered(owner, boundTextNodes, addNode, dialogIdentities, form, null, visualImages) && !uncoveredLabel;}diff --git a/test/page-monitor-feed-items.mjs b/test/page-monitor-feed-items.mjsindex 1174b97cd..39e5a00b4 100644--- a/test/page-monitor-feed-items.mjs+++ b/test/page-monitor-feed-items.mjs@@ -239,6 +239,21 @@ for (const build of ['chrome', 'firefox']) {} finally { await f.browser.close(); }});+ test(`${build} on ${engineName}: an article named only by a generic label is not an owner of its post`, async () => {+ // A generic aria-label ("Post") says nothing about which post this is,+ // and the name does not bind the post's text, so a virtualized cell+ // re-rendered with another post (same controls and links) could keep the+ // earlier decision. Without the name tying it to the content, the+ // article owns nothing; a label that points at the content does (X).+ const timeline = xTimeline(xPost(1, { article: 'aria-label="Post" tabindex="0"' }) + xPost(2, { name: 'Ada', handle: 'ada' }));+ const f = await open(engine, build, timeline, 'bookmark1');+ try {+ const result = await f.validate();+ assert.equal(result.ready, false);+ assert.equal(result.certificationFailure, 'owner_unresolved');+ } finally { await f.browser.close(); }+ });+test(`${build} on ${engineName}: an article that is not offered as one named, focusable, linked item owns nothing new`, async () => {const cases = [['unfocusable', xPost(1, { article: 'aria-labelledby="name{n} text{n} group{n}"' })],