Skip to content

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

Observe accessible-name relationship changes

Barack Sokullu9dd1a00139d7
diff --git a/src/chrome/src/content/page-monitor.js b/src/chrome/src/content/page-monitor.js
index 2c89ef6d8..688066ccf 100644
--- a/src/chrome/src/content/page-monitor.js
+++ b/src/chrome/src/content/page-monitor.js
@@ -360,7 +360,9 @@
[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'),
- el.getAttribute('name'), el.getAttribute('placeholder'), el.getAttribute('aria-required'), el.getAttribute('aria-readonly'),
+ el.getAttribute('id'), el.getAttribute('for'), 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'),
el.getAttribute('aria-expanded'), el.getAttribute('aria-selected'), el.getAttribute('aria-checked'),
el.getAttribute('aria-valuenow'), el.getAttribute('aria-valuetext'),
el.getAttribute('aria-pressed'),
@@ -438,7 +440,8 @@
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', 'name', 'placeholder', 'aria-required', 'aria-readonly',
+ attributeFilter: ['role', 'aria-label', 'id', 'for', 'name', 'placeholder', 'title', 'alt', 'aria-labelledby',
+ 'aria-required', 'aria-readonly', 'contenteditable', 'tabindex', 'onclick', 'required',
'aria-expanded', 'aria-selected', 'aria-checked', 'aria-pressed', 'aria-disabled',
'type', 'href', 'target', 'download', 'action', 'formaction', 'formtarget',
'aria-valuenow', 'aria-valuetext', 'aria-hidden', 'hidden', 'disabled', 'readonly', 'checked', 'selected', 'open', 'popover', 'inert', 'class', 'style'] });
diff --git a/src/firefox/src/content/page-monitor.js b/src/firefox/src/content/page-monitor.js
index 2c89ef6d8..688066ccf 100644
--- a/src/firefox/src/content/page-monitor.js
+++ b/src/firefox/src/content/page-monitor.js
@@ -360,7 +360,9 @@
[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'),
- el.getAttribute('name'), el.getAttribute('placeholder'), el.getAttribute('aria-required'), el.getAttribute('aria-readonly'),
+ el.getAttribute('id'), el.getAttribute('for'), 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'),
el.getAttribute('aria-expanded'), el.getAttribute('aria-selected'), el.getAttribute('aria-checked'),
el.getAttribute('aria-valuenow'), el.getAttribute('aria-valuetext'),
el.getAttribute('aria-pressed'),
@@ -438,7 +440,8 @@
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', 'name', 'placeholder', 'aria-required', 'aria-readonly',
+ attributeFilter: ['role', 'aria-label', 'id', 'for', 'name', 'placeholder', 'title', 'alt', 'aria-labelledby',
+ 'aria-required', 'aria-readonly', 'contenteditable', 'tabindex', 'onclick', 'required',
'aria-expanded', 'aria-selected', 'aria-checked', 'aria-pressed', 'aria-disabled',
'type', 'href', 'target', 'download', 'action', 'formaction', 'formtarget',
'aria-valuenow', 'aria-valuetext', 'aria-hidden', 'hidden', 'disabled', 'readonly', 'checked', 'selected', 'open', 'popover', 'inert', 'class', 'style'] });
diff --git a/test/page-monitor-ui.mjs b/test/page-monitor-ui.mjs
index c1cd3c02b..5aebbc22f 100644
--- a/test/page-monitor-ui.mjs
+++ b/test/page-monitor-ui.mjs
@@ -1564,7 +1564,7 @@ for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {
await page.waitForTimeout(180);
const changes = [
['name', 'updated-name'], ['placeholder', 'Updated placeholder'],
- ['aria-required', 'true'], ['aria-readonly', 'true'],
+ ['aria-required', 'true'], ['aria-readonly', 'true'], ['aria-labelledby', 'updated-accessible-name'],
];
for (const [attribute, value] of changes) {
const guard = await page.evaluate(attribute => {