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
Report Firefox scroll remainders as scrolls, not viewport changes
Claudebae727da4186
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 5295b1587..490c30c8a 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -20,6 +20,7 @@ This changelog was generated from the repository Git history and release tags. V- Page feedback: automatic page activity no longer discards revalidatable decisions, finished Act answers or the page_unstable budget; idle waits are no longer starved by automatic navigations; SPA route changes after agent clicks no longer cost an idle wait; stale feedback no longer leaks into the next run; Stop no longer waits for page capture; Ask answers survive user scrolling and selection.- Finished answers no longer reopen or loop when the page changes after completion; Stop no longer sends queued messages or corrections automatically (they stay queued, marked as paused); corrections apply immediately instead of after the current model response; planner history no longer shows browser observations as user messages; Chrome keeps the local vision fallback when the page updates.- Clicks, keys and text are never sent twice when the browser loses an acknowledgement after delivery; they are reported as sent with an unknown outcome. Continue and Retry no longer repeat an unconfirmed trusted click. Stopping while a field is being filled no longer submits it. Buttons that lift or change border on hover can be clicked.+- Firefox: a page's own fractional scrolling is no longer treated as a window or zoom change, so it no longer invalidates certified decisions where Chrome keeps them; real resizes, zoom and user scrolling still do.- Ordinary controls (filter chips, folder links, menus, tabs, toggles, draft attachment and media removal, composer tools) work before and after a correction; X and Bluesky no longer reject them as unidentified publication actions. After a correction, identical resubmissions are reported as already done, a corrected in-place save or a requested post on another platform is allowed once the earlier result is known, and requests to remove characters or hashtags are no longer treated as deleting the post. A submit-probe exception that left real publish controls unresolved is fixed.## [40.3.0] - 2026-10-12diff --git a/docs/page-feedback-monitor.md b/docs/page-feedback-monitor.mdindex e935103c9..36bb960b7 100644--- a/docs/page-feedback-monitor.md+++ b/docs/page-feedback-monitor.md@@ -17,6 +17,12 @@ time. Stop interrupts the wait.Window and visual-viewport size, zoom and offset changes invalidate preparedcoordinates. Top-level viewport activity waits for geometry to settle; embeddedframe size changes are page layout observations and do not extend the user gate.+A full-size, unzoomed visual viewport cannot pan by itself, so a sub-pixel+offset change with the same size, scale and DPR is the remainder of a+fractional layout scroll (Firefox reports it, Chromium does not). It is+reported as that scroll, with the document scroll's attribution, and counts as+scroll geometry in footprint comparisons, so both browsers treat a page's own+scrolling the same way.`composerDeliveryMode` only controls typed chat messages (Queue/Steer). Automaticpage feedback uses its own bounded queue and cannot promote a queued message todiff --git a/package.json b/package.jsonindex 367056fef..11c4f4472 100644--- a/package.json+++ b/package.json@@ -59,8 +59,8 @@"benchmark:relevance": "node scripts/benchmark-offline-relevance.mjs --verbose","test:social-contract": "node --test test/social-publish-contract.mjs test/publication-quote-markup.mjs","test:social-contract:dom": "node test/social-publish-contract-dom.mjs",- "test:runtime-lifecycle": "node test/bot-memory-dom.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-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/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/ask-response-scope.mjs test/ask-completion-churn.mjs test/page-feedback-policy.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/completion-current-execution-evidence.mjs test/monitor-intervention-contract.mjs test/monitor-owned-geometry.mjs test/monitor-local-attribution.mjs test/monitor-lifecycle-leaks.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/lifecycle-planner-digest.mjs test/lifecycle-vision-fallback.mjs test/guards-control-classification.mjs test/guards-steering-receipts.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/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/assistant-message-visibility-ui.mjs test/page-monitor-ui.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/dropdown-menu-inventory.mjs test/page-monitor-passive-progress.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 && node test/message-recipient-upload.mjs && node --test test/message-recipient-whatsapp.mjs && node test/quality/integration-mv3.mjs --full-form && node test/quality/literal-calculate-midrun-mv3.mjs && node test/quality/ask-completion-churn-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 && 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/literal-frame-mv3.mjs && node test/quality/mastodon-publication-mv3.mjs && node test/quality/mastodon-deletion-mv3.mjs && node test/quality/anchored-action-mv3.mjs && node test/quality/inline-social-composer-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",- "test:page-feedback": "node --test 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/pure-calculation-reply.mjs test/pure-calculation-tools.mjs test/page-feedback.mjs test/page-feedback-progress.mjs test/ask-response-scope.mjs test/ask-completion-churn.mjs test/page-feedback-policy.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/page-monitor-ui.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-passive-progress.mjs test/media-download-binding.mjs test/media-download-capture-integration.mjs test/monitor-intervention-contract.mjs test/monitor-owned-geometry.mjs test/monitor-local-attribution.mjs test/monitor-lifecycle-leaks.mjs test/feedback-automatic-churn.mjs test/feedback-navigation-idle.mjs test/feedback-run-boundaries.mjs test/feedback-ask-viewing.mjs test/delivery-click-ax-response-loss.mjs test/delivery-stop-compound.mjs test/delivery-cdp-input.mjs test/delivery-click-locks.mjs test/delivery-native-button-geometry.mjs && node test/message-recipient-upload.mjs && node --test test/message-recipient-whatsapp.mjs",+ "test:runtime-lifecycle": "node test/bot-memory-dom.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-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/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/ask-response-scope.mjs test/ask-completion-churn.mjs test/page-feedback-policy.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/completion-current-execution-evidence.mjs test/monitor-intervention-contract.mjs test/monitor-owned-geometry.mjs test/monitor-viewport-remainder.mjs test/monitor-local-attribution.mjs test/monitor-lifecycle-leaks.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/lifecycle-planner-digest.mjs test/lifecycle-vision-fallback.mjs test/guards-control-classification.mjs test/guards-steering-receipts.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/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/assistant-message-visibility-ui.mjs test/page-monitor-ui.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/dropdown-menu-inventory.mjs test/page-monitor-passive-progress.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 && node test/message-recipient-upload.mjs && node --test test/message-recipient-whatsapp.mjs && node test/quality/integration-mv3.mjs --full-form && node test/quality/literal-calculate-midrun-mv3.mjs && node test/quality/ask-completion-churn-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 && 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/literal-frame-mv3.mjs && node test/quality/mastodon-publication-mv3.mjs && node test/quality/mastodon-deletion-mv3.mjs && node test/quality/anchored-action-mv3.mjs && node test/quality/inline-social-composer-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",+ "test:page-feedback": "node --test 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/pure-calculation-reply.mjs test/pure-calculation-tools.mjs test/page-feedback.mjs test/page-feedback-progress.mjs test/ask-response-scope.mjs test/ask-completion-churn.mjs test/page-feedback-policy.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/page-monitor-ui.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-passive-progress.mjs test/media-download-binding.mjs test/media-download-capture-integration.mjs test/monitor-intervention-contract.mjs test/monitor-owned-geometry.mjs test/monitor-viewport-remainder.mjs test/monitor-local-attribution.mjs test/monitor-lifecycle-leaks.mjs test/feedback-automatic-churn.mjs test/feedback-navigation-idle.mjs test/feedback-run-boundaries.mjs test/feedback-ask-viewing.mjs test/delivery-click-ax-response-loss.mjs test/delivery-stop-compound.mjs test/delivery-cdp-input.mjs test/delivery-click-locks.mjs test/delivery-native-button-geometry.mjs && node test/message-recipient-upload.mjs && node --test test/message-recipient-whatsapp.mjs","test:chat-steering": "node --test test/chat-steering.mjs test/chat-steering-ui.mjs test/lifecycle-steering-latency.mjs test/lifecycle-run-ui.mjs","test:rich-text-dom": "node test/ui-content-lifecycle.mjs --dom","test:firefox-bidi": "node --test test/firefox-bidi.mjs test/firefox-full-page-screenshot.mjs",@@ -92,7 +92,7 @@"test:upload-owner": "node --test test/page-monitor-upload-owner.mjs test/page-monitor-upload-release.mjs","test:shard:quick": "npm run test:cms && npm run test:markdown && npm run test:generative-media && npm run test:systemone && npm run test:systemone:fast && node --test test/browser-dialogs.mjs test/capsolver-cloud-broker.mjs test/captcha-providers.mjs test/captcha-weighted-fallback.mjs test/captcha-hcaptcha-providers.mjs test/captcha-native-providers.mjs test/captcha-runtime-policy.mjs test/captcha-callback-bridge.mjs test/captcha-bridge-registration.mjs test/captcha-aws-recovery.mjs test/captcha-documented-contracts.mjs test/huggingface-signup-recovery.mjs test/trace-full-export.mjs test/feedback-traces.mjs && npm run test:firefox-bidi && npm run test:billing-notice && npm run test:compass-quota && npm run test:provider-limits && npm run test:provider-catalog && npm run test:provider-instances:ui && npm run test:openrouter-capabilities && npm run test:anthropic && npm run test:accessibility-tree-benchmark && npm run test:toolbar-guard && npm run test:cloud-bridge-approval && npm run test:discord && npm run test:pdf-read && npm run test:pdf-selection && npm run test:social-contract && npm run test:safesocial && npm run test:build-unpacked && npm run test:attachment-drop && npm run test:workflow-editor && node --test test/profile-sync-stats.mjs && node --test test/memcode-recall.mjs","test:shard:runtime-unit": "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/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/ask-response-scope.mjs test/ask-completion-churn.mjs test/page-feedback-policy.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/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/lifecycle-planner-digest.mjs test/lifecycle-steering-latency.mjs test/lifecycle-vision-fallback.mjs test/delivery-click-locks.mjs test/guards-steering-receipts.mjs test/terminal-user-messages.mjs",- "test:shard:browser-a": "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/assistant-message-visibility-ui.mjs test/page-monitor-ui.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/dropdown-menu-inventory.mjs test/page-monitor-passive-progress.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-local-attribution.mjs test/monitor-lifecycle-leaks.mjs test/lifecycle-run-ui.mjs test/delivery-cdp-input.mjs test/delivery-click-ax-response-loss.mjs test/delivery-native-button-geometry.mjs test/delivery-stop-compound.mjs test/guards-control-classification.mjs",+ "test:shard:browser-a": "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/assistant-message-visibility-ui.mjs test/page-monitor-ui.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/dropdown-menu-inventory.mjs test/page-monitor-passive-progress.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-local-attribution.mjs test/monitor-lifecycle-leaks.mjs test/lifecycle-run-ui.mjs test/delivery-cdp-input.mjs test/delivery-click-ax-response-loss.mjs test/delivery-native-button-geometry.mjs test/delivery-stop-compound.mjs test/guards-control-classification.mjs","test:shard:browser-b1": "node test/message-recipient-upload.mjs && node --test test/message-recipient-whatsapp.mjs && node test/quality/integration-mv3.mjs --full-form && node test/quality/literal-calculate-midrun-mv3.mjs && node test/quality/ask-completion-churn-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-c": "node test/quality/literal-frame-mv3.mjs && node test/quality/mastodon-publication-mv3.mjs && node test/quality/mastodon-deletion-mv3.mjs && node test/quality/anchored-action-mv3.mjs && node test/quality/inline-social-composer-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",diff --git a/src/chrome/src/content/page-monitor.js b/src/chrome/src/content/page-monitor.jsindex bf9f498f4..483d2167e 100644--- a/src/chrome/src/content/page-monitor.js+++ b/src/chrome/src/content/page-monitor.js@@ -182,6 +182,15 @@visualWidth: window.visualViewport?.width ?? window.innerWidth, visualHeight: window.visualViewport?.height ?? window.innerHeight,scale: window.visualViewport?.scale ?? 1, dpr: window.devicePixelRatio,offsetX: window.visualViewport?.offsetLeft ?? 0, offsetY: window.visualViewport?.offsetTop ?? 0 });+ // A full-size, unzoomed visual viewport has no independent pan range. When+ // only its sub-pixel offset differs, the change is the remainder of a+ // fractional layout scroll (Firefox reports it; Chromium does not), not a+ // zoom, resize or browser-chrome change.+ function viewportRemainderOnly(before, after) {+ return !!before && !!after && [before, after].every(value => value.scale === 1 && value.visualWidth === value.width+ && value.visualHeight === value.height && Math.abs(value.offsetX) < 1 && Math.abs(value.offsetY) < 1)+ && ['width', 'height', 'visualWidth', 'visualHeight', 'scale', 'dpr'].every(key => before[key] === after[key]);+ }function reconcileOwnedViewportOffset(viewport, event) {if (event?.target !== window.visualViewport || event.isTrusted !== true || !active || interventionUnreported) return false;for (const op of operations.values()) {@@ -195,19 +204,13 @@if (!after) continue;if (before.relaxed) {const original = proof.viewport;- if (!original || !sameRelaxedBinding(before, after)- || ![original, viewport].every(value => value.scale === 1 && value.visualWidth === value.width- && value.visualHeight === value.height && Math.abs(value.offsetX) < 1 && Math.abs(value.offsetY) < 1)- || ['width', 'height', 'visualWidth', 'visualHeight', 'scale', 'dpr'].some(key => original[key] !== viewport[key])) continue;+ if (!original || !sameRelaxedBinding(before, after) || !viewportRemainderOnly(original, viewport)) continue;ownedPreparationBindings.set(op.preparedBinding, { ...proof, binding: after, viewportNotificationPending: false });return true;}const originalContext = JSON.parse(before.context), currentContext = JSON.parse(after.context);const original = originalContext[2];- if (![original, viewport].every(value => value.scale === 1 && value.visualWidth === value.width- && value.visualHeight === value.height && Math.abs(value.offsetX) < 1 && Math.abs(value.offsetY) < 1)- || ['width', 'height', 'visualWidth', 'visualHeight', 'scale', 'dpr'].some(key => original[key] !== viewport[key])) continue;- // A full-size, unzoomed visual viewport has no independent pan range.+ if (!viewportRemainderOnly(original, viewport)) continue;// After an owned fractional scroll some engines report its subpixel// remainder late (e.g. pageTop=346.833, scrollY=347, offsetTop=-0.167).// Consume only that phase's first bounded native notification, with the@@ -684,11 +687,16 @@if (before?.relaxed) return sameRelaxedBinding(before, after);if (!before?.model || !after?.model) return false;if (![before, after].every(binding => binding.hit === binding.target || binding.target.contains?.(binding.hit))) return false;+ return samePreparedBinding(before, { ...after, hit: before.hit, context: withOriginalGeometry(before, after) });+ }+ // Only scroll offsets, the target rectangle and a scroll's sub-pixel visual+ // viewport remainder are geometry. URL, base, viewport size and zoom, and+ // recipient context stay exact.+ function withOriginalGeometry(before, after) {const original = JSON.parse(before.context), current = JSON.parse(after.context);- // Only scroll offsets and the target rectangle can be derived from this- // synchronous owned phase. URL, viewport and recipient context stay exact.for (const slot of [3, 4, 5]) current[slot] = original[slot];- return samePreparedBinding(before, { ...after, hit: before.hit, context: JSON.stringify(current) });+ if (viewportRemainderOnly(original[2], current[2])) current[2] = original[2];+ return JSON.stringify(current);}// Share a derived geometry proof for this original certificate. Callers// have checked samePreparationSemantics; private semantic values stay fixed.@@ -738,9 +746,7 @@if (before.target !== after.target || before.scope !== after.scope) return 'target_changed';if (before.context !== after.context || before.hit !== after.hit) {if (samePreparationSemantics(before, after)) return 'geometry_changed';- const original = JSON.parse(before.context), current = JSON.parse(after.context);- for (const slot of [3, 4, 5]) current[slot] = original[slot];- if (samePreparedBinding(before, { ...after, hit: before.hit, context: JSON.stringify(current) })) return 'target_hit_changed';+ if (samePreparedBinding(before, { ...after, hit: before.hit, context: withOriginalGeometry(before, after) })) return 'target_hit_changed';}return samePreparedBinding(before, after) ? '' : 'semantic_binding_changed';}@@ -2945,6 +2951,8 @@const onResize = event => {const current = currentViewport(), key = JSON.stringify(current);if (!active || key === lastViewport) return;+ let previous = null;+ try { previous = JSON.parse(lastViewport); } catch {}lastViewport = key; revision++; publishRevision();if (reconcileOwnedViewportOffset(current, event)) {send({ kind: 'resize', source: 'agent', target: 'viewport', viewport: current }); return;@@ -2954,6 +2962,13 @@return;}if (agentResize) void flushAgentResize('unknown');+ // Report a scroll remainder as the scroll it belongs to, attributed like+ // the document scroll; it is not a top-level viewport change.+ if (viewportRemainderOnly(previous, current)) {+ send({ kind: 'scroll', source: Date.now() - lastUserAt < 1000 ? 'user' : 'unknown',+ target: targetName(document.documentElement), viewport: { x: window.scrollX, y: window.scrollY } });+ return;+ }send({ kind: 'resize', source: window === window.top ? 'unknown' : 'page', target: 'viewport', viewport: current });};listen(window, 'resize', onResize);diff --git a/src/firefox/src/content/page-monitor.js b/src/firefox/src/content/page-monitor.jsindex bf9f498f4..483d2167e 100644--- a/src/firefox/src/content/page-monitor.js+++ b/src/firefox/src/content/page-monitor.js@@ -182,6 +182,15 @@visualWidth: window.visualViewport?.width ?? window.innerWidth, visualHeight: window.visualViewport?.height ?? window.innerHeight,scale: window.visualViewport?.scale ?? 1, dpr: window.devicePixelRatio,offsetX: window.visualViewport?.offsetLeft ?? 0, offsetY: window.visualViewport?.offsetTop ?? 0 });+ // A full-size, unzoomed visual viewport has no independent pan range. When+ // only its sub-pixel offset differs, the change is the remainder of a+ // fractional layout scroll (Firefox reports it; Chromium does not), not a+ // zoom, resize or browser-chrome change.+ function viewportRemainderOnly(before, after) {+ return !!before && !!after && [before, after].every(value => value.scale === 1 && value.visualWidth === value.width+ && value.visualHeight === value.height && Math.abs(value.offsetX) < 1 && Math.abs(value.offsetY) < 1)+ && ['width', 'height', 'visualWidth', 'visualHeight', 'scale', 'dpr'].every(key => before[key] === after[key]);+ }function reconcileOwnedViewportOffset(viewport, event) {if (event?.target !== window.visualViewport || event.isTrusted !== true || !active || interventionUnreported) return false;for (const op of operations.values()) {@@ -195,19 +204,13 @@if (!after) continue;if (before.relaxed) {const original = proof.viewport;- if (!original || !sameRelaxedBinding(before, after)- || ![original, viewport].every(value => value.scale === 1 && value.visualWidth === value.width- && value.visualHeight === value.height && Math.abs(value.offsetX) < 1 && Math.abs(value.offsetY) < 1)- || ['width', 'height', 'visualWidth', 'visualHeight', 'scale', 'dpr'].some(key => original[key] !== viewport[key])) continue;+ if (!original || !sameRelaxedBinding(before, after) || !viewportRemainderOnly(original, viewport)) continue;ownedPreparationBindings.set(op.preparedBinding, { ...proof, binding: after, viewportNotificationPending: false });return true;}const originalContext = JSON.parse(before.context), currentContext = JSON.parse(after.context);const original = originalContext[2];- if (![original, viewport].every(value => value.scale === 1 && value.visualWidth === value.width- && value.visualHeight === value.height && Math.abs(value.offsetX) < 1 && Math.abs(value.offsetY) < 1)- || ['width', 'height', 'visualWidth', 'visualHeight', 'scale', 'dpr'].some(key => original[key] !== viewport[key])) continue;- // A full-size, unzoomed visual viewport has no independent pan range.+ if (!viewportRemainderOnly(original, viewport)) continue;// After an owned fractional scroll some engines report its subpixel// remainder late (e.g. pageTop=346.833, scrollY=347, offsetTop=-0.167).// Consume only that phase's first bounded native notification, with the@@ -684,11 +687,16 @@if (before?.relaxed) return sameRelaxedBinding(before, after);if (!before?.model || !after?.model) return false;if (![before, after].every(binding => binding.hit === binding.target || binding.target.contains?.(binding.hit))) return false;+ return samePreparedBinding(before, { ...after, hit: before.hit, context: withOriginalGeometry(before, after) });+ }+ // Only scroll offsets, the target rectangle and a scroll's sub-pixel visual+ // viewport remainder are geometry. URL, base, viewport size and zoom, and+ // recipient context stay exact.+ function withOriginalGeometry(before, after) {const original = JSON.parse(before.context), current = JSON.parse(after.context);- // Only scroll offsets and the target rectangle can be derived from this- // synchronous owned phase. URL, viewport and recipient context stay exact.for (const slot of [3, 4, 5]) current[slot] = original[slot];- return samePreparedBinding(before, { ...after, hit: before.hit, context: JSON.stringify(current) });+ if (viewportRemainderOnly(original[2], current[2])) current[2] = original[2];+ return JSON.stringify(current);}// Share a derived geometry proof for this original certificate. Callers// have checked samePreparationSemantics; private semantic values stay fixed.@@ -738,9 +746,7 @@if (before.target !== after.target || before.scope !== after.scope) return 'target_changed';if (before.context !== after.context || before.hit !== after.hit) {if (samePreparationSemantics(before, after)) return 'geometry_changed';- const original = JSON.parse(before.context), current = JSON.parse(after.context);- for (const slot of [3, 4, 5]) current[slot] = original[slot];- if (samePreparedBinding(before, { ...after, hit: before.hit, context: JSON.stringify(current) })) return 'target_hit_changed';+ if (samePreparedBinding(before, { ...after, hit: before.hit, context: withOriginalGeometry(before, after) })) return 'target_hit_changed';}return samePreparedBinding(before, after) ? '' : 'semantic_binding_changed';}@@ -2945,6 +2951,8 @@const onResize = event => {const current = currentViewport(), key = JSON.stringify(current);if (!active || key === lastViewport) return;+ let previous = null;+ try { previous = JSON.parse(lastViewport); } catch {}lastViewport = key; revision++; publishRevision();if (reconcileOwnedViewportOffset(current, event)) {send({ kind: 'resize', source: 'agent', target: 'viewport', viewport: current }); return;@@ -2954,6 +2962,13 @@return;}if (agentResize) void flushAgentResize('unknown');+ // Report a scroll remainder as the scroll it belongs to, attributed like+ // the document scroll; it is not a top-level viewport change.+ if (viewportRemainderOnly(previous, current)) {+ send({ kind: 'scroll', source: Date.now() - lastUserAt < 1000 ? 'user' : 'unknown',+ target: targetName(document.documentElement), viewport: { x: window.scrollX, y: window.scrollY } });+ return;+ }send({ kind: 'resize', source: window === window.top ? 'unknown' : 'page', target: 'viewport', viewport: current });};listen(window, 'resize', onResize);diff --git a/test/monitor-viewport-remainder.mjs b/test/monitor-viewport-remainder.mjsnew file mode 100644index 000000000..e05488a00--- /dev/null+++ b/test/monitor-viewport-remainder.mjs@@ -0,0 +1,146 @@+// A full-size, unzoomed visual viewport cannot pan by itself. Firefox reports+// the sub-pixel remainder of a fractional page scroll as a visual-viewport+// notification (Chromium does not); it is part of that scroll, not a zoom,+// resize or browser-chrome change. Real viewport changes and user scrolling+// still invalidate model-bound decisions, and a scroll that persists still+// changes the exact geometry the decision was certified for.+import assert from 'node:assert/strict';+import fs from 'node:fs';+import { test } from 'node:test';+import { chromium, firefox } from 'playwright';++const RUN = 'viewport-remainder-run';+const body = `<!doctype html><style>+body { margin: 20px; font: 16px sans-serif; } #commit { width: 200px; height: 45px; }+</style><main><h1>Current record settings</h1><button id="commit" type="button">Apply settings</button>+<label>Record title <input id="title" value="Neutral draft"></label></main><div style="height:4000px"></div>+<div id="near" style="position:absolute;left:0;top:12.35px;width:1px;height:1px"></div>+<div id="far" style="position:absolute;left:0;top:1250.35px;width:1px;height:1px"></div>+<script>window.clicks = 0; document.getElementById('commit').addEventListener('click', () => clicks++);</script>`;++async function fixture(browser, build) {+ const context = await browser.newContext({ viewport: { width: 900, height: 700 } });+ await context.route('https://viewport-remainder.test/**', route => route.fulfill({ contentType: 'text/html', body }));+ await context.addInitScript(RUN => {+ window.feedback = []; window.messageListeners = []; window.remainders = [];+ const runtime = {+ onMessage: { addListener: fn => messageListeners.push(fn), removeListener() {} },+ async sendMessage(msg) {+ if (msg.action === 'get_page_monitor_state') return { active: true, runToken: RUN, documentToken: msg.documentToken };+ if (msg.action === 'page_feedback') { feedback.push(msg.feedback); return { accepted: true }; }+ return {};+ },+ };+ window.chrome = { runtime }; window.browser = window.chrome;+ window.deliver = (action, params = {}) => new Promise(resolve => {+ let answered = false;+ const respond = value => { answered = true; resolve(value); };+ for (const listener of messageListeners) {+ const asynchronous = listener({ target: 'content', action, params: { runToken: RUN, ...params } }, {}, respond);+ if (answered || asynchronous === true) return;+ }+ resolve(undefined);+ });+ addEventListener('DOMContentLoaded', () => window.visualViewport?.addEventListener('scroll',+ () => remainders.push(visualViewport.offsetTop)));+ }, RUN);+ await context.addInitScript({ content: fs.readFileSync(new URL(`../src/${build}/src/content/page-monitor.js`, import.meta.url), 'utf8') });+ const tab = await context.newPage();+ await tab.goto('https://viewport-remainder.test/start');+ await tab.waitForFunction(() => window.__wbPageMonitor?.active);+ await tab.mouse.move(5, 690);+ await tab.waitForTimeout(1100); // the pointer move is older than the user-scroll window+ await tab.evaluate(() => { feedback = []; remainders = []; });+ return { context, page: tab };+}++const message = (tab, action, params = {}) => tab.evaluate(({ action, params }) => Promise.race([deliver(action, params),+ new Promise(resolve => setTimeout(() => resolve({ ready: false, code: 'monitor_response_missing' }), 3000))]), { action, params });++async function certify(tab) {+ const snapshot = await message(tab, 'page_monitor_capture_model');+ assert.equal(snapshot.ready, true);+ const base = { runToken: RUN, operationId: 'remainder', tool: 'click', selector: '#commit',+ expectedModelSnapshot: snapshot.snapshotToken, allowPassiveRebase: true };+ assert.equal((await message(tab, 'page_monitor_prepare', base)).modelBindingValid, true);+ return base;+}++// Page-script scrolls, each followed by its frames and native notifications.+// Aligning an element at a fractional offset leaves a sub-pixel remainder in+// Firefox; scrolling to the top removes it again. Gecko re-applies a pending+// scrollIntoView on its next reflow, so each step settles one reflow first.+const pageScrolls = (tab, steps) => tab.evaluate(async steps => {+ const settle = () => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(() => setTimeout(resolve, 60))));+ const reflow = () => { document.body.style.paddingBottom = '1px'; void document.body.offsetHeight;+ document.body.style.paddingBottom = ''; void document.body.offsetHeight; };+ for (const step of steps) {+ if (step === 'top') scrollTo({ top: 0, behavior: 'instant' });+ else document.getElementById(step).scrollIntoView({ block: 'start', behavior: 'instant' });+ reflow(); await settle();+ }+ await new Promise(resolve => setTimeout(resolve, 200)); // the coalesced final scroll report+ return scrollY;+}, steps);++for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {+ test(`${build}: a page's fractional scroll is reported as a scroll, never as a viewport change`, { timeout: 60000 }, async () => {+ const browser = await engine.launch({ headless: true });+ try {+ const { page } = await fixture(browser, build);+ assert.equal(await pageScrolls(page, ['far', 'near', 'top']), 0);+ const { events, remainders } = await page.evaluate(() => ({ events: feedback, remainders }));+ // Firefox must actually have reported the sub-pixel remainder, so this+ // exercises the notification rather than passing vacuously.+ if (build === 'firefox') assert.ok(remainders.some(offset => offset !== 0), JSON.stringify(remainders));+ assert.equal(events.some(event => event.kind === 'resize'), false, JSON.stringify(events));+ assert.ok(events.some(event => event.kind === 'scroll' && event.source === 'unknown'), JSON.stringify(events));+ assert.equal(events.some(event => event.source === 'user'), false, JSON.stringify(events));+ } finally { await browser.close(); }+ });++ test(`${build}: a certified decision survives a page scroll that returns to the same position`, { timeout: 60000 }, async () => {+ const browser = await engine.launch({ headless: true });+ try {+ const { page } = await fixture(browser, build);+ const base = await certify(page);+ assert.equal(await pageScrolls(page, ['near', 'top']), 0);+ const fence = await message(page, 'page_monitor_dispatch', { ...base, kind: 'click', fenceOnly: true });+ const state = await page.evaluate(() => ({ events: feedback, remainders, clicks }));+ if (build === 'firefox') assert.ok(state.remainders.some(offset => offset !== 0), JSON.stringify(state.remainders));+ assert.equal(fence.ready, true, JSON.stringify({ fence, state }));+ assert.equal(state.clicks, 0);+ } finally { await browser.close(); }+ });++ test(`${build}: persisting scroll, zoom, resize and user scroll still refuse the decision`, { timeout: 120000 }, async t => {+ const browser = await engine.launch({ headless: true });+ try {+ for (const [name, change, predicate] of [+ ['page scroll that persists', async page => assert.ok(await pageScrolls(page, ['near']) > 0), /geometry_changed/],+ ['visual viewport zoom', page => page.evaluate(() => {+ Object.defineProperty(visualViewport, 'scale', { configurable: true, get: () => 1.25 });+ visualViewport.dispatchEvent(new Event('resize'));+ }), /intervention_changed/],+ ['viewport size', async page => {+ await page.setViewportSize({ width: 900, height: 650 });+ await page.waitForFunction(() => feedback.some(event => event.kind === 'resize'));+ }, /intervention_changed/],+ ['user wheel scroll', async page => {+ await page.mouse.move(450, 400); await page.mouse.wheel(0, 40);+ await page.waitForFunction(() => scrollY > 0); await page.waitForTimeout(200);+ }, /intervention_changed/],+ ]) await t.test(name, async () => {+ const { context, page } = await fixture(browser, build);+ try {+ const base = await certify(page);+ await change(page);+ const fence = await message(page, 'page_monitor_dispatch', { ...base, kind: 'click', fenceOnly: true });+ assert.equal(fence.ready, false, JSON.stringify(fence));+ assert.match(fence.preparationVeto?.predicate || '', predicate, JSON.stringify(fence));+ assert.equal(await page.evaluate(() => clicks), 0);+ } finally { await context.close(); }+ });+ } finally { await browser.close(); }+ });+}diff --git a/test/typing-preparation-geometry.mjs b/test/typing-preparation-geometry.mjsindex 09c58e89c..98404eba1 100644--- a/test/typing-preparation-geometry.mjs+++ b/test/typing-preparation-geometry.mjs@@ -112,7 +112,6 @@ for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {await f.page.evaluate(ref_id => qaMessage('type_ax', { ref_id, text: 'Replacement draft', clear: true,_bidiPrepare: '00000000-0000-4000-8000-000000000000' }), f.ref_id);if (name.startsWith('later ') && /viewport|zoom|DPR/.test(name)) await f.page.waitForTimeout(80);- const previousScroll = name === 'later viewport motion' ? await f.page.evaluate(() => scrollY) : null;if (name === 'later human click') await f.page.locator('#private').click();else if (name === 'later viewport dimensions') await f.page.setViewportSize({ width: 900, height: 650 });else await f.page.evaluate(name => {@@ -124,7 +123,6 @@ for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {Object.defineProperty(visualViewport, 'offsetTop', { configurable: true, get: () => 0.25 });visualViewport.dispatchEvent(new Event('scroll'));}- if (name === 'later viewport motion') scrollBy({ top: 2, behavior: 'instant' });if (name === 'later zoom') {Object.defineProperty(visualViewport, 'scale', { configurable: true, get: () => 1.25 });visualViewport.dispatchEvent(new Event('resize'));@@ -136,15 +134,32 @@ for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {if (name === 'changed URL') history.pushState({}, '', '/changed-editor');if (name === 'Stop') return qaMessage('page_monitor_state', { active: false });}, name);- // Gecko can apply even an instant scroll on its next refresh. Check an- // actual later viewport movement, rather than a queued scroll request.- if (name === 'later viewport motion') await f.page.waitForFunction(previous => Math.abs(scrollY - previous) >= 1, previousScroll);const result = await f.page.evaluate(async ({ ref_id, name }) => {const params = {operationId: 'owned-input', tool: 'type_ax', kind: 'input', ref_id, fenceOnly: true,...(name === 'different run' ? { runToken: 'new-run' } : {}),...(name === 'different document' ? { documentToken: 'new-document' } : {}),};+ if (name === 'later viewport motion') {+ // Gecko re-applies the agent's own pending scrollIntoView on its+ // next reflow, which would undo the page's motion (the exact+ // footprint is then intact again). Let that reflow happen first.+ document.body.style.paddingBottom = '1px'; void document.body.offsetHeight;+ document.body.style.paddingBottom = ''; void document.body.offsetHeight;+ const previous = scrollY;+ scrollBy({ top: 2, behavior: 'instant' });+ // Gecko can apply even an instant scroll on its next refresh. Fence+ // in the first frame that shows the actual later movement.+ return new Promise((resolve, reject) => {+ const deadline = performance.now() + 5000;+ const check = () => {+ if (Math.abs(scrollY - previous) >= 1) qaMessage('page_monitor_dispatch', params).then(resolve, reject);+ else if (performance.now() > deadline) reject(new Error(`the page did not move from ${previous}`));+ else requestAnimationFrame(check);+ };+ requestAnimationFrame(check);+ });+ }if (name === 'stale native revision') {// Isolate the revision contract from an earlier scroll/layout// observation: a fresh decision owns the current exact editor.@@ -158,6 +173,7 @@ for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {return qaMessage('page_monitor_dispatch', params);}, { ref_id: f.ref_id, name });assert.equal(result.ready, false, JSON.stringify(result));+ if (name === 'later viewport motion') assert.equal(result.preparationVeto?.predicate, 'geometry_changed', JSON.stringify(result));assert.equal(await f.page.evaluate(() => qaInputCount), 0);} finally { await f.browser.close(); }});