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
Fix sequential release upload binding
Barack Sokullu264701b7dea7
diff --git a/docs/accessibility-tree-and-refs.md b/docs/accessibility-tree-and-refs.mdindex 805d862d6..854c296c5 100644--- a/docs/accessibility-tree-and-refs.md+++ b/docs/accessibility-tree-and-refs.md@@ -36,7 +36,7 @@ dialog "Add a product" [ref_166]**Parameters:**| Parameter | Default | Description ||---|---|---|-| `filter` | `'all'` | `'all'` (whole rendered document scope), `'visible'` (in-viewport, visible nodes), `'interactive'` (clickable/typeable only) |+| `filter` | `'all'` | `'all'` (whole document scope, including hidden nodes), `'visible'` (in-viewport, visible nodes), `'interactive'` (clickable/typeable only) || `maxDepth` | `15` | Max tree depth to descend || `maxChars` | Filter-dependent | Structured page size. Defaults to 6,000 for `all`, 3,000 for `visible`, and 3,500 for `interactive`; larger trees return continuation metadata. See [adaptive read windows](#adaptive-read-windows). || `ref_id` | — | Anchor at a specific element's subtree instead of `document.body` |@@ -49,6 +49,10 @@ role "accessible name" [ref_id] href="..." type="..." placeholder="..." value=".Indentation is 1 space per tree-depth level (skipped generic containers don't bump depth).+`filter: 'all'` retains hidden nodes and marks them `hidden=true`, including+inactive status and error messages. Their presence alone does not establish a+current upload or failure; inspect visible status and the staged asset rows.+### `__wb_ax_lookup(ref_id)`Resolves a `ref_N` string back to the live DOM `Element`. Returns `null` if the element was removed from the DOM.diff --git a/package.json b/package.jsonindex 27bdc8997..de7fed06b 100644--- a/package.json+++ b/package.json@@ -98,7 +98,7 @@"test:shard:runtime-unit": "node --test test/skill-download-wait.mjs && node --test test/agent-lifecycle.mjs test/runtime-startup.mjs test/run-ui-scheduled-lifecycle.mjs test/transport-deadlines.mjs test/cdp-worker-restart.mjs test/bot-memory.mjs test/bot-memory-click-guard.mjs test/bot-memory-registries.mjs test/bot-memory-cloud-controller.mjs test/cdp-clear-receipt.mjs test/cdp-field-submit-recovery.mjs test/conversation-persistence.mjs test/context-live-tool-group.mjs test/integration-races.mjs test/watch-completion-checkpoint.mjs test/runtime-model-identity.mjs test/provider-message-privacy.mjs test/runtime-task-authority.mjs test/planner-repair-authority.mjs test/runtime-progress-continuation.mjs test/chat-resume-chain.mjs test/chat-resume-completion.mjs test/native-chat-execution-ledger.mjs test/chat-send-dispatch-result.mjs test/chat-reply-dedup-race.mjs test/memcode-lifecycle.mjs test/runtime-peer-review.mjs test/read-continuation-schema.mjs test/completion-submit-acknowledgement.mjs test/completion-live-status.mjs test/completion-iframe-submit.mjs test/form-validation-alert-readings.mjs test/control-effect-readings.mjs test/trusted-retry-readings.mjs test/completion-semantic-commit.mjs test/completion-diagnostics.mjs test/mastodon-publication.mjs test/calculator.mjs test/chat-recovery-protocol.mjs test/chat-pending-reconciliation.mjs test/semantic-page-retry.mjs test/pdf-detection.mjs test/runtime-lifecycle.mjs test/collection-read-progress.mjs test/network-lifecycle.mjs test/text-write-cancellation.mjs test/trusted-field-preparation.mjs test/draftjs-text.mjs test/rich-text-frameworks.mjs test/cdp-managed-text-selection.mjs test/firefox-rich-text-readback.mjs test/contenteditable-beforeinput.mjs test/trusted-field-preparation-ownership.mjs test/typing-preparation-geometry.mjs test/chat-steering.mjs test/resource-mutation-guards.mjs test/completion-steering-receipt-authority.mjs test/steering-revision-recovery.mjs test/pending-clarification-hydration.mjs test/permission-steering-wakeup.mjs test/pure-calculation-reply.mjs test/pure-calculation-tools.mjs test/page-feedback.mjs test/page-feedback-progress.mjs test/page-feedback-unbindable-target.mjs test/rich-text-preflight-page-change.mjs test/keyboard-receiver-frame.mjs test/ask-response-scope.mjs test/ask-completion-churn.mjs test/page-feedback-policy.mjs test/research-escalation-page-feedback.mjs test/page-feedback-transport-races.mjs test/page-feedback-recovery.mjs test/telegram-read-preparation-agent.mjs test/media-download-agent-handler.mjs test/code-scanning-url-recipient.mjs test/apocalypse-comm-parsing.mjs test/apocalypse-scalar-decoding.mjs test/bitgpu-chat-security.mjs test/social-media-url-upgrades.mjs test/downloaded-file-saved-bytes.mjs test/downloaded-file-local-probe.mjs test/formless-verification-recovery.mjs test/file-upload-accept.mjs test/file-upload-accept-agent.mjs test/workflow-route-generic-completion.mjs test/release-publication-completion.mjs test/workflow-implicit-metadata.mjs test/workflow-field-readings.mjs test/workflow-field-anchors.mjs test/user-turn-kind.mjs test/follow-up-task-context.mjs test/completion-current-execution-evidence.mjs test/video-upload-attachment.mjs test/feedback-automatic-churn.mjs test/feedback-navigation-idle.mjs test/feedback-run-boundaries.mjs test/feedback-ask-viewing.mjs test/lifecycle-terminal-done.mjs test/incomplete-completion-recovery.mjs test/lifecycle-planner-digest.mjs test/lifecycle-steering-latency.mjs test/lifecycle-steering-restart.mjs test/lifecycle-vision-fallback.mjs test/delivery-click-locks.mjs test/guards-steering-receipts.mjs test/terminal-user-messages.mjs test/improver-providers.mjs test/improver-providers-agent.mjs test/improver-guards-ledger.mjs test/improver-guards-tools.mjs test/improver-clarify.mjs test/improver-clarify-scheduler.mjs test/improver-misc.mjs test/improver-forms.mjs test/improver-forms-strict-secrets.mjs test/improver-content-press-keys-hint.mjs && npm run test:plan-notifications","test:shard:browser-a": "node --test test/captcha-draft-content.mjs test/captcha-challenge-surfaces.mjs && node test/bot-memory-dom.mjs && node test/bot-memory-click-dom.mjs && node test/ui-content-lifecycle.mjs && node --test test/native-telegram-chat.mjs test/native-telegram-recipient.mjs test/telegram-native-baseline.mjs test/telegram-native-latest.mjs test/native-chat-pre-enter-draft.mjs test/chat-draft-dispatch-ownership.mjs test/native-telegram-alias-preparation.mjs test/telegram-read-preparation-content.mjs test/queued-composer-ownership.mjs test/onboarding-provider-ready.mjs test/workflow-native-targets.mjs test/native-whatsapp-chat.mjs test/native-chat-context-identity.mjs test/native-whatsapp-contact.mjs test/whatsapp-native-bootstrap.mjs test/whatsapp-drawer-identity.mjs test/whatsapp-read-latest.mjs test/whatsapp-read-preparation.mjs test/whatsapp-chat-completion.mjs test/whatsapp-chat-restart.mjs test/chat-goal-lifecycle.mjs test/chat-completion.mjs test/chat-generic-dispatch.mjs test/completion-live-status-browser.mjs test/native-confirmation-visibility.mjs test/native-button-preparation.mjs test/read-continuation-browser.mjs test/iframe-preparation-focus.mjs test/contenteditable-literal.mjs test/native-chat-empty-editor.mjs test/native-chat-trusted-clear.mjs test/chat-steering-ui.mjs test/recipient-confirmation-ui.mjs test/assistant-message-visibility-ui.mjs test/page-monitor-ui.mjs test/x-compose-trusted-typing.mjs test/page-monitor-dialog.mjs test/page-monitor-dialog-native.mjs test/page-monitor-inline-post.mjs test/bluesky-composer-context.mjs test/page-monitor-anchored.mjs test/page-monitor-upload-owner.mjs test/page-monitor-upload-release.mjs test/page-monitor-native-controls.mjs test/page-monitor-native-preparation.mjs test/native-preparation-cold.mjs test/page-monitor-navigation.mjs test/page-monitor-main-owner.mjs test/page-monitor-collateral-controls.mjs test/accessibility-tree-scoped-budget.mjs test/ax-reference-origin.mjs test/page-monitor-decorative-hit.mjs test/social-ui-navigation.mjs test/native-resource-deletion-binding.mjs test/native-mastodon-confirmation.mjs test/dropdown-menu-inventory.mjs test/page-monitor-passive-progress.mjs test/page-monitor-feed-items.mjs test/media-download-binding.mjs test/media-download-capture-integration.mjs test/social-media-downloader-reinjection.mjs test/upload-file-local-state-guidance.mjs test/monitor-intervention-contract.mjs test/monitor-owned-geometry.mjs test/monitor-viewport-remainder.mjs test/monitor-scroll-churn.mjs test/monitor-local-attribution.mjs test/monitor-lifecycle-leaks.mjs test/lifecycle-run-ui.mjs test/lifecycle-menu-prompts-held.mjs test/delivery-cdp-input.mjs test/delivery-click-ax-response-loss.mjs test/delivery-native-button-geometry.mjs test/delivery-hover-transition.mjs test/delivery-native-button-route.mjs test/delivery-dispatch-boundary.mjs test/delivery-stop-compound.mjs test/guards-control-classification.mjs test/guards-unbound-deletion.mjs test/submit-probe-readings.mjs test/improver-content-account-chrome.mjs test/improver-content-recipient.mjs test/improver-content-truncated-replacement.mjs test/improver-forms-probe.mjs test/improver-misc-trace-browser.mjs","test:shard:browser-b1": "node test/message-recipient-upload.mjs && node test/message-recipient-clarify-binding.mjs && node --test test/message-recipient-whatsapp.mjs test/message-control-readings.mjs && node test/quality/integration-mv3.mjs --full-form && node test/quality/integration-mv3.mjs --batch && node test/quality/literal-calculate-midrun-mv3.mjs && node test/quality/ask-completion-churn-mv3.mjs && node test/quality/ask-person-activity-mv3.mjs && node test/quality/telegram-cold-preparation-mv3.mjs && node test/quality/native-chat-mv3.mjs && node test/quality/native-chat-presubmit-mv3.mjs && node test/quality/cloud-bot-memory-mv3.mjs",- "test:shard:browser-b2": "node test/quality/whatsapp-contact-matrix.mjs && node test/quality/pdf-detection-mv3.mjs && node test/quality/download-upload-mv3.mjs && node test/quality/upload-release-binding-mv3.mjs && node test/quality/release-review-world-mv3.mjs && node test/quality/downloaded-file-saved-bytes-mv3.mjs && node test/quality/file-upload-accept-mv3.mjs && node test/quality/bulk-resume-mv3.mjs && node test/quality/shared-action-guards-mv3.mjs && node test/quality/video-upload-attachment-mv3.mjs",+ "test:shard:browser-b2": "node test/quality/whatsapp-contact-matrix.mjs && node test/quality/pdf-detection-mv3.mjs && node test/quality/download-upload-mv3.mjs && node test/quality/upload-release-binding-mv3.mjs && node test/quality/upload-release-binding-mv3.mjs --selector-recovery && node test/quality/upload-release-binding-mv3.mjs --sequential-assets && node test/quality/release-review-world-mv3.mjs && node test/quality/downloaded-file-saved-bytes-mv3.mjs && node test/quality/file-upload-accept-mv3.mjs && node test/quality/bulk-resume-mv3.mjs && node test/quality/shared-action-guards-mv3.mjs && node test/quality/video-upload-attachment-mv3.mjs","test:shard:browser-c": "node test/quality/literal-frame-mv3.mjs && node test/quality/mastodon-publication-mv3.mjs && node test/quality/mastodon-reply-route-mv3.mjs && node test/quality/mastodon-deletion-mv3.mjs && node test/quality/mastodon-delete-confirmation-mv3.mjs && node test/quality/mastodon-delete-confirmation-mv3.mjs --menu-read && node test/quality/mastodon-delete-confirmation-mv3.mjs --vague && node test/quality/unbound-deletion-mv3.mjs && node test/quality/recipient-clarify-mv3.mjs && node test/quality/open-chat-recipients-mv3.mjs && node test/quality/correction-cross-site-mv3.mjs && node test/quality/anchored-action-mv3.mjs && node test/quality/inline-social-composer-mv3.mjs && node test/quality/x-compose-dialog-mv3.mjs && node test/quality/bluesky-composer-mv3.mjs && node test/quality/dropdown-menu-matrix.mjs && node test/quality/mastodon-deletion-navigation-mv3.mjs && node test/quality/semantic-navigation-matrix.mjs && node test/quality/workflow-replay-mv3.mjs && node test/quality/generative-media-mv3.mjs && node test/quality/cdp-worker-restart-mv3.mjs && node test/quality/steering-worker-restart-mv3.mjs","test:shard:tail": "node test/run.js && node test/selection-scope-restoration.mjs && node scripts/benchmark-offline-relevance.mjs && npm run test:security","test:composer-context": "node --test test/page-monitor-inline-post.mjs test/bluesky-composer-context.mjs && node test/quality/inline-social-composer-mv3.mjs && node test/quality/x-compose-dialog-mv3.mjs && node test/quality/bluesky-composer-mv3.mjs",diff --git a/src/chrome/src/agent/adapters.js b/src/chrome/src/agent/adapters.jsindex de5cd756c..6f901ad41 100644--- a/src/chrome/src/agent/adapters.js+++ b/src/chrome/src/agent/adapters.js@@ -15910,8 +15910,8 @@ const ADAPTERS = [notes: `- Username may only contain alphanumeric characters or single hyphens, and cannot begin or end with a hyphen.- Creating a release: navigate to /<owner>/<repo>/releases/new, choose/create the tag with the "Choose a tag" combobox, and verify the "Previous tag" range. If the user supplied no exact notes, prefer "Generate release notes" and review its output; otherwise preserve their text. Finish with "Publish release" or the adjacent "Save draft" as requested.-- On the release form, use named controls rather than unstable indexes (never reuse remembered element #38). The release body is a CodeMirror editor: click its "Describe this release" surface before typing.-- EDITING an existing release (URL pattern /<owner>/<repo>/releases/edit/<tag>): the file upload input is \`input#releases-upload\` (NOT a generic input[type="file"] — there are several on the page). Use \`upload_file({selector: "input#releases-upload", filePath: "..."})\` for each binary. After each upload, GitHub renders a small chip listing the filename in the "Attach binaries" area below the body editor — verify the chip appears with the correct filename before moving on. The commit button is green and says "Update release"; navigating away from the edit page WITHOUT clicking it discards the uploads. If you can't see "Update release" without scrolling, scroll down before clicking — don't navigate back to the dist folder thinking you need to re-fetch.+- On the release form, use named controls rather than unstable indexes (never reuse remembered element #38). The release body is a CodeMirror editor: click its "Describe this release" surface before typing. Read current upload status with filter="visible"; filter="all" also includes hidden loading/error templates, which do not establish an active failure.+- Release binaries on both /releases/new and /releases/edit/<tag>: call \`get_interactive_elements\` and use the exact selector on the asset input record (normally #releases-upload). The other file input belongs to Markdown attachments. Reuse each saved downloadId with \`upload_file\`; never guess a name selector or use generic input[type="file"]. After each attachment, inspect the visible asset row/status before attaching the next file. Finish with "Publish release", "Save draft", or "Update release" as requested, then verify every filename on the saved release page; navigating away before saving loses staged changes.- Files in a /tree/.../<folder> view (e.g. /tree/main/dist) can be downloaded via raw URLs of the form https://github.com/<owner>/<repo>/raw/<branch>/<path>. Once downloaded, the file is on local disk; do not re-download to "verify".- Creating a pull request: when no exact title was supplied, prefer the title field's Copilot button; for a blank description, prefer Copilot > "Summary". Review both suggestions and add missing rationale/testing context. Summary ignores existing description text, so preserve repository templates and user content; if Copilot is unavailable, draft normally. PR descriptions/comments use CodeMirror with a separate Markdown preview.- File browser: pressing "t" opens the fuzzy file finder (faster than navigating folders). When editing a repository file, verify the complete editor value before clicking "Commit changes"; then open or observe the new /commit/<sha> link so WebBrain can verify the raw file at that exact commit and reject duplicated or partial content.diff --git a/src/chrome/src/agent/page-feedback.js b/src/chrome/src/agent/page-feedback.jsindex 10e63dfbe..ef1b5ce6c 100644--- a/src/chrome/src/agent/page-feedback.js+++ b/src/chrome/src/agent/page-feedback.js@@ -229,7 +229,20 @@ export function pageFeedbackPendingResult() {}// The answer of a call whose target the observed certificate cannot bind.-function actionBindingUnavailableResult(run) {+function actionBindingUnavailableResult(run, name) {+ if (name === 'upload_file') {+ const reason = run.actionBindingUnavailableReason;+ const explanation = reason === 'target_ambiguous'+ ? 'The selector matches more than one element, so the intended file input cannot be bound.'+ : reason === 'target_unresolved'+ ? 'The requested file input could not be resolved on the current page.'+ : 'The requested file input was not covered by the observed action context.';+ return { success: false, skipped: true, dispatched: false, noDispatch: true, retryable: false,+ errorCode: 'action_binding_unavailable',+ ...(['target_ambiguous', 'target_unresolved', 'target_uncovered'].includes(reason) ? { bindingFailure: reason } : {}),+ recoveryRequired: 'get_interactive_elements',+ error: explanation + ' Nothing was attached. Call get_interactive_elements again, identify the intended file-input record by its upload widget context, and copy its exact selector into a new upload_file call with the same attachmentId, downloadId, or filePath. Do not guess a selector or click the upload control.' };+ }return { success: false, skipped: true, dispatched: false, noDispatch: true, retryable: false,errorCode: 'action_binding_unavailable',...(run.actionBindingUnavailableReason === 'target_ambiguous' ? { bindingFailure: 'target_ambiguous',@@ -1354,6 +1367,11 @@ export const pageFeedbackMethods = {run.actionCaptureTarget = safeAction(name, args);run.actionBindingUnavailable = `${name}:${JSON.stringify(args)}`;run.actionBindingUnavailableReason = response.reason;+ // The monitor may reject ambiguity before the upload resolver runs.+ // Preserve that resolver's required inventory step on this path too.+ if (name === 'upload_file' && response.reason === 'target_ambiguous') {+ this._uploadSelectorRecoveryRequired?.set(tabId, 0);+ }}if (owned && response.uncertified === true) {// The original node is unchanged, but its action context was never@@ -1377,7 +1395,7 @@ export const pageFeedbackMethods = {if (!run || typeof args?.selector !== 'string' || !args.selector.trim() || !this.constructor.STATE_CHANGE_TOOLS?.has(name)|| pageFeedbackCallPolicy(name, args, run.modelState, run.latestPage).kind !== 'bound_target') return null;if (await this._validatePageFeedbackAction(tabId, name, args, run.modelState, null, { answerOnly: true }) !== false) return null;- return run.actionBindingUnavailable === `${name}:${JSON.stringify(args)}` ? actionBindingUnavailableResult(run) : null;+ return run.actionBindingUnavailable === `${name}:${JSON.stringify(args)}` ? actionBindingUnavailableResult(run, name) : null;},_pageFeedbackBlocksCall(tabId, name, args = {}) {@@ -1760,7 +1778,7 @@ export function installPageFeedback(Agent) {if (modelBound) {const validated = await this._validatePageFeedbackAction(tabId, name, args, modelState, batchId);if (validated === false) return run.actionBindingUnavailable === `${name}:${JSON.stringify(args)}`- ? actionBindingUnavailableResult(run)+ ? actionBindingUnavailableResult(run, name): run.actionContextUnverified === true? { ...pageFeedbackPendingResult(), actionContextUnverified: true, errorCode: 'action_context_unverified',error: 'The requested control had no verified original action context. No action was dispatched; inspect the fresh bounded target observation before choosing another action.' }diff --git a/src/chrome/src/content/accessibility-tree.js b/src/chrome/src/content/accessibility-tree.jsindex 9fbc6b60f..1ebed6c56 100644--- a/src/chrome/src/content/accessibility-tree.js+++ b/src/chrome/src/content/accessibility-tree.js@@ -731,6 +731,35 @@return false;}+ let treeHiddenStateCache = null;+ function isHiddenTreeNode(el) {+ const cache = treeHiddenStateCache || new WeakMap();+ const pending = [];+ let node = el;+ for (; node?.nodeType === Node.ELEMENT_NODE && !cache.has(node); node = composedParent(node)) pending.push(node);+ let suppressed = cache.get(node)?.suppressed === true;+ let transparent = cache.get(node)?.transparent === true;+ while (pending.length) {+ const current = pending.pop();+ const style = window.getComputedStyle(current);+ const generatesBox = style.display !== 'contents';+ suppressed ||= current.getAttribute('aria-hidden') === 'true'+ || style.display === 'none' || (generatesBox && style.contentVisibility === 'hidden');+ // Top-layer boxes escape ancestor opacity, but not display/content+ // suppression or aria-hidden. Their own opacity still applies.+ if (transparent && (current.matches(':modal')+ || (current.hasAttribute('popover') && 'popover' in current && current.matches(':popover-open'))+ || current.matches(':fullscreen'))) transparent = false;+ // Box effects on display:contents do not affect its rendered children.+ transparent ||= generatesBox && style.opacity === '0';+ // Visibility can be restored by a child. Cache the inherited states+ // separately so siblings and anchored reads keep the same semantics.+ cache.set(current, { suppressed, transparent, hidden: suppressed || transparent || ['hidden', 'collapse'].includes(style.visibility) });+ }+ // Offscreen text, display:contents and CSS overrides of [hidden] render.+ return cache.get(el)?.hidden === true;+ }+function deepestOpenShadowHit(x, y) {let hit = document.elementFromPoint(x, y);const seen = new Set();@@ -1080,6 +1109,12 @@line += ' hidden=true';}} catch {}+ } else {+ // filter=all keeps inactive status/error templates as well as controls.+ // Without this marker their text can be mistaken for a live outcome.+ try {+ if (isHiddenTreeNode(el)) line += ' hidden=true';+ } catch {}}try {if (isInteractive(el) && isNodeOccluded(el)) {@@ -1839,6 +1874,8 @@}function generateAccessibilityTree(filter, maxDepth, maxChars, refId, page, expectedTreeRevision) {+ const previousHiddenStateCache = treeHiddenStateCache;+ treeHiddenStateCache = new WeakMap();jevCollector = filter === 'interactive' && !refId && (!page || page === 1) ? new Map() : null;lastJevSnapshot = null;jevSensitiveControlSeen = false;@@ -2043,6 +2080,7 @@viewport: { width: window.innerWidth, height: window.innerHeight },};} finally {+ treeHiddenStateCache = previousHiddenStateCache;if (jevCollector) {const controls = [...jevCollector.values()];const structure = fingerprintTreeContent(JSON.stringify(controls.map(({ value, checked, signature, ...control }) => control)));diff --git a/src/chrome/src/content/page-monitor.js b/src/chrome/src/content/page-monitor.jsindex 310667b1c..1298336cb 100644--- a/src/chrome/src/content/page-monitor.js+++ b/src/chrome/src/content/page-monitor.js@@ -1311,6 +1311,10 @@function nativeFileWidget(target) {if (!(target instanceof HTMLInputElement) || target.type !== 'file' || target.disabled|| target.closest('fieldset[disabled]')) return null;+ const targetStyle = getComputedStyle(target), targetRect = target.getBoundingClientRect();+ const hiddenTarget = targetStyle.display === 'none' || ['hidden', 'collapse'].includes(targetStyle.visibility)+ || Number(targetStyle.opacity) === 0 || targetStyle.contentVisibility === 'hidden'+ || (targetRect.width <= 1 && targetRect.height <= 1);// A transport-only wrapper may hide the input itself. Its visible widget// must still identify one exact file slot and one rendered activation// purpose; a hidden form, composer or arbitrary collection is not a widget.@@ -1343,9 +1347,17 @@hiddenTransport ||= style.display === 'none' || ['hidden', 'collapse'].includes(style.visibility)|| Number(style.opacity) === 0 || style.contentVisibility === 'hidden';}- // Existing visible section/form ownership remains authoritative. This- // proof is only for an otherwise hidden, transport-only ancestor chain.- if (hiddenTransport) return { owner, activator, transport };+ // Pages also hide the native input itself (often a clipped 1px slot),+ // including after consuming an earlier attachment. The same exclusive+ // slot/activator proof survives within its original native form only+ // when its complete visible destination context is bound below.+ // Formless slots still need the native section's observed purpose;+ // an arbitrary Upload button is not enough.+ const sameForm = target.form && owner.closest('form') === target.form+ && ('form' in activator ? activator.form : activator.closest('form')) === target.form;+ if (hiddenTransport || (hiddenTarget && sameForm)) return {+ owner, activator, transport, contextForm: hiddenTransport ? null : target.form,+ };}return null;}@@ -1460,11 +1472,15 @@if (mainOwner) owner = mainOwner.main;}let unstructuredOwner = false;+ let fileContextForm = null;let meaningfulOwner = !!conversation || !!readonlyPreparation;if (!owner && form && [...form.querySelectorAll('h1,h2,h3,h4,h5,h6,[role="heading"],'+modelEntityIdentitySelector)].some(node => node.closest('form,[role="form"]') === form && !node.closest(entityOwnerSelector)&& !node.closest('aside,nav,[role="navigation"],[role="complementary"]'))) owner = form;- if (!owner && fileWidget) { owner = fileWidget.owner; meaningfulOwner = true; }+ if (!owner && fileWidget) {+ owner = fileWidget.owner; meaningfulOwner = true;+ fileContextForm = fileWidget.contextForm;+ }if (!owner) {// A tiny toolbar is not a composer owner. Find the bounded container// that includes its editor and action, with a heading outside the form@@ -1661,6 +1677,19 @@else meaningfulOwner ||= (headingFreeDialog || headingFreeNamedScope)&& dialogTextIsCovered(owner, boundTextNodes, addNode, dialogIdentities, form, null, visualImages) && !uncoveredLabel;}+ if (fileContextForm) {+ // Native form membership alone does not identify the upload recipient:+ // pages can render it as plain text beside the dropzone. Bind and expose+ // that complete context, including controls such as native options that+ // form.elements omits, before admitting this directly hidden slot.+ if (!addNode(fileContextForm, { directText: true })) return null;+ for (const control of fileContextForm.querySelectorAll(modelControlSelector)) {+ if (control.closest('form,[role="form"]') !== fileContextForm+ || !addNode(control, { text: true, control: true })) return null;+ }+ if (!dialogTextIsCovered(fileContextForm, boundTextNodes, addNode, dialogIdentities, form, null, visualImages)+ || uncoveredLabel) return null;+ }// An arbitrary container/toolbar with no entity anchor cannot establish// the recipient or item. Such targets retain strict legacy dispatch only.if (!owner || !meaningfulOwner) return null;diff --git a/src/firefox/src/agent/adapters.js b/src/firefox/src/agent/adapters.jsindex a1aceb27a..e722ae5fe 100644--- a/src/firefox/src/agent/adapters.js+++ b/src/firefox/src/agent/adapters.js@@ -15909,8 +15909,8 @@ const ADAPTERS = [notes: `- Username may only contain alphanumeric characters or single hyphens, and cannot begin or end with a hyphen.- Creating a release: navigate to /<owner>/<repo>/releases/new, choose/create the tag with the "Choose a tag" combobox, and verify the "Previous tag" range. If the user supplied no exact notes, prefer "Generate release notes" and review its output; otherwise preserve their text. Finish with "Publish release" or the adjacent "Save draft" as requested.-- On the release form, use named controls rather than unstable indexes (never reuse remembered element #38). The release body is a CodeMirror editor: click its "Describe this release" surface before typing.-- EDITING an existing release (URL pattern /<owner>/<repo>/releases/edit/<tag>): the file upload input is \`input#releases-upload\` (NOT a generic input[type="file"] — there are several on the page). Prefer \`upload_file({selector: "input#releases-upload", downloadId: N})\` when the binary is already in Downloads; otherwise \`upload_file({selector: "input#releases-upload"})\` opens a user file picker. After each upload, GitHub renders a small chip listing the filename in the "Attach binaries" area — verify the chip appears with the correct filename before moving on. The commit button is green and says "Update release"; navigating away without clicking it discards the uploads.+- On the release form, use named controls rather than unstable indexes (never reuse remembered element #38). The release body is a CodeMirror editor: click its "Describe this release" surface before typing. Read current upload status with filter="visible"; filter="all" also includes hidden loading/error templates, which do not establish an active failure.+- Release binaries on both /releases/new and /releases/edit/<tag>: call \`get_interactive_elements\` and use the exact selector on the asset input record (normally #releases-upload). The other file input belongs to Markdown attachments. Reuse each saved downloadId with \`upload_file\`; never guess a name selector or use generic input[type="file"]. After each attachment, inspect the visible asset row/status before attaching the next file. Finish with "Publish release", "Save draft", or "Update release" as requested, then verify every filename on the saved release page; navigating away before saving loses staged changes.- Files in a /tree/.../<folder> view (e.g. /tree/main/dist) can be downloaded via raw URLs of the form https://github.com/<owner>/<repo>/raw/<branch>/<path>. Once downloaded, the file is on local disk; do not re-download to "verify".- Creating a pull request: when no exact title was supplied, prefer the title field's Copilot button; for a blank description, prefer Copilot > "Summary". Review both suggestions and add missing rationale/testing context. Summary ignores existing description text, so preserve repository templates and user content; if Copilot is unavailable, draft normally. PR descriptions/comments use CodeMirror with a separate Markdown preview.- File browser: pressing "t" opens the fuzzy file finder (faster than navigating folders). When editing a repository file, verify the complete editor value before clicking "Commit changes"; then open or observe the new /commit/<sha> link so WebBrain can verify the raw file at that exact commit and reject duplicated or partial content.diff --git a/src/firefox/src/agent/page-feedback.js b/src/firefox/src/agent/page-feedback.jsindex 10e63dfbe..ef1b5ce6c 100644--- a/src/firefox/src/agent/page-feedback.js+++ b/src/firefox/src/agent/page-feedback.js@@ -229,7 +229,20 @@ export function pageFeedbackPendingResult() {}// The answer of a call whose target the observed certificate cannot bind.-function actionBindingUnavailableResult(run) {+function actionBindingUnavailableResult(run, name) {+ if (name === 'upload_file') {+ const reason = run.actionBindingUnavailableReason;+ const explanation = reason === 'target_ambiguous'+ ? 'The selector matches more than one element, so the intended file input cannot be bound.'+ : reason === 'target_unresolved'+ ? 'The requested file input could not be resolved on the current page.'+ : 'The requested file input was not covered by the observed action context.';+ return { success: false, skipped: true, dispatched: false, noDispatch: true, retryable: false,+ errorCode: 'action_binding_unavailable',+ ...(['target_ambiguous', 'target_unresolved', 'target_uncovered'].includes(reason) ? { bindingFailure: reason } : {}),+ recoveryRequired: 'get_interactive_elements',+ error: explanation + ' Nothing was attached. Call get_interactive_elements again, identify the intended file-input record by its upload widget context, and copy its exact selector into a new upload_file call with the same attachmentId, downloadId, or filePath. Do not guess a selector or click the upload control.' };+ }return { success: false, skipped: true, dispatched: false, noDispatch: true, retryable: false,errorCode: 'action_binding_unavailable',...(run.actionBindingUnavailableReason === 'target_ambiguous' ? { bindingFailure: 'target_ambiguous',@@ -1354,6 +1367,11 @@ export const pageFeedbackMethods = {run.actionCaptureTarget = safeAction(name, args);run.actionBindingUnavailable = `${name}:${JSON.stringify(args)}`;run.actionBindingUnavailableReason = response.reason;+ // The monitor may reject ambiguity before the upload resolver runs.+ // Preserve that resolver's required inventory step on this path too.+ if (name === 'upload_file' && response.reason === 'target_ambiguous') {+ this._uploadSelectorRecoveryRequired?.set(tabId, 0);+ }}if (owned && response.uncertified === true) {// The original node is unchanged, but its action context was never@@ -1377,7 +1395,7 @@ export const pageFeedbackMethods = {if (!run || typeof args?.selector !== 'string' || !args.selector.trim() || !this.constructor.STATE_CHANGE_TOOLS?.has(name)|| pageFeedbackCallPolicy(name, args, run.modelState, run.latestPage).kind !== 'bound_target') return null;if (await this._validatePageFeedbackAction(tabId, name, args, run.modelState, null, { answerOnly: true }) !== false) return null;- return run.actionBindingUnavailable === `${name}:${JSON.stringify(args)}` ? actionBindingUnavailableResult(run) : null;+ return run.actionBindingUnavailable === `${name}:${JSON.stringify(args)}` ? actionBindingUnavailableResult(run, name) : null;},_pageFeedbackBlocksCall(tabId, name, args = {}) {@@ -1760,7 +1778,7 @@ export function installPageFeedback(Agent) {if (modelBound) {const validated = await this._validatePageFeedbackAction(tabId, name, args, modelState, batchId);if (validated === false) return run.actionBindingUnavailable === `${name}:${JSON.stringify(args)}`- ? actionBindingUnavailableResult(run)+ ? actionBindingUnavailableResult(run, name): run.actionContextUnverified === true? { ...pageFeedbackPendingResult(), actionContextUnverified: true, errorCode: 'action_context_unverified',error: 'The requested control had no verified original action context. No action was dispatched; inspect the fresh bounded target observation before choosing another action.' }diff --git a/src/firefox/src/content/accessibility-tree.js b/src/firefox/src/content/accessibility-tree.jsindex 9fbc6b60f..1ebed6c56 100644--- a/src/firefox/src/content/accessibility-tree.js+++ b/src/firefox/src/content/accessibility-tree.js@@ -731,6 +731,35 @@return false;}+ let treeHiddenStateCache = null;+ function isHiddenTreeNode(el) {+ const cache = treeHiddenStateCache || new WeakMap();+ const pending = [];+ let node = el;+ for (; node?.nodeType === Node.ELEMENT_NODE && !cache.has(node); node = composedParent(node)) pending.push(node);+ let suppressed = cache.get(node)?.suppressed === true;+ let transparent = cache.get(node)?.transparent === true;+ while (pending.length) {+ const current = pending.pop();+ const style = window.getComputedStyle(current);+ const generatesBox = style.display !== 'contents';+ suppressed ||= current.getAttribute('aria-hidden') === 'true'+ || style.display === 'none' || (generatesBox && style.contentVisibility === 'hidden');+ // Top-layer boxes escape ancestor opacity, but not display/content+ // suppression or aria-hidden. Their own opacity still applies.+ if (transparent && (current.matches(':modal')+ || (current.hasAttribute('popover') && 'popover' in current && current.matches(':popover-open'))+ || current.matches(':fullscreen'))) transparent = false;+ // Box effects on display:contents do not affect its rendered children.+ transparent ||= generatesBox && style.opacity === '0';+ // Visibility can be restored by a child. Cache the inherited states+ // separately so siblings and anchored reads keep the same semantics.+ cache.set(current, { suppressed, transparent, hidden: suppressed || transparent || ['hidden', 'collapse'].includes(style.visibility) });+ }+ // Offscreen text, display:contents and CSS overrides of [hidden] render.+ return cache.get(el)?.hidden === true;+ }+function deepestOpenShadowHit(x, y) {let hit = document.elementFromPoint(x, y);const seen = new Set();@@ -1080,6 +1109,12 @@line += ' hidden=true';}} catch {}+ } else {+ // filter=all keeps inactive status/error templates as well as controls.+ // Without this marker their text can be mistaken for a live outcome.+ try {+ if (isHiddenTreeNode(el)) line += ' hidden=true';+ } catch {}}try {if (isInteractive(el) && isNodeOccluded(el)) {@@ -1839,6 +1874,8 @@}function generateAccessibilityTree(filter, maxDepth, maxChars, refId, page, expectedTreeRevision) {+ const previousHiddenStateCache = treeHiddenStateCache;+ treeHiddenStateCache = new WeakMap();jevCollector = filter === 'interactive' && !refId && (!page || page === 1) ? new Map() : null;lastJevSnapshot = null;jevSensitiveControlSeen = false;@@ -2043,6 +2080,7 @@viewport: { width: window.innerWidth, height: window.innerHeight },};} finally {+ treeHiddenStateCache = previousHiddenStateCache;if (jevCollector) {const controls = [...jevCollector.values()];const structure = fingerprintTreeContent(JSON.stringify(controls.map(({ value, checked, signature, ...control }) => control)));diff --git a/src/firefox/src/content/page-monitor.js b/src/firefox/src/content/page-monitor.jsindex 310667b1c..1298336cb 100644--- a/src/firefox/src/content/page-monitor.js+++ b/src/firefox/src/content/page-monitor.js@@ -1311,6 +1311,10 @@function nativeFileWidget(target) {if (!(target instanceof HTMLInputElement) || target.type !== 'file' || target.disabled|| target.closest('fieldset[disabled]')) return null;+ const targetStyle = getComputedStyle(target), targetRect = target.getBoundingClientRect();+ const hiddenTarget = targetStyle.display === 'none' || ['hidden', 'collapse'].includes(targetStyle.visibility)+ || Number(targetStyle.opacity) === 0 || targetStyle.contentVisibility === 'hidden'+ || (targetRect.width <= 1 && targetRect.height <= 1);// A transport-only wrapper may hide the input itself. Its visible widget// must still identify one exact file slot and one rendered activation// purpose; a hidden form, composer or arbitrary collection is not a widget.@@ -1343,9 +1347,17 @@hiddenTransport ||= style.display === 'none' || ['hidden', 'collapse'].includes(style.visibility)|| Number(style.opacity) === 0 || style.contentVisibility === 'hidden';}- // Existing visible section/form ownership remains authoritative. This- // proof is only for an otherwise hidden, transport-only ancestor chain.- if (hiddenTransport) return { owner, activator, transport };+ // Pages also hide the native input itself (often a clipped 1px slot),+ // including after consuming an earlier attachment. The same exclusive+ // slot/activator proof survives within its original native form only+ // when its complete visible destination context is bound below.+ // Formless slots still need the native section's observed purpose;+ // an arbitrary Upload button is not enough.+ const sameForm = target.form && owner.closest('form') === target.form+ && ('form' in activator ? activator.form : activator.closest('form')) === target.form;+ if (hiddenTransport || (hiddenTarget && sameForm)) return {+ owner, activator, transport, contextForm: hiddenTransport ? null : target.form,+ };}return null;}@@ -1460,11 +1472,15 @@if (mainOwner) owner = mainOwner.main;}let unstructuredOwner = false;+ let fileContextForm = null;let meaningfulOwner = !!conversation || !!readonlyPreparation;if (!owner && form && [...form.querySelectorAll('h1,h2,h3,h4,h5,h6,[role="heading"],'+modelEntityIdentitySelector)].some(node => node.closest('form,[role="form"]') === form && !node.closest(entityOwnerSelector)&& !node.closest('aside,nav,[role="navigation"],[role="complementary"]'))) owner = form;- if (!owner && fileWidget) { owner = fileWidget.owner; meaningfulOwner = true; }+ if (!owner && fileWidget) {+ owner = fileWidget.owner; meaningfulOwner = true;+ fileContextForm = fileWidget.contextForm;+ }if (!owner) {// A tiny toolbar is not a composer owner. Find the bounded container// that includes its editor and action, with a heading outside the form@@ -1661,6 +1677,19 @@else meaningfulOwner ||= (headingFreeDialog || headingFreeNamedScope)&& dialogTextIsCovered(owner, boundTextNodes, addNode, dialogIdentities, form, null, visualImages) && !uncoveredLabel;}+ if (fileContextForm) {+ // Native form membership alone does not identify the upload recipient:+ // pages can render it as plain text beside the dropzone. Bind and expose+ // that complete context, including controls such as native options that+ // form.elements omits, before admitting this directly hidden slot.+ if (!addNode(fileContextForm, { directText: true })) return null;+ for (const control of fileContextForm.querySelectorAll(modelControlSelector)) {+ if (control.closest('form,[role="form"]') !== fileContextForm+ || !addNode(control, { text: true, control: true })) return null;+ }+ if (!dialogTextIsCovered(fileContextForm, boundTextNodes, addNode, dialogIdentities, form, null, visualImages)+ || uncoveredLabel) return null;+ }// An arbitrary container/toolbar with no entity anchor cannot establish// the recipient or item. Such targets retain strict legacy dispatch only.if (!owner || !meaningfulOwner) return null;diff --git a/test/accessibility-tree-scoped-budget.mjs b/test/accessibility-tree-scoped-budget.mjsindex 3b8d2b28e..a01b535da 100644--- a/test/accessibility-tree-scoped-budget.mjs+++ b/test/accessibility-tree-scoped-budget.mjs@@ -17,12 +17,12 @@ body{margin:0;height:600px;overflow:hidden}button{height:32px}#global-menu{posit<div role="menu" class="hidden"><button>Hidden private action</button></div><script>window.qaActions=0;document.addEventListener('click',()=>qaActions++);</script>`;-async function withPage(engine, build, callback) {+async function withPage(engine, build, callback, pageHtml = html) {const browser = await engine.launch({ headless: true });try {const context = await browser.newContext({ viewport: { width: 1000, height: 600 } });await context.addInitScript({ content: await fs.readFile(path.join(ROOT, 'src', build, 'src/content/accessibility-tree.js'), 'utf8') });- await context.route(`${url}*`, route => route.fulfill({ contentType: 'text/html', body: html }));+ await context.route(`${url}*`, route => route.fulfill({ contentType: 'text/html', body: pageHtml }));const page = await context.newPage(); await page.goto(url);const read = (id, maxChars = 1000, continuation = {}) => page.evaluate(({ id, maxChars, continuation }) => {const root = __wb_ax_ref(document.getElementById(id));@@ -35,6 +35,161 @@ async function withPage(engine, build, callback) {function firstRef(tree) { return tree.pageContent.match(/\[(ref_[A-Za-z0-9_-]+)\]/)?.[1]; }+const uploadStatusHtml = `<!doctype html><meta charset="utf-8"><style>+.inactive{display:none}.masked{position:absolute;opacity:0;width:1px;height:1px}+#offscreen-status{position:absolute;top:1200px}+</style><main id="upload">+<p id="idle" role="status">Ready for release assets</p>+<p id="hidden-override" role="status" hidden style="display:block">Asset ready</p>+<span id="uploading" class="inactive">Uploading your file now…</span>+<div class="inactive"><span id="duplicate">An attachment with that filename already exists.</span></div>+<p id="bad-type" role="alert" hidden>We do not support that file type.</p>+<div aria-hidden="true"><p id="empty-file" role="status">This file is empty.</p></div>+<div style="opacity:0"><p id="failed" role="alert">Unable to process the file.</p></div>+<div style="content-visibility:hidden"><span id="too-big">The file exceeds the size limit.</span></div>+<span id="inline-status">Inline status text</span>+<span id="contents-status" style="display:contents">Contents status text</span>+<span id="contents-opacity" style="display:contents;opacity:0">Visible contents text</span>+<div style="display:contents;content-visibility:hidden"><p id="contents-visibility" role="status">Visible contents status</p></div>+<div style="opacity:0"><div style="display:contents"><p id="contents-hidden" role="status">Hidden ancestor status</p></div></div>+<div style="visibility:hidden"><p id="visible-override" role="status" style="visibility:visible">Current upload details</p></div>+<p id="offscreen-status" role="status">Offscreen upload details</p>+<label><input id="custom-checkbox" type="checkbox" class="masked">Confirm asset</label>+<label><input id="custom-file" type="file" class="masked">Choose release assets</label>+<div id="shadow-status-host" style="opacity:0"></div>+</main><script>window.qaActions=0;document.addEventListener('click',()=>qaActions++);</script>`;++for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {+ test(`${build}: all AX reads distinguish inactive upload status templates from rendered text`, () => withPage(engine, build, async page => {+ const readAll = () => page.evaluate(() => __generateAccessibilityTree('all', 15, 12000, __wb_ax_ref(document.getElementById('upload'))));+ const line = (tree, id) => {+ const result = tree.pageContent.split('\n').find(row => row.includes(`dom_id="${id}"`));+ assert.ok(result, `all must retain ${id}`);+ return result;+ };+ const tree = await readAll();+ assert.equal(tree.hasMore, undefined);+ for (const id of ['uploading', 'duplicate', 'bad-type', 'empty-file', 'failed', 'too-big', 'contents-hidden']) {+ assert.match(line(tree, id), /\bhidden=true/, `${id} must not look like a live upload status`);+ }+ for (const id of ['idle', 'hidden-override', 'inline-status', 'contents-status', 'contents-opacity', 'contents-visibility', 'visible-override', 'offscreen-status', 'custom-checkbox', 'custom-file']) {+ assert.doesNotMatch(line(tree, id), /\bhidden=true/, `${id} remains rendered or label-driven`);+ }+ await page.evaluate(() => {+ document.getElementById('uploading').classList.remove('inactive');+ document.getElementById('idle').hidden = true;+ });+ const changed = await readAll();+ assert.doesNotMatch(line(changed, 'uploading'), /\bhidden=true/);+ assert.match(line(changed, 'idle'), /\bhidden=true/);++ // Anchored reads can start inside an open shadow root. Visibility still+ // belongs to its composed ancestors, including the host.+ const shadow = await page.evaluate(() => {+ const host = document.getElementById('shadow-status-host');+ host.attachShadow({ mode: 'open' }).innerHTML = '<p role="alert">Shadow upload failed.</p>';+ const ref = __wb_ax_ref(host.shadowRoot.firstElementChild);+ const hidden = __generateAccessibilityTree('all', 5, 1000, ref).pageContent;+ host.style.opacity = '1';+ return { hidden, shown: __generateAccessibilityTree('all', 5, 1000, ref).pageContent };+ });+ assert.match(shadow.hidden, /alert "Shadow upload failed\.".*hidden=true/);+ assert.doesNotMatch(shadow.shown, /\bhidden=true/);+ }, uploadStatusHtml));++ test(`${build}: top-layer statuses escape ancestor opacity while preserving real suppression`, () => withPage(engine, build, async page => {+ const result = await page.evaluate(() => {+ const parent = document.getElementById('transparent-parent');+ const dialog = document.getElementById('modal');+ const read = () => __generateAccessibilityTree('all', 15, 12000).pageContent;+ dialog.showModal();+ const shown = read();+ const hitIds = ['modal-status', 'modal-button'].map(id => {+ const rect = document.getElementById(id).getBoundingClientRect();+ return document.elementFromPoint(rect.left + rect.width / 2, rect.top + rect.height / 2)?.id;+ });+ dialog.style.opacity = '0';+ const ownOpacity = read();+ dialog.style.opacity = '';+ parent.setAttribute('aria-hidden', 'true');+ dialog.setAttribute('aria-hidden', 'false');+ const ariaHidden = read();+ parent.removeAttribute('aria-hidden');+ parent.style.display = 'none';+ const displayNone = read();+ parent.style.display = '';+ parent.style.contentVisibility = 'hidden';+ const skippedContent = read();+ parent.style.contentVisibility = '';+ dialog.close();+ dialog.show();+ const nonModal = read();+ dialog.close();+ document.getElementById('popover').showPopover();+ const popover = read();+ return { shown, hitIds, ownOpacity, ariaHidden, displayNone, skippedContent, nonModal, popover };+ });+ const line = (tree, id) => {+ const row = tree.split('\n').find(row => row.includes(`dom_id="${id}"`));+ assert.ok(row, `all must retain ${id}`);+ return row;+ };+ assert.deepEqual(result.hitIds, ['modal-status', 'modal-button'], 'the modal controls are rendered above their transparent ancestor');+ for (const id of ['modal-status', 'modal-button']) assert.doesNotMatch(line(result.shown, id), /\bhidden=true/);+ for (const id of ['ordinary-status', 'modal-hidden']) assert.match(line(result.shown, id), /\bhidden=true/);+ for (const state of ['ownOpacity', 'ariaHidden', 'displayNone', 'skippedContent', 'nonModal']) {+ assert.match(line(result[state], 'modal-status'), /\bhidden=true/, `${state} must still suppress the status`);+ }+ assert.doesNotMatch(line(result.popover, 'popover-status'), /\bhidden=true/);+ assert.match(line(result.popover, 'ordinary-status'), /\bhidden=true/);+ }, `<!doctype html><div id="transparent-parent" style="opacity:0">+<p id="ordinary-status" role="status">Ordinary hidden status</p>+<dialog id="modal"><p id="modal-status" role="status">Confirm upload</p><button id="modal-button">Continue</button><p id="modal-hidden" role="status" style="opacity:0">Inactive modal status</p></dialog>+<div id="popover" popover="manual"><p id="popover-status" role="status">Upload ready</p></div>+</div><script>window.qaActions=0;document.addEventListener('click',()=>qaActions++);</script>`));++ test(`${build}: hidden status checks share ancestor work only within the current AX read`, () => withPage(engine, build, async page => {+ const result = await page.evaluate(() => {+ const owner = document.getElementById('owner');+ let parent = owner;+ for (let depth = 0; depth < 80; depth++) parent = parent.appendChild(document.createElement('div'));+ for (let index = 0; index < 400; index++) {+ const status = parent.appendChild(document.createElement('p'));+ status.setAttribute('role', 'status');+ status.textContent = `Bulk status ${index}`;+ }+ const ownerRef = __wb_ax_ref(owner);+ const nestedRef = __wb_ax_ref(document.getElementById('nested'));+ const getStyle = window.getComputedStyle;+ let styleReads = 0, nested = false;+ window.getComputedStyle = function(element, ...args) {+ styleReads++;+ if (!nested && element === parent.firstElementChild) {+ nested = true;+ __generateAccessibilityTree('all', 5, 1000, nestedRef);+ }+ return getStyle.call(this, element, ...args);+ };+ try {+ const shown = __generateAccessibilityTree('all', 120, 150000, ownerRef);+ const shownReads = styleReads;+ owner.style.opacity = '0';+ styleReads = 0;+ const hidden = __generateAccessibilityTree('all', 120, 150000, ownerRef);+ return { shown, hidden, shownReads, hiddenReads: styleReads, elements: document.querySelectorAll('*').length, nested };+ } finally { window.getComputedStyle = getStyle; }+ });+ for (const [state, reads] of [['shown', result.shownReads], ['hidden', result.hiddenReads]]) {+ assert.equal(result[state].error, undefined);+ const statuses = result[state].pageContent.split('\n').filter(line => /status "Bulk status \d+"/.test(line));+ assert.equal(statuses.length, 400);+ assert.equal(statuses.filter(line => /\bhidden=true/.test(line)).length, state === 'hidden' ? 400 : 0);+ assert.ok(reads < result.elements * 6, `${state}: ${reads} style lookups repeated shared ancestry`);+ }+ assert.equal(result.nested, true, 'a nested scoped read must restore the outer read cache');+ }, '<!doctype html><main id="owner"></main><p id="nested" role="status">Nested status</p><script>window.qaActions=0</script>'));+}+for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {test(`${build}: exact target receives bounded AX budget before unrelated global overlays`, () => withPage(engine, build, async (page, read) => {const { root, tree } = await read('commit');diff --git a/test/lib/upload-release-fixture.mjs b/test/lib/upload-release-fixture.mjsindex f56d08d3c..062978324 100644--- a/test/lib/upload-release-fixture.mjs+++ b/test/lib/upload-release-fixture.mjs@@ -17,3 +17,30 @@ for(const [slot,id] of [['markdown','fc-release-body'],['binary','releases-uploaif(slot==='binary')document.getElementById('binary-status').textContent='Binary staged: '+[...event.target.files].map(file=>file.name).join(', ');});document.getElementById('binary-button').onclick=()=>{chooserClicks++;document.getElementById('releases-upload').click();};document.getElementById('release-form').onsubmit=event=>event.preventDefault();</script>`;++// A page may replace its hidden transport wrapper with a directly clipped+// native slot after consuming the first attachment. Asset editors live next+// to the exclusive dropzone and remain part of the same release form.+export function stageSequentialReleaseUploads(hiding = 'clipped') {+ document.querySelectorAll('h1,h2').forEach(node => node.remove());+ const decoration = document.createElement('div'); decoration.hidden = true;+ decoration.innerHTML = '<span></span>'.repeat(300);+ const widget = document.getElementById('binary-widget');+ widget.after(decoration);+ const input = document.getElementById('releases-upload');+ input.addEventListener('change', () => {+ for (const file of input.files) {+ const row = document.createElement('div'); row.className = 'staged-asset';+ const name = document.createElement('input');+ name.setAttribute('aria-label', 'Change this file’s name'); name.value = file.name;+ const remove = document.createElement('button');+ remove.type = 'button'; remove.textContent = 'Remove attached binary';+ row.append(name, remove); widget.before(row);+ }+ if (input.parentElement !== widget) input.parentElement.replaceWith(input);+ input.style.cssText = hiding === 'opacity'+ ? 'position:absolute;width:12px;height:12px;opacity:0;overflow:hidden'+ : 'position:absolute;width:1px;height:1px;clip-path:inset(50%);overflow:hidden';+ input.value = '';+ });+}diff --git a/test/page-feedback-unbindable-target.mjs b/test/page-feedback-unbindable-target.mjsindex 0ee82282b..ac7da4e1f 100644--- a/test/page-feedback-unbindable-target.mjs+++ b/test/page-feedback-unbindable-target.mjs@@ -235,4 +235,126 @@ for (const build of ['chrome', 'firefox']) {} finally { api.tabs.sendMessage = oldSend; documents.delete(tab); }});}++ for (const reason of ['target_ambiguous', 'target_unresolved', 'target_uncovered']) {+ test(`${build}: upload ${reason} preserves its source and requires usable file-input discovery`, async () => {+ const tab = nextTab++, messagesSeen = [], validations = [];+ const selector = reason === 'target_ambiguous' ? 'input[type="file"]' : 'input[name="guessed-upload"]';+ const uploadTree = 'heading "New release" [ref_heading]\nbutton "Attach release binaries" [ref_binary]\n'+ + 'button "Publish release" [ref_publish] type="button"';+ const inventory = [+ { tag: 'input', type: 'file', id: 'fc-release-body', selector: '#fc-release-body', text: 'Attach Markdown files' },+ { tag: 'input', type: 'file', id: 'releases-upload', selector: '#releases-upload', text: 'Attach release binaries' },+ ];+ const source = { downloadId: 71 };+ const oldSend = api.tabs.sendMessage;+ let agent, send, requests = 0, captures = 0, inventories = 0, attachments = 0, publications = 0;+ api.tabs.sendMessage = async (_id, message) => {+ if (message.action === 'page_monitor_capture_model') {+ return { ready: true, runToken: message.params.runToken, documentToken: 'content-1',+ snapshotToken: 'upload-' + ++captures, targetCount: 4, focusedTargetAvailable: false,+ page: { success: true, url: PAGE_URL, pageContent: uploadTree } };+ }+ if (message.action === 'page_monitor_validate_model') {+ validations.push(message.params);+ return { ready: message.params.selector !== selector,+ ...(message.params.selector === selector ? { reason } : {}),+ runToken: message.params.runToken, documentToken: 'content-1', snapshotToken: message.params.snapshotToken };+ }+ if (message.action === 'page_monitor_prepare') return { ready: true, modelBindingValid: true };+ if (message.action === 'get_interactive_elements_cdp') { inventories++; return inventory; }+ return { ready: true };+ };+ const next = async messages => {+ messagesSeen.push(structuredClone(messages));+ requests++;+ assert.ok(requests <= 4, 'Upload recovery must reach a new exact-target decision.');+ // Passive page activity must not swallow the upload's own refusal.+ send({});+ if (requests === 1) return calls(['bad-upload', 'upload_file', { selector, ...source }],+ ['premature-publication', 'click_ax', { ref_id: 'ref_publish' }]);+ if (requests === 2) {+ assert.equal(agent._uploadSelectorRecoveryRequired.has(tab), reason === 'target_ambiguous');+ if (reason === 'target_ambiguous') {+ // Even a now-unique selector cannot bypass the original resolver's+ // inspection requirement when ambiguity was found by preflight.+ const directRetry = await pageFeedbackExecute.call(agent, tab, 'upload_file',+ { selector: '#releases-upload', ...source }, () => {});+ assert.equal(directRetry.recoveryRequired, 'get_interactive_elements', JSON.stringify(directRetry));+ assert.equal(directRetry.noDispatch, true);+ }+ return calls(['inspect-files', 'get_interactive_elements', {}]);+ }+ if (requests === 3) return calls(['exact-upload', 'upload_file', { selector: '#releases-upload', ...source }]);+ return calls(['finished', 'done', { summary: 'The intended attachment was selected.', outcome: 'partial' }]);+ };+ agent = makeAgent(Agent, next);+ agent._enrichUserMessageWithCurrentPage = async (_tab, _messages, content) => { send = bind(agent, tab); return { role: 'user', content }; };+ agent.executeTool = async function(id, name, args, onUpdate, context) {+ if (name === 'get_accessibility_tree') return { success: true, pageContent: uploadTree };+ if (name === 'done') return { done: true, success: true, summary: args.summary, outcome: args.outcome };+ if (name === 'get_interactive_elements' || (name === 'upload_file' && args.selector === selector)) {+ return pageFeedbackExecute.call(this, id, name, args, onUpdate, context);+ }+ if (name === 'click_ax') { publications++; return { success: true, dispatched: true }; }+ assert.equal(name, 'upload_file');+ assert.equal(args.selector, '#releases-upload');+ assert.deepEqual(args, { selector: '#releases-upload', ...source });+ assert.equal(this._uploadSelectorRecoveryRequired.has(id), false);+ assert.equal(inventories, 1);+ attachments++;+ return { success: true, dispatched: true, verified: true };+ };+ try {+ await agent.processMessage(tab, 'Attach the existing downloaded ZIP to the release binary slot.', () => {}, 'act', [],+ { detachedRequestId: 'upload-target-' + tab, askStreamingEnabled: false });+ assert.equal(requests, 4);+ const answers = toolResults(messagesSeen[1]).map(parse);+ const answer = answers.find(item => item?.errorCode === 'action_binding_unavailable');+ assert.ok(answer, JSON.stringify(answers));+ assert.equal(answer.bindingFailure, reason);+ assert.equal(answer.noDispatch, true);+ assert.equal(answer.dispatched, false);+ assert.equal(answer.retryable, false);+ assert.equal(answer.recoveryRequired, 'get_interactive_elements');+ assert.match(answer.error, /get_interactive_elements.*exact selector.*same attachmentId, downloadId, or filePath/);+ assert.doesNotMatch(answer.error, /ref_id/);+ assert.ok(answers.some(item => item?.skippedBecause === 'fresh_turn_required'));+ assert.equal(publications, 0);+ assert.equal(attachments, 1);+ assert.ok(validations.some(params => params.selector === selector));+ assert.equal(agent._pageFeedbackRuns.size, 0);+ } finally { api.tabs.sendMessage = oldSend; documents.delete(tab); }+ });+ }++ test(`${build}: late upload ambiguity cannot impose recovery on a changed run, document or user decision`, async () => {+ const oldSend = api.tabs.sendMessage;+ try {+ for (const changed of ['run', 'document', 'user']) {+ const tab = nextTab++, agent = makeAgent(Agent, async () => ({ content: '' }));+ const frame = { token: 'content-1', id: 'document-1' };+ const run = { token: 'owned-run', url: PAGE_URL, events: new Map(), frames: new Map([[0, frame]]) };+ run.modelState = { token: run.token, url: run.url, frames: new Map([[0, { ...frame }]]), steeringRevision: 0,+ actionBinding: { runToken: run.token, documentToken: frame.token, snapshotToken: 'owned-snapshot' } };+ agent._pageFeedbackRuns = new Map([[tab, run]]);+ let queried = false;+ api.tabs.sendMessage = async (_id, message) => {+ assert.equal(message.action, 'page_monitor_validate_model');+ queried = true;+ if (changed === 'run') agent._pageFeedbackRuns.set(tab, { ...run, token: 'replacement-run' });+ else if (changed === 'document') run.frames.set(0, { token: 'replacement-document', id: 'document-2' });+ else run.events.set('human', { kind: 'click', source: 'user', frameId: 0 });+ return { ready: false, reason: 'target_ambiguous', runToken: run.token,+ documentToken: frame.token, snapshotToken: message.params.snapshotToken };+ };+ const result = await agent._validatePageFeedbackAction(tab, 'upload_file',+ { selector: 'input[type=file]', downloadId: 71 }, run.modelState);+ assert.equal(queried, true, changed);+ assert.equal(result, false, changed);+ assert.equal(agent._uploadSelectorRecoveryRequired.has(tab), false, changed);+ agent._pageFeedbackRuns.delete(tab);+ }+ } finally { api.tabs.sendMessage = oldSend; }+ });}diff --git a/test/page-monitor-upload-release.mjs b/test/page-monitor-upload-release.mjsindex 934858d0c..af4461922 100644--- a/test/page-monitor-upload-release.mjs+++ b/test/page-monitor-upload-release.mjs@@ -2,11 +2,21 @@ import assert from 'node:assert/strict';import fs from 'node:fs/promises';import { test } from 'node:test';import { chromium, firefox } from 'playwright';-import { uploadReleaseHtml } from './lib/upload-release-fixture.mjs';+import { uploadReleaseHtml, stageSequentialReleaseUploads } from './lib/upload-release-fixture.mjs';-async function fixture(browser, build) {+const recipientUploadHtml = `<!doctype html><style>+#binary-widget{display:block;width:400px;padding:10px}input[type=file]{width:1px;height:1px;opacity:0}+</style><form id="release-form"><div id="recipient">Upload recipient: Alice</div>+<div id="binary-widget"><button type="button">Upload document</button><input type="file" id="releases-upload"></div></form>+<script>window.attachmentEvents={markdown:[],binary:[]};window.chooserClicks=0;window.uploadRecipients=[];+document.getElementById('releases-upload').onchange=event=>{+ attachmentEvents.binary.push([...event.target.files].map(file=>({name:file.name,size:file.size})));+ uploadRecipients.push(document.getElementById('release-form').firstChild.textContent);+};</script>`;++async function fixture(browser, build, html = uploadReleaseHtml) {const context = await browser.newContext({ viewport: { width: 1100, height: 900 } });- await context.route('https://owned-upload.invalid/**', route => route.fulfill({ contentType: 'text/html', body: uploadReleaseHtml }));+ await context.route('https://owned-upload.invalid/**', route => route.fulfill({ contentType: 'text/html', body: html }));await context.addInitScript(() => {window.listeners = []; window.feedback = []; window.qaRunToken = 'upload-release-run';const runtime = { onMessage: { addListener: listener => listeners.push(listener), removeListener() {} },@@ -38,34 +48,94 @@ const capture = (page, params = {}) => page.evaluate(params => deliver('page_monconst validate = (page, snapshot, selector = '#releases-upload') => page.evaluate(({ snapshot, selector }) => deliver('page_monitor_validate_model', {tool: 'upload_file', selector, snapshotToken: snapshot.snapshotToken,}), { snapshot, selector });-async function attach(page, snapshot, race = null) {+async function attach(page, snapshot, race = null, filename = 'owned.zip') {await page.evaluate(snapshot => {window.qaUploadSnapshot = snapshot.snapshotToken;return deliver('page_monitor_prepare', { operationId: 'owned-upload', tool: 'upload_file',selector: '#releases-upload', expectedModelSnapshot: snapshot.snapshotToken, allowPassiveRebase: true });}, snapshot);if (race) await race(page);- return page.evaluate(async () => {+ return page.evaluate(async filename => {const validation = await deliver('page_monitor_validate_model', { tool: 'upload_file', selector: '#releases-upload',snapshotToken: window.qaUploadSnapshot });const fence = await deliver('page_monitor_dispatch', { operationId: 'owned-upload', kind: 'input', fenceOnly: true });if (validation.ready && fence.ready) __wbPageMonitor.withPreparedDispatch('owned-upload', () => __wbPageMonitor.withLocalDispatch(() => {const input = document.getElementById('releases-upload'), transfer = new DataTransfer();- transfer.items.add(new File(['PK\\u0003\\u0004owned bytes'], 'owned.zip', { type: 'application/zip', lastModified: 1 }));+ transfer.items.add(new File(['PK\\u0003\\u0004owned bytes'], filename, { type: 'application/zip', lastModified: 1 }));input.files = transfer.files; input.dispatchEvent(new Event('input', { bubbles: true })); input.dispatchEvent(new Event('change', { bubbles: true }));}));return { validation, fence, events: attachmentEvents, chooserClicks };- });+ }, filename);}for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {test(`${build}: release binary upload has exact widget, recovery and dispatch fences`, { timeout: 120000 }, async t => {const browser = await engine.launch({ headless: true });try {- const withFixture = async work => {- const { context, page } = await fixture(browser, build);+ const withFixture = async (work, html) => {+ const { context, page } = await fixture(browser, build, html);try { await work(page); } finally { await context.close(); }};+ for (const location of ['sibling element', 'form text']) for (const mutation of ['unchanged', 'text changed', 'node replaced']) await t.test(`a direct hidden slot binds its recipient in ${location}: ${mutation}`, () => withFixture(async page => {+ if (location === 'form text') await page.evaluate(() => {+ const recipient = document.getElementById('recipient');+ recipient.replaceWith(document.createTextNode(recipient.textContent));+ });+ const snapshot = await capture(page, { uploadTargets: ['#releases-upload'] });+ assert.equal((await validate(page, snapshot)).ready, true);+ assert.match(snapshot.page.pageContent, /Upload recipient: Alice/);+ const attached = await attach(page, snapshot, mutation === 'unchanged' ? null : page => page.evaluate(mutation => {+ const recipient = document.getElementById('release-form').firstChild;+ if (mutation === 'text changed') recipient.textContent = 'Upload recipient: Mallory';+ else recipient.replaceWith(recipient.cloneNode(true));+ }, mutation));+ // A text node replacement with identical content keeps its bound+ // parent and destination; an element replacement changes that owner.+ const expected = mutation === 'unchanged' || (location === 'form text' && mutation === 'node replaced');+ assert.equal(attached.validation.ready, expected);+ assert.equal(attached.fence.ready, expected);+ assert.equal(attached.events.binary.length, expected ? 1 : 0);+ assert.deepEqual(await page.evaluate(() => uploadRecipients), expected ? ['Upload recipient: Alice'] : []);+ assert.deepEqual(attached.events.markdown, []); assert.equal(attached.chooserClicks, 0);+ }, recipientUploadHtml));+ for (const changed of [false, true]) await t.test(`a direct hidden slot binds native select options: ${changed ? 'changed' : 'unchanged'}`, () => withFixture(async page => {+ await page.evaluate(() => {+ const select = document.createElement('select'); select.setAttribute('aria-label', 'Release target');+ select.innerHTML = '<option value="alice">Alice</option><option value="mallory">Mallory</option>';+ document.getElementById('release-form').append(select);+ });+ const snapshot = await capture(page, { uploadTargets: ['#releases-upload'] });+ assert.equal((await validate(page, snapshot)).ready, true);+ const attached = await attach(page, snapshot, changed ? page => page.evaluate(() => {+ document.querySelector('select').value = 'mallory';+ }) : null);+ assert.equal(attached.fence.ready, !changed);+ assert.equal(attached.events.binary.length, changed ? 0 : 1);+ assert.deepEqual(attached.events.markdown, []); assert.equal(attached.chooserClicks, 0);+ }, recipientUploadHtml));+ for (const changed of [false, true]) await t.test(`a direct hidden slot retains its existing form heading owner: ${changed ? 'changed' : 'unchanged'}`, () => withFixture(async page => {+ await page.evaluate(() => {+ const recipient = document.getElementById('recipient'), heading = document.createElement('h2');+ heading.id = recipient.id; heading.textContent = recipient.textContent; recipient.replaceWith(heading);+ const editor = document.createElement('div'); editor.innerHTML = 'Name <input type="text" value="Owned">';+ document.getElementById('release-form').append(editor);+ });+ const snapshot = await capture(page, { uploadTargets: ['#releases-upload'] });+ assert.equal((await validate(page, snapshot)).ready, true);+ const attached = await attach(page, snapshot, changed ? page => page.evaluate(() => {+ document.getElementById('recipient').textContent = 'Upload recipient: Mallory';+ }) : null);+ assert.equal(attached.fence.ready, !changed);+ assert.deepEqual(await page.evaluate(() => uploadRecipients), changed ? [] : ['Upload recipient: Alice']);+ }, recipientUploadHtml));+ await t.test('a direct hidden slot cannot use partially observed recipient text', () => withFixture(async page => {+ await page.evaluate(() => { document.getElementById('recipient').textContent = 'Upload recipient: ' + 'Alice '.repeat(100); });+ const snapshot = await capture(page, { uploadTargets: ['#releases-upload'] });+ assert.equal((await validate(page, snapshot)).ready, false);+ const attached = await attach(page, snapshot);+ assert.equal(attached.fence.ready, false); assert.deepEqual(attached.events, { markdown: [], binary: [] });+ assert.deepEqual(await page.evaluate(() => uploadRecipients), []);+ }, recipientUploadHtml));await t.test('discovered binary input receives one file, with no Markdown attachment or chooser', () => withFixture(async page => {const inventory = await page.evaluate(() => deliver('get_interactive_elements_cdp'));assert.equal(inventory.filter(item => item.type === 'file').length, 2);@@ -79,6 +149,61 @@ for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {assert.equal(attached.fence.ready, true); assert.equal(attached.events.binary.length, 1);assert.deepEqual(attached.events.markdown, []); assert.equal(attached.chooserClicks, 0);}));+ for (const hiding of ['clipped', 'opacity']) await t.test(`consumed attachments retain an exclusive ${hiding} file slot for the next asset`, () => withFixture(async page => {+ await page.evaluate(stageSequentialReleaseUploads, hiding);+ const filenames = ['chrome.zip', 'edge.zip', 'firefox.zip', 'corresponding-source.zip'];+ for (const [index, filename] of filenames.entries()) {+ const snapshot = await capture(page, { uploadTargets: ['#releases-upload'] });+ assert.equal((await validate(page, snapshot)).ready, true, `Asset ${filename} must have its own fresh certificate.`);+ assert.match(snapshot.page.pageContent, /file input selector="#releases-upload" widget_ref=/);+ const attached = await attach(page, snapshot, null, filename);+ assert.equal(attached.validation.ready, true); assert.equal(attached.fence.ready, true);+ assert.equal(attached.events.binary.length, index + 1);+ assert.deepEqual(attached.events.markdown, []); assert.equal(attached.chooserClicks, 0);+ assert.equal(await page.locator('#releases-upload').evaluate(input => input.files.length), 0);+ await page.evaluate(() => deliver('page_monitor_finish', { operationId: 'owned-upload' }));+ assert.equal((await validate(page, snapshot)).ready, false, 'Consumption never repairs or reuses the previous certificate.');+ }+ assert.deepEqual(await page.locator('.staged-asset input').evaluateAll(inputs => inputs.map(input => input.value)), filenames);+ }));+ const consumedMutations = [+ ['second file slot', () => { const extra = document.createElement('input'); extra.type = 'file'; document.getElementById('binary-widget').append(extra); }],+ ['second activator', () => { const extra = document.createElement('button'); extra.type = 'button'; extra.textContent = 'Another upload'; document.getElementById('binary-widget').append(extra); }],+ ['hidden widget', () => { document.getElementById('binary-widget').style.display = 'none'; }],+ ['inert widget', () => { document.getElementById('binary-widget').inert = true; }],+ ['form association', () => { document.getElementById('releases-upload').setAttribute('form', 'other-form'); }],+ ['staged filename', () => { document.querySelector('.staged-asset input').value = 'another.zip'; }],+ ['staged removal handler', () => { document.querySelector('.staged-asset button').onclick = () => { window.unexpected = true; }; }],+ ];+ for (const [name, mutate] of consumedMutations) await t.test(`a consumed direct slot rejects ${name} before the next dispatch`, () => withFixture(async page => {+ await page.evaluate(stageSequentialReleaseUploads);+ const first = await capture(page);+ assert.equal((await attach(page, first, null, 'chrome.zip')).events.binary.length, 1);+ await page.evaluate(() => deliver('page_monitor_finish', { operationId: 'owned-upload' }));+ const fresh = await capture(page, { uploadTargets: ['#releases-upload'] });+ assert.equal((await validate(page, fresh)).ready, true);+ const attached = await attach(page, fresh, page => page.evaluate(mutate), 'edge.zip');+ assert.equal(attached.fence.ready, false);+ assert.equal(attached.events.binary.length, 1); assert.deepEqual(attached.events.markdown, []);+ assert.equal(attached.chooserClicks, 0);+ }));+ for (const association of ['missing', 'another-form']) await t.test(`a consumed direct slot cannot borrow an activator with ${association} form association`, () => withFixture(async page => {+ await page.evaluate(stageSequentialReleaseUploads);+ const first = await capture(page);+ assert.equal((await attach(page, first, null, 'chrome.zip')).events.binary.length, 1);+ await page.evaluate(() => deliver('page_monitor_finish', { operationId: 'owned-upload' }));+ await page.evaluate(association => {+ if (association === 'another-form') {+ const form = document.createElement('form'); form.id = association; document.body.append(form);+ }+ document.getElementById('binary-button').setAttribute('form', association);+ }, association);+ const fresh = await capture(page, { uploadTargets: ['#releases-upload'] });+ assert.equal((await validate(page, fresh)).ready, false);+ const attached = await attach(page, fresh, null, 'edge.zip');+ assert.equal(attached.fence.ready, false); assert.equal(attached.events.binary.length, 1);+ assert.deepEqual(attached.events.markdown, []); assert.equal(attached.chooserClicks, 0);+ }));await t.test('a deep discovered input belongs only to a fresh bounded observation', () => withFixture(async page => {await page.evaluate(() => {const decoration = document.createElement('div'); decoration.hidden = true;diff --git a/test/quality/upload-release-binding-mv3.mjs b/test/quality/upload-release-binding-mv3.mjsindex 748b61fec..65915d28f 100644--- a/test/quality/upload-release-binding-mv3.mjs+++ b/test/quality/upload-release-binding-mv3.mjs@@ -5,39 +5,49 @@ import http from 'node:http';import os from 'node:os';import path from 'node:path';import { chromium } from 'playwright';-import { uploadReleaseHtml } from '../lib/upload-release-fixture.mjs';+import { uploadReleaseHtml, stageSequentialReleaseUploads } from '../lib/upload-release-fixture.mjs';// Installed Chrome executes the production model wrapper, native download,// target recovery, CDP file assignment and one owned server submission.-const out = path.resolve(process.env.WEBBRAIN_QUALITY_ARTIFACTS || 'ci/artifacts/upload-release-binding-mv3');+const selectorRecovery = process.argv.includes('--selector-recovery');+const sequentialAssets = process.argv.includes('--sequential-assets');+const out = path.resolve(process.env.WEBBRAIN_QUALITY_ARTIFACTS || `ci/artifacts/upload-release-binding-mv3${selectorRecovery ? '-selectors' : sequentialAssets ? '-sequential' : ''}`);await fs.mkdir(out, { recursive: true });const zip = Buffer.concat([Buffer.from([80, 75, 3, 4]), Buffer.from('Owned binary upload fixture exact bytes.')]);+const filenames = sequentialAssets ? ['owned-chrome.zip', 'owned-edge.zip', 'owned-firefox.zip', 'owned-source.zip'] : ['owned-release.zip'];+const assets = new Map(filenames.map(name => [name, sequentialAssets ? Buffer.concat([zip, Buffer.from(name)]) : zip]));const uploads = [], decisions = [], assetRequests = [];let base, step = 0;-const html = uploadReleaseHtml.replace('<file-attachment id="binary-widget">',+let html = uploadReleaseHtml.replace('<file-attachment id="binary-widget">',`<div aria-hidden="true" style="display:none">${'<span></span>'.repeat(5000)}</div><file-attachment id="binary-widget">`).replace("document.getElementById('release-form').onsubmit=event=>event.preventDefault();", `document.getElementById('release-form').onsubmit=async event=>{- event.preventDefault();const form=new FormData();form.append('binary',document.getElementById('releases-upload').files[0]);+ event.preventDefault();const form=new FormData();+ for(const file of (window.queuedAssets || document.getElementById('releases-upload').files))form.append('binary',file);const response=await fetch('/upload',{method:'POST',body:form});if(response.ok)document.getElementById('binary-status').textContent='Owned binary release saved';};`);+if (sequentialAssets) html = html.replace('</script>', `+window.queuedAssets=[];+document.getElementById('releases-upload').addEventListener('change',event=>queuedAssets.push(...event.target.files));+(${stageSequentialReleaseUploads.toString()})();</script>`);const intent = { request_kind: 'execute', scope_relation: 'new', requires_state_change: true, requires_submission: true,- messaging: null, deliverables: ['Download and attach the exact owned ZIP only to the binary widget, submit once and verify saved.'],+ messaging: null, deliverables: ['Download and attach the requested owned ZIP assets only to the binary widget, submit once and verify saved.'],allows_planner_shaped_result: false, allows_app_state_tool_evidence: false, completion_requirements: { download: true },- read_scope: 'visible_page', summary: 'Download the exact ZIP, attach to the binary slot, submit once and verify.',+ read_scope: 'visible_page', summary: 'Download the requested ZIP assets, attach to the binary slot, submit once and verify.',steps: [{ id: '1', action: 'Download, inspect file inputs, attach ZIP to the binary slot, submit and verify.' }],memory: { use_progress_ledger: false, progress_action: null }, scheduling: null, risks: [] };const textOf = content => typeof content === 'string' ? content : Array.isArray(content)? content.filter(part => part.type === 'text').map(part => part.text).join('\n') : '';const server = http.createServer(async (request, response) => {- if (request.url === '/owned-release.zip') {+ const filename = request.url.slice(1), bytes = assets.get(filename);+ if (bytes) {assetRequests.push(request.method); response.writeHead(200, { 'Content-Type': 'application/zip',- 'Content-Length': zip.length, 'Content-Disposition': 'attachment; filename="owned-release.zip"' }); response.end(zip); return;+ 'Content-Length': bytes.length, 'Content-Disposition': `attachment; filename="${filename}"` }); response.end(bytes); return;}if (request.url === '/upload') {const chunks = []; for await (const chunk of request) chunks.push(chunk);- const body = Buffer.concat(chunks), start = body.indexOf(zip);- uploads.push({ exactBytes: start >= 0 && body.subarray(start, start + zip.length).equals(zip),+ const body = Buffer.concat(chunks);+ uploads.push({ exactBytes: [...assets.values()].every(bytes => body.includes(bytes)),contentType: request.headers['content-type'] }); response.writeHead(200).end('saved'); return;}if (request.url === '/v1/chat/completions') {@@ -48,22 +58,36 @@ const server = http.createServer(async (request, response) => {message = { role: 'assistant', content: JSON.stringify({ outcome: 'succeeded', reason: 'Owned binary release saved appears on the current form.' }) };else if (!input.tools?.length) message = { role: 'assistant', content: JSON.stringify(intent) };else {- let downloadId, submitRef;+ let downloadId, submitRef, downloadIds = [];const tools = input.messages.filter(item => item.role === 'tool');for (const item of tools) {const content = textOf(item.content);try {const result = JSON.parse(content.slice(content.indexOf('{'), content.lastIndexOf('}') + 1));downloadId ??= result.downloads?.[0]?.downloadId;+ if (result.downloads?.length) downloadIds = result.downloads.map(item => item.downloadId);submitRef ??= result.pageContent?.split('\n').find(line => /button "Publish release"/.test(line))?.match(/\[(ref_[A-Za-z0-9_-]+)\]/)?.[1];} catch {}}// A deep DOM leaves the first exact hidden input outside the capture// scan. Its rejected call must return before a fresh inventory and a// new model decision attach the same exact source to the intended slot.- const calls = [+ const calls = sequentialAssets ? [+ { name: 'download_files', args: { urls: filenames.map(name => `${base}/${name}`) } },+ ...filenames.flatMap((_, index) => [+ { name: 'get_interactive_elements', args: {} },+ { name: 'upload_file', args: { selector: '#releases-upload', downloadId: downloadIds[index] } },+ ]),+ { name: 'get_accessibility_tree', args: { filter: 'visible', maxChars: 8000 } },+ { name: 'click_ax', args: { ref_id: submitRef } },+ { name: 'read_page', args: { limit: 3000 } },+ { name: 'done', args: { outcome: 'partial', summary: 'The four owned ZIPs were attached and submitted once. Local QA finished.' } },+ ] : [{ name: 'download_files', args: { urls: [`${base}/owned-release.zip`] } },- { name: 'upload_file', args: { selector: '#releases-upload', downloadId } },+ { name: 'upload_file', args: { selector: selectorRecovery ? 'input[type="file"]' : '#releases-upload', downloadId } },+ // Replay the trace's guessed, nonexistent selector after the ambiguous+ // call. Neither failure may dispatch or silently choose an input.+ ...(selectorRecovery ? [{ name: 'upload_file', args: { selector: 'input[name="release[release_assets_attributes][][file]"]', downloadId } }] : []),{ name: 'get_interactive_elements', args: {} },{ name: 'upload_file', args: { selector: '#releases-upload', downloadId } },{ name: 'get_accessibility_tree', args: { filter: 'visible', maxChars: 8000 } },@@ -87,6 +111,7 @@ const profile = await fs.mkdtemp(path.join(os.tmpdir(), 'webbrain-upload-releasetry {const extension = path.resolve('src/chrome'), downloadsPath = path.join(profile, 'downloads'); await fs.mkdir(downloadsPath);context = await chromium.launchPersistentContext(profile, { headless: true, channel: 'chromium', acceptDownloads: true, downloadsPath,+ ...(sequentialAssets ? { viewport: { width: 1100, height: 1000 } } : {}),args: [`--disable-extensions-except=${extension}`, `--load-extension=${extension}`] });await context.route('**/*', route => {const url = new URL(route.request().url());@@ -105,34 +130,56 @@ try {const harness = await context.newPage(); await harness.goto(`chrome-extension://${new URL(worker.url()).host}/src/ui/settings.html`);const message = (action, data = {}) => harness.evaluate(({ action, data }) => chrome.runtime.sendMessage({ target: 'background', action, ...data }), { action, data });await harness.evaluate(() => chrome.storage.local.set({ helpImproveWebBrain: false, planBeforeActMode: 'off', planReviewMode: 'never',- screenshotFallback: false, autoScreenshot: false, maxAgentSteps: 12, systemOneEnabled: false, tracingEnabled: false,+ screenshotFallback: false, autoScreenshot: false, maxAgentSteps: 18, systemOneEnabled: false, tracingEnabled: false,agentAllowLocalNetwork: true, askBeforeConsequentialActions: false, openaiAskStreamingEnabled: false }));assert.equal((await message('update_provider', { providerId: 'openrouter', config: { apiKey: 'owned-fixture-key', baseUrl: `${base}/v1`,model: 'minimax/minimax-m3', enabled: true, contextWindow: 1000000, supportsAskStreaming: false } })).ok, true);assert.equal((await message('set_active_provider', { providerId: 'openrouter' })).ok, true);const page = await context.newPage(); await page.goto(`${base}/owned/repository/releases/new`);const tabId = await harness.evaluate(async url => (await chrome.tabs.query({})).find(tab => tab.url === url)?.id, page.url());- const result = await message('chat', { tabId, text: `Download ${base}/owned-release.zip. Attach exactly that ZIP to the binary widget, leaving the Markdown slot empty. Submit exactly once and verify Owned binary release saved.`,+ const result = await message('chat', { tabId, text: `Download ${filenames.map(name => `${base}/${name}`).join(', ')}. Attach exactly those ZIPs to the binary widget, leaving the Markdown slot empty. Submit exactly once and verify Owned binary release saved.`,mode: 'act', requestId: 'owned-upload-release', locale: 'en' });const state = await page.evaluate(() => ({ events: attachmentEvents, chooserClicks, status: document.getElementById('binary-status').textContent,- files: [...document.getElementById('releases-upload').files].map(file => ({ name: file.name, size: file.size })) }));+ files: [...document.getElementById('releases-upload').files].map(file => ({ name: file.name, size: file.size })),+ staged: [...document.querySelectorAll('.staged-asset input')].map(input => input.value) }));const toolResults = result.updates.filter(update => update.type === 'tool_result').map(update => update.data);await fs.writeFile(path.join(out, 'evidence.json'), JSON.stringify({ result, state, decisions, uploads, assetRequests,expectedBytes: zip.length, expectedSha256: crypto.createHash('sha256').update(zip).digest('hex') }, null, 2));const attachments = toolResults.filter(item => item.name === 'upload_file');- assert.equal(attachments.length, 2, JSON.stringify(toolResults));- assert.equal(attachments[0].result.errorCode, 'action_binding_unavailable');- assert.equal(attachments[0].result.noDispatch, true); assert.equal(attachments[0].result.dispatched, false);- assert.equal(attachments[1].result.success, true, JSON.stringify(attachments[1]));- assert.ok(decisions[3].precedingToolIds.includes('owned-release-upload-1'), 'A rejected original call returns before the new attachment decision.');- assert.ok(decisions[3].precedingToolIds.includes('owned-release-upload-2'), 'Fresh file inventory precedes the new decision.');- assert.deepEqual(state.events.markdown, []); assert.equal(state.events.binary.length, 1); assert.equal(state.chooserClicks, 0);- const downloaded = toolResults.find(item => item.name === 'download_files')?.result.downloads?.[0];- assert.equal(downloaded?.success, true); assert.equal(downloaded.url, `${base}/owned-release.zip`);- assert.deepEqual(state.files, [{ name: path.basename(downloaded.filename), size: zip.length }]);- assert.deepEqual(assetRequests, ['GET']); assert.equal(uploads.length, 1); assert.equal(uploads[0].exactBytes, true);+ const failures = sequentialAssets ? 0 : selectorRecovery ? 2 : 1, recoveryStep = selectorRecovery ? 4 : 3;+ assert.equal(attachments.length, failures + filenames.length, JSON.stringify(toolResults));+ for (const attachment of attachments.slice(0, failures)) {+ assert.equal(attachment.result.errorCode, 'action_binding_unavailable');+ assert.equal(attachment.result.noDispatch, true); assert.equal(attachment.result.dispatched, false);+ assert.match(attachment.result.error, /get_interactive_elements/);+ assert.doesNotMatch(attachment.result.error, /Use the ref_id/);+ }+ if (selectorRecovery) {+ assert.equal(attachments[0].result.bindingFailure, 'target_ambiguous');+ assert.equal(attachments[1].result.bindingFailure, 'target_unresolved');+ }+ for (const attachment of attachments.slice(failures)) {+ assert.equal(attachment.result.success, true, JSON.stringify(attachment));+ if (sequentialAssets) assert.equal(attachment.result.attachmentState, 'page_consumed');+ }+ if (!sequentialAssets) {+ assert.ok(decisions[recoveryStep].precedingToolIds.includes('owned-release-upload-1'), 'A rejected original call returns before the new attachment decision.');+ assert.ok(decisions[recoveryStep].precedingToolIds.includes(`owned-release-upload-${recoveryStep - 1}`), 'Fresh file inventory precedes the new decision.');+ }+ assert.deepEqual(state.events.markdown, []); assert.equal(state.events.binary.length, filenames.length); assert.equal(state.chooserClicks, 0);+ const downloaded = toolResults.find(item => item.name === 'download_files')?.result.downloads;+ assert.equal(downloaded?.length, filenames.length);+ for (const [index, item] of downloaded.entries()) {+ assert.equal(item.success, true); assert.equal(item.url, `${base}/${filenames[index]}`);+ assert.deepEqual(state.events.binary[index], [{ name: path.basename(item.filename), size: assets.get(filenames[index]).length }]);+ }+ if (sequentialAssets) {+ assert.deepEqual(state.files, []);+ assert.deepEqual(state.staged, downloaded.map(item => path.basename(item.filename)));+ } else assert.deepEqual(state.files, [{ name: path.basename(downloaded[0].filename), size: zip.length }]);+ assert.deepEqual(assetRequests, filenames.map(() => 'GET')); assert.equal(uploads.length, 1); assert.equal(uploads[0].exactBytes, true);assert.equal(state.status, 'Owned binary release saved');- console.log(JSON.stringify({ passed: true, firstUpload: 'known no-dispatch', recoveredUploads: 1, alternateSlotUploads: 0,+ console.log(JSON.stringify({ passed: true, rejectedUploads: failures, attachedAssets: filenames.length, alternateSlotUploads: 0,chooserClicks: 0, serverSubmissions: uploads.length, exactBytes: uploads[0].exactBytes }));} finally {await context?.close(); await new Promise(resolve => server.close(resolve));