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
Let Mastodon's delete confirmation through after WebBrain's own menu click
Claudea93ee1d10606
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 02760a8ce..9efa149bc 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,6 +7,7 @@ This changelog was generated from the repository Git history and release tags. V## [Unreleased]### Fixed+- Mastodon: deleting your own post no longer stops at Mastodon's "Delete post?" confirmation. WebBrain opened the post's "…" menu and chose Delete, and the confirmation that its own click opened was refused as "not inside one identifiable record". When the menu entry was clicked no model had read its caption yet, so WebBrain had not tied the confirmation to the post, and while the confirmation is open Mastodon makes the rest of the page inert, which WebBrain read as the post and your account being hidden. Mastodon's dangerous entries on your own post now count as its deletion by page structure, the post and your account behind the confirmation still count, and Mastodon's own confirm button is recognized in windows narrower than 1175 px, where Mastodon shows no composer beside the timeline. A confirmation that WebBrain's click did not open, another account's post, and anything inert without Mastodon's confirmation open still bind nothing. With Mastodon's confirmation turned off, the dangerous entry is checked as the deletion itself even before its caption is read.- Ask mode: an answer being written no longer disappears and starts over when you use the page meanwhile. In a WhatsApp trace, typing a draft and clicking in the chat while the answer was written threw the answer away twice and wrote it again each time, and the answer that finally stayed, written after you stopped, was the shortest. Scrolling, selecting, clicking and typing on the page, and the page's changes from them, now leave the answer as it is: it is about the page as you asked about it, and the run ends without waiting for you to stop typing. Navigating the page to another address still starts the answer over.- Posting on another site after a correction: after a Mastodon post, "ok now on X" no longer leaves WebBrain going back and forth between the two sites, typing the X post again each time. It counted X as the same platform as Mastodon, because it reads account names only on X and Bluesky, and asked to find the Mastodon post on X itself, which can never happen. The site a post was made on now names its platform when no account name was read, and a post on another site goes ahead once a page has been read since the correction, provided the task made no earlier post on that site. What the task attempted is saved with the conversation, and just before each action that may post or submit something, so this still holds when the task continues after WebBrain restarted, and a post already sent on X under the correction is not sent again by a later run of the task. When the task did post on that site before, or WebBrain has no full record of its earlier attempts, it stops once and says so, instead of searching for a post it cannot find. A search, a settings save or consent click on X, a click that sent nothing or a form the page rejected is not such a post; a click that Stop interrupted after it was sent counts. On the other hosts and clients of X and Bluesky, such as X Pro, whose Post buttons WebBrain does not recognize, anything sent that may have been a post counts as one, so a post from X Pro is not repeated on x.com; this includes a Post button whose caption no model read in time, which looked like a harmless button, while Enter in the post editor there edits the draft and is not a post. If that record cannot be saved just before a possible post on X or Bluesky, the post is not sent and WebBrain says why, as it already does when a run's recovery checkpoint cannot be saved. x.com and twitter.com are one platform.- Chrome: a page's "Leave site?" prompt no longer waits for you when WebBrain navigates away during a task that started on a page the debugger cannot attach to, such as chrome://extensions, or whose debugger connection dropped. WebBrain arms its dialog handling again at the next debugger attach and around each of its own navigations, and answers Leave for its own navigation as it already did on other runs. If you cancel the debugger, prompts stay yours to answer. Firefox offers extensions no way to answer these prompts.diff --git a/docs/architecture.md b/docs/architecture.mdindex 0b87dd30d..c63a899ef 100644--- a/docs/architecture.md+++ b/docs/architecture.md@@ -161,7 +161,20 @@ a script, by another launcher, or alongside a second new one. A menu that opensinside a dialog already on screen counts, and so does a menu inside a newwrapper that opened with it. A Mastodon post'smenu and its confirmation are captured the same way for the native post, and-the action bar Mastodon draws beside a detailed status belongs to that status. A+the action bar Mastodon draws beside a detailed status belongs to that status.+On a post of the signed-in account, the menu's entries Mastodon marks dangerous+(Delete, Delete & re-draft; buttons since 4.4, links drawn as buttons in 4.3)+are deletions of that post by page structure, read or not: with Mastodon's confirmation preference on, the confirmation such an+entry's click opens belongs to the post; with it off, the entry is the deletion+itself. Mastodon makes the rest of the page inert while its confirmation is+open, so the native identity reads (the post, its links and text, the signed-in+account) look through the inert mark on the siblings of that open modal root,+and through nothing else. The signed-in account is the navigation's account+link, or, in layouts without one, the account the app's initial state names;+the two must agree. The confirmation's primary button counts as Mastodon's own+commit in any layout, also below 1175 px, where Mastodon shows no composer+beside the timeline. The probe identifies the page's records once per run,+however many of its checks need them. Aconfirmation dialog borrows the record of the agent's own authorized clickonly when it opened after that click was checked, within 30 seconds, and holdsthat one deletion control. The probe receives nothing from the request.diff --git a/package.json b/package.jsonindex eaf8396c3..935ca0312 100644--- a/package.json+++ b/package.json@@ -59,7 +59,7 @@"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/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/lifecycle-steering-restart.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/workflow-field-readings.mjs test/workflow-field-anchors.mjs test/user-turn-kind.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-unbound-deletion.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/recipient-confirmation-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/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 && 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/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 && 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/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/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: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/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/lifecycle-steering-restart.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/workflow-field-readings.mjs test/workflow-field-anchors.mjs test/user-turn-kind.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-unbound-deletion.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/recipient-confirmation-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/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 && 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/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 && 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/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/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: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/page-monitor-feed-items.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 test/delivery-hover-transition.mjs test/delivery-dispatch-boundary.mjs && node test/message-recipient-upload.mjs && node test/message-recipient-clarify-binding.mjs && node --test test/message-recipient-whatsapp.mjs","test:chat-steering": "node --test test/chat-steering.mjs test/chat-steering-ui.mjs test/recipient-confirmation-ui.mjs test/lifecycle-steering-latency.mjs test/lifecycle-steering-restart.mjs test/lifecycle-run-ui.mjs test/lifecycle-menu-prompts-held.mjs","test:rich-text-dom": "node test/ui-content-lifecycle.mjs --dom",@@ -92,14 +92,14 @@"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/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/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/workflow-field-readings.mjs test/workflow-field-anchors.mjs test/user-turn-kind.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-steering-restart.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/recipient-confirmation-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/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-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-dispatch-boundary.mjs test/delivery-stop-compound.mjs test/guards-control-classification.mjs test/guards-unbound-deletion.mjs test/submit-probe-readings.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/recipient-confirmation-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/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-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-dispatch-boundary.mjs test/delivery-stop-compound.mjs test/guards-control-classification.mjs test/guards-unbound-deletion.mjs test/submit-probe-readings.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/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-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/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/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: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/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/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/bluesky-composer-mv3.mjs","test:bot-memory": "node --test test/bot-memory.mjs test/bot-memory-registries.mjs test/bot-memory-cloud-controller.mjs && node test/bot-memory-dom.mjs && node test/quality/cloud-bot-memory-mv3.mjs",- "test:shared-action-guards": "node --test test/typing-preparation-geometry.mjs test/resource-mutation-guards.mjs test/completion-steering-receipt-authority.mjs test/social-ui-navigation.mjs test/native-resource-deletion-binding.mjs test/trusted-field-preparation-ownership.mjs test/guards-control-classification.mjs test/guards-unbound-deletion.mjs test/guards-steering-receipts.mjs && node test/quality/shared-action-guards-mv3.mjs"+ "test:shared-action-guards": "node --test test/typing-preparation-geometry.mjs test/resource-mutation-guards.mjs test/completion-steering-receipt-authority.mjs test/social-ui-navigation.mjs test/native-resource-deletion-binding.mjs test/native-mastodon-confirmation.mjs test/trusted-field-preparation-ownership.mjs test/guards-control-classification.mjs test/guards-unbound-deletion.mjs test/guards-steering-receipts.mjs && node test/quality/shared-action-guards-mv3.mjs"},"devDependencies": {"c8": "^12.0.0",diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.jsindex e430befa8..09161a16e 100644--- a/src/chrome/src/agent/agent.js+++ b/src/chrome/src/agent/agent.js@@ -29267,8 +29267,12 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dconst modal = candidate?.closest?.('.modal-root__modal.safety-action-modal');if (!modal || !isRenderedNative(candidate) || !isRenderedNative(modal)|| candidate.disabled || candidate.getAttribute('aria-disabled') === 'true') return false;- if (!doc.querySelector('form.compose-form textarea.autosuggest-textarea__textarea')- || !doc.querySelector('.navigation-bar a.account__display-name[href],.navigation-panel a.account__display-name[href]')) return false;+ // The signed-in web app, in any layout: the navigation's account link,+ // or the app's own state naming the signed-in account. Mastodon shows+ // no composer beside the timeline in windows narrower than 1175 px.+ const me = nativeInitialState()?.meta?.me;+ if (!doc.querySelector('.navigation-bar a.account__display-name[href],.navigation-panel a.account__display-name[href]')+ && !(typeof me === 'string' && me)) return false;const modals = [...doc.querySelectorAll('.modal-root__modal.safety-action-modal')].filter(isRenderedNative);const primary = [...modal.querySelectorAll('.safety-action-modal__actions > button.button')].filter(isRenderedNative);return modals.length === 1 && primary.length === 1 && primary[0] === candidate;@@ -29603,6 +29607,75 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d}return true;};+ // While one of Mastodon's modals is open, its ModalRoot marks every+ // sibling of .modal-root inert: the page behind stays rendered, only out+ // of reach. A delete confirmation's post and the signed-in account are+ // there, so the reads that identify them look through that mark (and the+ // pointer-events an inert polyfill adds), and through nothing else. The+ // probe runs synchronously, so the page cannot change while it caches this.+ let nativeModalBackgroundSet = null;+ const nativeModalBackgrounds = () => {+ if (nativeModalBackgroundSet) return nativeModalBackgroundSet;+ nativeModalBackgroundSet = new Set();+ try {+ for (const root of doc.querySelectorAll('.modal-root')) {+ const open = [...root.querySelectorAll('.modal-root__modal')].some(modal => {+ const rect = modal.getBoundingClientRect();+ return rect.width > 0 && rect.height > 0;+ });+ if (!open) continue;+ for (const sibling of root.parentElement?.children || []) {+ if (sibling !== root && sibling.matches('[inert],[aria-hidden="true"]')) nativeModalBackgroundSet.add(sibling);+ }+ }+ } catch {}+ return nativeModalBackgroundSet;+ };+ const nativeIdentityVisible = element => {+ const backgrounds = nativeModalBackgrounds();+ let behind = false;+ for (let node = element; node && backgrounds.size && !behind; node = node.parentElement) behind = backgrounds.has(node);+ if (!behind) return nativeResourceVisible(element);+ try {+ const rect = element.getBoundingClientRect();+ if (!element.isConnected || !(rect.width > 0 && rect.height > 0)) return false;+ for (let node = element; node; node = node.parentElement) {+ const style = getComputedStyle(node);+ if (node.matches('[hidden]') || (node.matches('[inert],[aria-hidden="true"]') && !backgrounds.has(node))+ || style.display === 'none' || ['hidden', 'collapse'].includes(style.visibility)+ || Number.parseFloat(style.opacity) === 0 || style.contentVisibility === 'hidden') return false;+ }+ return true;+ } catch { return false; }+ };+ // A Mastodon account as its profile address on this server.+ const nativeAccountIdentity = href => {+ try { const parsed = new URL(href, url); return parsed.origin === location.origin && !parsed.search && !parsed.hash+ && /^\/@[a-z0-9_]+\/?$/i.test(parsed.pathname) ? `${parsed.origin}${parsed.pathname.replace(/\/$/, '').toLowerCase()}` : ''; }+ catch { return ''; }+ };+ let nativeInitialStateValue;+ const nativeInitialState = () => {+ if (nativeInitialStateValue !== undefined) return nativeInitialStateValue;+ nativeInitialStateValue = null;+ try { const state = doc.querySelector('script#initial-state[type="application/json"]');+ if (state && state.textContent.length <= 2500000) nativeInitialStateValue = JSON.parse(state.textContent);+ } catch {}+ return nativeInitialStateValue;+ };+ // The signed-in account: the navigation's account link where the layout+ // shows one (beside the composer on wide windows; in the navigation panel+ // since 4.4), else the app's own initial state, which every layout has.+ // Two that disagree name no account.+ const nativeSignedInAccount = () => {+ const shown = [...new Set([...doc.querySelectorAll('.navigation-bar a.account__display-name[href],.navigation-panel a.account__display-name[href]')]+ .filter(nativeIdentityVisible).map(link => nativeAccountIdentity(link.href)).filter(Boolean))];+ const state = nativeInitialState(), me = state?.meta?.me;+ const account = typeof me === 'string' && me && state.accounts && typeof state.accounts === 'object' ? state.accounts[me] : null;+ const initial = typeof account?.url === 'string' ? nativeAccountIdentity(account.url) : '';+ if (shown.length > 1 || (shown.length && initial && shown[0] !== initial)) return '';+ return shown[0] || initial;+ };// The native record an element belongs to: its own status, or for the// action bar Mastodon renders beside a detailed status (not inside it),// the one detailed status in the same wrapper.@@ -29650,30 +29723,24 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d};const nativeResourceProofs = () => {if (args.__wbNativeResourceAdapter !== 'mastodon') return [];- const identity = href => {- try { const parsed = new URL(href, url); return parsed.origin === location.origin && !parsed.search && !parsed.hash- && /^\/@[a-z0-9_]+\/?$/i.test(parsed.pathname) ? `${parsed.origin}${parsed.pathname.replace(/\/$/, '').toLowerCase()}` : ''; }- catch { return ''; }- };- const accounts = [...new Set([...doc.querySelectorAll('.navigation-bar a.account__display-name[href],.navigation-panel a.account__display-name[href]')]- .filter(nativeResourceVisible).map(link => identity(link.href)).filter(Boolean))];- if (accounts.length !== 1) return [];- const records = [...doc.querySelectorAll('.status,.detailed-status')].filter(nativeResourceVisible);+ const signedIn = nativeSignedInAccount();+ if (!signedIn) return [];+ const records = [...doc.querySelectorAll('.status,.detailed-status')].filter(nativeIdentityVisible);const proofs = [];for (const record of records.slice(0, 80)) {const own = selector => [...record.querySelectorAll(selector)].filter(node => node.closest('.status,.detailed-status') === record);- const links = own('a.status__relative-time[href],a.detailed-status__datetime[href]').filter(nativeResourceVisible);- const authors = own('a.status__display-name[href],a.detailed-status__display-name[href]').filter(nativeResourceVisible);- const contents = own('.status__content__text--visible').filter(nativeResourceVisible);+ const links = own('a.status__relative-time[href],a.detailed-status__datetime[href]').filter(nativeIdentityVisible);+ const authors = own('a.status__display-name[href],a.detailed-status__display-name[href]').filter(nativeIdentityVisible);+ const contents = own('.status__content__text--visible').filter(nativeIdentityVisible);if (links.length !== 1 || authors.length !== 1 || contents.length !== 1|| record.querySelector('textarea,[contenteditable="true"]')) continue;let permalink; try { permalink = new URL(links[0].href); } catch { continue; }const handle = permalink.pathname.match(/^\/@([a-z0-9_]+)\/\d+\/?$/i)?.[1];- const account = identity(authors[0].href);+ const account = nativeAccountIdentity(authors[0].href);if (!handle || permalink.origin !== location.origin || permalink.search || permalink.hash- || account !== `${permalink.origin}/@${handle.toLowerCase()}` || account !== accounts[0]) continue;+ || account !== `${permalink.origin}/@${handle.toLowerCase()}` || account !== signedIn) continue;const nodes = [record, ...record.querySelectorAll('*')];- const textValues = [...new Set(nodes.slice(0, 400).filter(nativeResourceVisible).flatMap(node => [node.innerText, node.textContent])+ const textValues = [...new Set(nodes.slice(0, 400).filter(nativeIdentityVisible).flatMap(node => [node.innerText, node.textContent]).filter(value => typeof value === 'string' && value.length <= 25000))];proofs.push({ url: permalink.href, account, nativeAdapter: 'mastodon',taskKey: args.__wbResourceTaskKey, runToken: args.__wbResourceRunToken,@@ -29682,7 +29749,12 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d}return proofs;};+ // The probe runs synchronously, so the page's records cannot change while+ // it does: they are identified once per run, not again for every question+ // the probe asks about them.+ let resourceProofsOfRun = null;const resourceProofs = () => {+ if (resourceProofsOfRun) return [...resourceProofsOfRun];const known = new Set(publicationResourceUrls().urls);const records = [...doc.querySelectorAll('article,[role="article"],[role="listitem"],[itemid]')].filter(isVisible);const results = [];@@ -29705,8 +29777,9 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d// Native evidence is authoritative for a native record, including its// active account fence; a generic wrapper cannot bypass that fence.const native = nativeResourceProofs();- return args.__wbNativeResourceAdapter === 'mastodon'+ resourceProofsOfRun = args.__wbNativeResourceAdapter === 'mastodon'? results.filter(proof => !proof._record.matches('.status,.detailed-status')).concat(native) : results;+ return [...resourceProofsOfRun];};const resourceProofFor = target => {const records = resourceProofs();@@ -29978,6 +30051,9 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d&& String(link.getAttribute('role') || '').toLowerCase() !== 'button'&& !destructiveLinkQuery(link);})();+ // A dangerous entry of the signed-in account's own post menu that+ // deletes at once (Mastodon's confirmation preference is off).+ let nativeMenuDeletion = false;if (control && ['click', 'click_ax', 'iframe_click'].includes(toolName)&& nativeResourceVisible(control) && !control.disabled && control.getAttribute('aria-disabled') !== 'true'&& !control.form && !control.closest('form')) {@@ -29985,19 +30061,22 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dconst more = control.closest('.status__action-bar,.detailed-status__action-bar')&& control.querySelector('svg.icon-ellipsis-h');// The "…" button opens the post's menu: a caption read as a commit or- // a deletion would be another control. The menu's dangerous item read- // as deleting the post opens Mastodon's own confirmation.+ // a deletion would be another control.const dangerousCaption = commitReading(actionReading) || deletionReading(actionReading);- const menuDelete = control.matches('.dropdown-menu__item--dangerous > button[data-index]')- && actionReading === 'delete_one';+ // Mastodon marks a post menu's destructive entries dangerous. On a post+ // of the signed-in account, the only kind with a native proof, those+ // are Delete and Delete & re-draft: deletions of that post by page+ // structure, whether or not a model has read their captions yet. The+ // entries are buttons since 4.4, and links drawn as buttons in 4.3.+ const menuDelete = control.matches('.dropdown-menu__item--dangerous > button[data-index],'+ + '.dropdown-menu__item--dangerous > a[role="button"][data-index]') && !!control.closest('.dropdown-menu');// Mastodon supports direct deletion when its confirmation preference// is disabled. Only its explicit enabled native setting can prove// that this menu entry opens a confirmation rather than committing.- let deleteConfirmationEnabled = false;- try { const state = doc.querySelector('script#initial-state[type="application/json"]');- if (state && state.textContent.length <= 2500000) deleteConfirmationEnabled = JSON.parse(state.textContent)?.meta?.delete_modal === true;- } catch {}- const kind = proof?.nativeAdapter === 'mastodon' && proof.complete+ const deleteConfirmationEnabled = nativeInitialState()?.meta?.delete_modal === true;+ const nativeProof = proof?.nativeAdapter === 'mastodon' && proof.complete;+ nativeMenuDeletion = nativeProof && menuDelete && !deleteConfirmationEnabled;+ const kind = nativeProof? more && !dangerousCaption ? 'menu' : menuDelete && deleteConfirmationEnabled ? 'confirmation' : '' : '';if (kind) {const popupLauncherToken = rememberPopupLauncher(control, proof, kind);@@ -30328,7 +30407,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d};const nativeDeletionConfirmation = nativeConfirmationCommit(control) && resourceProofFor(control)?.nativeAdapter === 'mastodon';if (control && ['click', 'click_ax', 'iframe_click'].includes(toolName) && !navigationOwnsActivation- && (deletionReading(actionReading) || nativeDeletionConfirmation)+ && (deletionReading(actionReading) || nativeDeletionConfirmation || nativeMenuDeletion)&& isVisible(control) && !control.disabled && control.getAttribute('aria-disabled') !== 'true') {const info = submitInfo(control.form || control.closest('form'), 'resource deletion activation', null, null, 'strong', control);const actionResource = resourceProofFor(target);diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.jsindex 2146e20dc..026d8a081 100644--- a/src/firefox/src/agent/agent.js+++ b/src/firefox/src/agent/agent.js@@ -26608,8 +26608,12 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dconst modal = candidate?.closest?.('.modal-root__modal.safety-action-modal');if (!modal || !isRenderedNative(candidate) || !isRenderedNative(modal)|| candidate.disabled || candidate.getAttribute('aria-disabled') === 'true') return false;- if (!doc.querySelector('form.compose-form textarea.autosuggest-textarea__textarea')- || !doc.querySelector('.navigation-bar a.account__display-name[href],.navigation-panel a.account__display-name[href]')) return false;+ // The signed-in web app, in any layout: the navigation's account link,+ // or the app's own state naming the signed-in account. Mastodon shows+ // no composer beside the timeline in windows narrower than 1175 px.+ const me = nativeInitialState()?.meta?.me;+ if (!doc.querySelector('.navigation-bar a.account__display-name[href],.navigation-panel a.account__display-name[href]')+ && !(typeof me === 'string' && me)) return false;const modals = [...doc.querySelectorAll('.modal-root__modal.safety-action-modal')].filter(isRenderedNative);const primary = [...modal.querySelectorAll('.safety-action-modal__actions > button.button')].filter(isRenderedNative);return modals.length === 1 && primary.length === 1 && primary[0] === candidate;@@ -26909,6 +26913,75 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d}return true;};+ // While one of Mastodon's modals is open, its ModalRoot marks every+ // sibling of .modal-root inert: the page behind stays rendered, only out+ // of reach. A delete confirmation's post and the signed-in account are+ // there, so the reads that identify them look through that mark (and the+ // pointer-events an inert polyfill adds), and through nothing else. The+ // probe runs synchronously, so the page cannot change while it caches this.+ let nativeModalBackgroundSet = null;+ const nativeModalBackgrounds = () => {+ if (nativeModalBackgroundSet) return nativeModalBackgroundSet;+ nativeModalBackgroundSet = new Set();+ try {+ for (const root of doc.querySelectorAll('.modal-root')) {+ const open = [...root.querySelectorAll('.modal-root__modal')].some(modal => {+ const rect = modal.getBoundingClientRect();+ return rect.width > 0 && rect.height > 0;+ });+ if (!open) continue;+ for (const sibling of root.parentElement?.children || []) {+ if (sibling !== root && sibling.matches('[inert],[aria-hidden="true"]')) nativeModalBackgroundSet.add(sibling);+ }+ }+ } catch {}+ return nativeModalBackgroundSet;+ };+ const nativeIdentityVisible = element => {+ const backgrounds = nativeModalBackgrounds();+ let behind = false;+ for (let node = element; node && backgrounds.size && !behind; node = node.parentElement) behind = backgrounds.has(node);+ if (!behind) return nativeResourceVisible(element);+ try {+ const rect = element.getBoundingClientRect();+ if (!element.isConnected || !(rect.width > 0 && rect.height > 0)) return false;+ for (let node = element; node; node = node.parentElement) {+ const style = getComputedStyle(node);+ if (node.matches('[hidden]') || (node.matches('[inert],[aria-hidden="true"]') && !backgrounds.has(node))+ || style.display === 'none' || ['hidden', 'collapse'].includes(style.visibility)+ || Number.parseFloat(style.opacity) === 0 || style.contentVisibility === 'hidden') return false;+ }+ return true;+ } catch { return false; }+ };+ // A Mastodon account as its profile address on this server.+ const nativeAccountIdentity = href => {+ try { const parsed = new URL(href, url); return parsed.origin === location.origin && !parsed.search && !parsed.hash+ && /^\/@[a-z0-9_]+\/?$/i.test(parsed.pathname) ? `${parsed.origin}${parsed.pathname.replace(/\/$/, '').toLowerCase()}` : ''; }+ catch { return ''; }+ };+ let nativeInitialStateValue;+ const nativeInitialState = () => {+ if (nativeInitialStateValue !== undefined) return nativeInitialStateValue;+ nativeInitialStateValue = null;+ try { const state = doc.querySelector('script#initial-state[type="application/json"]');+ if (state && state.textContent.length <= 2500000) nativeInitialStateValue = JSON.parse(state.textContent);+ } catch {}+ return nativeInitialStateValue;+ };+ // The signed-in account: the navigation's account link where the layout+ // shows one (beside the composer on wide windows; in the navigation panel+ // since 4.4), else the app's own initial state, which every layout has.+ // Two that disagree name no account.+ const nativeSignedInAccount = () => {+ const shown = [...new Set([...doc.querySelectorAll('.navigation-bar a.account__display-name[href],.navigation-panel a.account__display-name[href]')]+ .filter(nativeIdentityVisible).map(link => nativeAccountIdentity(link.href)).filter(Boolean))];+ const state = nativeInitialState(), me = state?.meta?.me;+ const account = typeof me === 'string' && me && state.accounts && typeof state.accounts === 'object' ? state.accounts[me] : null;+ const initial = typeof account?.url === 'string' ? nativeAccountIdentity(account.url) : '';+ if (shown.length > 1 || (shown.length && initial && shown[0] !== initial)) return '';+ return shown[0] || initial;+ };// The native record an element belongs to: its own status, or for the// action bar Mastodon renders beside a detailed status (not inside it),// the one detailed status in the same wrapper.@@ -26956,30 +27029,24 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d};const nativeResourceProofs = () => {if (args.__wbNativeResourceAdapter !== 'mastodon') return [];- const identity = href => {- try { const parsed = new URL(href, url); return parsed.origin === location.origin && !parsed.search && !parsed.hash- && /^\/@[a-z0-9_]+\/?$/i.test(parsed.pathname) ? `${parsed.origin}${parsed.pathname.replace(/\/$/, '').toLowerCase()}` : ''; }- catch { return ''; }- };- const accounts = [...new Set([...doc.querySelectorAll('.navigation-bar a.account__display-name[href],.navigation-panel a.account__display-name[href]')]- .filter(nativeResourceVisible).map(link => identity(link.href)).filter(Boolean))];- if (accounts.length !== 1) return [];- const records = [...doc.querySelectorAll('.status,.detailed-status')].filter(nativeResourceVisible);+ const signedIn = nativeSignedInAccount();+ if (!signedIn) return [];+ const records = [...doc.querySelectorAll('.status,.detailed-status')].filter(nativeIdentityVisible);const proofs = [];for (const record of records.slice(0, 80)) {const own = selector => [...record.querySelectorAll(selector)].filter(node => node.closest('.status,.detailed-status') === record);- const links = own('a.status__relative-time[href],a.detailed-status__datetime[href]').filter(nativeResourceVisible);- const authors = own('a.status__display-name[href],a.detailed-status__display-name[href]').filter(nativeResourceVisible);- const contents = own('.status__content__text--visible').filter(nativeResourceVisible);+ const links = own('a.status__relative-time[href],a.detailed-status__datetime[href]').filter(nativeIdentityVisible);+ const authors = own('a.status__display-name[href],a.detailed-status__display-name[href]').filter(nativeIdentityVisible);+ const contents = own('.status__content__text--visible').filter(nativeIdentityVisible);if (links.length !== 1 || authors.length !== 1 || contents.length !== 1|| record.querySelector('textarea,[contenteditable="true"]')) continue;let permalink; try { permalink = new URL(links[0].href); } catch { continue; }const handle = permalink.pathname.match(/^\/@([a-z0-9_]+)\/\d+\/?$/i)?.[1];- const account = identity(authors[0].href);+ const account = nativeAccountIdentity(authors[0].href);if (!handle || permalink.origin !== location.origin || permalink.search || permalink.hash- || account !== `${permalink.origin}/@${handle.toLowerCase()}` || account !== accounts[0]) continue;+ || account !== `${permalink.origin}/@${handle.toLowerCase()}` || account !== signedIn) continue;const nodes = [record, ...record.querySelectorAll('*')];- const textValues = [...new Set(nodes.slice(0, 400).filter(nativeResourceVisible).flatMap(node => [node.innerText, node.textContent])+ const textValues = [...new Set(nodes.slice(0, 400).filter(nativeIdentityVisible).flatMap(node => [node.innerText, node.textContent]).filter(value => typeof value === 'string' && value.length <= 25000))];proofs.push({ url: permalink.href, account, nativeAdapter: 'mastodon',taskKey: args.__wbResourceTaskKey, runToken: args.__wbResourceRunToken,@@ -26988,7 +27055,12 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d}return proofs;};+ // The probe runs synchronously, so the page's records cannot change while+ // it does: they are identified once per run, not again for every question+ // the probe asks about them.+ let resourceProofsOfRun = null;const resourceProofs = () => {+ if (resourceProofsOfRun) return [...resourceProofsOfRun];const known = new Set(publicationResourceUrls().urls);const records = [...doc.querySelectorAll('article,[role="article"],[role="listitem"],[itemid]')].filter(isVisible);const results = [];@@ -27011,8 +27083,9 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d// Native evidence is authoritative for a native record, including its// active account fence; a generic wrapper cannot bypass that fence.const native = nativeResourceProofs();- return args.__wbNativeResourceAdapter === 'mastodon'+ resourceProofsOfRun = args.__wbNativeResourceAdapter === 'mastodon'? results.filter(proof => !proof._record.matches('.status,.detailed-status')).concat(native) : results;+ return [...resourceProofsOfRun];};const resourceProofFor = target => {const records = resourceProofs();@@ -27284,6 +27357,9 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d&& String(link.getAttribute('role') || '').toLowerCase() !== 'button'&& !destructiveLinkQuery(link);})();+ // A dangerous entry of the signed-in account's own post menu that+ // deletes at once (Mastodon's confirmation preference is off).+ let nativeMenuDeletion = false;if (control && ['click', 'click_ax', 'iframe_click'].includes(toolName)&& nativeResourceVisible(control) && !control.disabled && control.getAttribute('aria-disabled') !== 'true'&& !control.form && !control.closest('form')) {@@ -27291,19 +27367,22 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dconst more = control.closest('.status__action-bar,.detailed-status__action-bar')&& control.querySelector('svg.icon-ellipsis-h');// The "…" button opens the post's menu: a caption read as a commit or- // a deletion would be another control. The menu's dangerous item read- // as deleting the post opens Mastodon's own confirmation.+ // a deletion would be another control.const dangerousCaption = commitReading(actionReading) || deletionReading(actionReading);- const menuDelete = control.matches('.dropdown-menu__item--dangerous > button[data-index]')- && actionReading === 'delete_one';+ // Mastodon marks a post menu's destructive entries dangerous. On a post+ // of the signed-in account, the only kind with a native proof, those+ // are Delete and Delete & re-draft: deletions of that post by page+ // structure, whether or not a model has read their captions yet. The+ // entries are buttons since 4.4, and links drawn as buttons in 4.3.+ const menuDelete = control.matches('.dropdown-menu__item--dangerous > button[data-index],'+ + '.dropdown-menu__item--dangerous > a[role="button"][data-index]') && !!control.closest('.dropdown-menu');// Mastodon supports direct deletion when its confirmation preference// is disabled. Only its explicit enabled native setting can prove// that this menu entry opens a confirmation rather than committing.- let deleteConfirmationEnabled = false;- try { const state = doc.querySelector('script#initial-state[type="application/json"]');- if (state && state.textContent.length <= 2500000) deleteConfirmationEnabled = JSON.parse(state.textContent)?.meta?.delete_modal === true;- } catch {}- const kind = proof?.nativeAdapter === 'mastodon' && proof.complete+ const deleteConfirmationEnabled = nativeInitialState()?.meta?.delete_modal === true;+ const nativeProof = proof?.nativeAdapter === 'mastodon' && proof.complete;+ nativeMenuDeletion = nativeProof && menuDelete && !deleteConfirmationEnabled;+ const kind = nativeProof? more && !dangerousCaption ? 'menu' : menuDelete && deleteConfirmationEnabled ? 'confirmation' : '' : '';if (kind) {const popupLauncherToken = rememberPopupLauncher(control, proof, kind);@@ -27634,7 +27713,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d};const nativeDeletionConfirmation = nativeConfirmationCommit(control) && resourceProofFor(control)?.nativeAdapter === 'mastodon';if (control && ['click', 'click_ax', 'iframe_click'].includes(toolName) && !navigationOwnsActivation- && (deletionReading(actionReading) || nativeDeletionConfirmation)+ && (deletionReading(actionReading) || nativeDeletionConfirmation || nativeMenuDeletion)&& isVisible(control) && !control.disabled && control.getAttribute('aria-disabled') !== 'true') {const info = submitInfo(control.form || control.closest('form'), 'resource deletion activation', null, null, 'strong', control);const actionResource = resourceProofFor(target);diff --git a/test/native-mastodon-confirmation.mjs b/test/native-mastodon-confirmation.mjsnew file mode 100644index 000000000..bffe9d0c9--- /dev/null+++ b/test/native-mastodon-confirmation.mjs@@ -0,0 +1,308 @@+import assert from 'node:assert/strict';+import { test } from 'node:test';+import { chromium, firefox } from 'playwright';+import { fixtureControlEffectReading, installModelStub, probeWithReadings } from './semantic-decision-stub.mjs';++// Mastodon 4.4 to 4.7 as a trace showed it, in a 1126 px wide tab beside+// WebBrain's panel. Mastodon renders its composer beside the timeline only from+// 1175 px, so there is none here; the signed-in account is in the navigation+// panel (since 4.4); a post's menu mounts at the end of the body, and its+// dangerous entries are Delete and Delete & re-draft; the delete confirmation+// opens a moment after the click, and while it is open ModalRoot marks every+// sibling of .modal-root inert. In the trace WebBrain opened the post's menu,+// chose Sil, and the confirmation that click opened was refused as "not inside+// one identifiable record".+const origin = 'https://mastoturk.org';+const own = id => `${origin}/@ownedqa/${id}`;+const status = (id, text, account = 'ownedqa') => `<article data-id="${id}"><div class="status__wrapper status__wrapper-public focusable" tabindex="0" aria-label="QA ${account}, ${text}, 15 Eki 21:01, ${account}">+<div class="status status-public" id="record-${id}"><div class="status__info"><a href="/@${account}/${id}" class="status__relative-time"><time>9m</time></a>+<a href="/@${account}" title="${account}" class="status__display-name"><span class="display-name"><bdi><strong class="display-name__html">QA ${account}</strong></bdi> <span class="display-name__account">@${account}</span></span></a></div>+<div class="status__content"><div class="status__content__text status__content__text--visible translate" lang="tr"><p>${text}</p></div></div>+<div class="status__action-bar"><div class="status__action-bar__button-wrapper"><button type="button" aria-label="Yanıtla" title="Yanıtla" class="status__action-bar__button icon-button"><svg class="icon icon-reply"></svg></button></div>+<div class="status__action-bar__button-wrapper"><button type="button" aria-label="Daha fazla" aria-expanded="false" title="Daha fazla" id="more-${id}" class="status__action-bar__button icon-button"><svg class="icon icon-ellipsis-h"></svg></button></div></div>+</div></div></article>`;+const accountBar = '<div class="navigation-bar"><div class="account account--minimal"><div class="account__wrapper"><div class="account__info-wrapper"><a class="account__display-name" title="ownedqa" href="/@ownedqa"><span class="display-name"><bdi><strong class="display-name__html">QA</strong></bdi> <span class="display-name__account">@ownedqa</span></span></a></div></div></div></div>';+const navigation = withAccount => `<div class="columns-area__panels__pane columns-area__panels__pane--start columns-area__panels__pane--navigational"><div class="columns-area__panels__pane__inner"><div class="navigation-panel">+<div class="navigation-panel__logo"><a href="/" class="column-link column-link--logo">Mastodon</a></div><form class="search"><input type="text" class="search__input" placeholder="Ara veya bağlantıyı yapıştır"></form>+${withAccount ? accountBar : ''}<div class="navigation-panel__menu"><a class="button navigation-panel__compose-button column-link" href="/publish">Yeni Gönderi</a><a class="column-link" href="/home">Anasayfa</a></div></div></div></div>`;+const composer = '<div class="columns-area__panels__pane columns-area__panels__pane--compositional"><div class="compose-panel"><form class="compose-form"><textarea class="autosuggest-textarea__textarea" placeholder="Aklında ne var?"></textarea></form></div></div>';+const menu = `<div id="menu-X" style="position:absolute;left:600px;top:120px;z-index:5;background:#fff"><div class="dropdown-animation dropdown-menu bottom"><div class="dropdown-menu__arrow bottom"></div><div class="dropdown-menu__container"><ul class="dropdown-menu__container__list">+<li class="dropdown-menu__item"><button data-index="0">Bu gönderiyi genişlet</button></li><li class="dropdown-menu__item"><button data-index="1">Gönderi bağlantısını kopyala</button></li>+<li class="dropdown-menu__separator"></li><li class="dropdown-menu__item"><button data-index="3" id="menu-edit">Düzenle</button></li>+<li class="dropdown-menu__item dropdown-menu__item--dangerous"><button data-index="4" id="menu-delete">Sil</button></li>+<li class="dropdown-menu__item dropdown-menu__item--dangerous"><button data-index="5" id="menu-redraft">Sil, Düzenle ve yeniden-paylaş</button></li></ul></div></div></div>`;+// Mastodon 4.4 and 4.5 render the confirmation as a div; 4.6 and later as a+// form whose confirm button submits it.+const confirmation = shell => {+ const body = '<div class="safety-action-modal__top"><div class="safety-action-modal__confirmation"><h1>Gönderiyi sil?</h1><p>Bu gönderiyi silmek istediğinden emin misin?</p></div></div>';+ return '<div style="pointer-events:auto"><div role="presentation" class="modal-root__overlay"></div><div role="dialog" class="modal-root__container">'+ + (shell === 'form'+ ? `<form class="modal-root__modal safety-action-modal">${body}<div class="safety-action-modal__bottom"><div class="safety-action-modal__actions"><button type="button" class="link-button" id="cancel">İptal</button><button type="submit" class="button" id="confirm">Sil</button></div></div></form>`+ : `<div class="modal-root__modal safety-action-modal">${body}<div class="safety-action-modal__bottom"><div class="safety-action-modal__actions"><button class="link-button" id="cancel">İptal</button><button type="button" class="button" id="confirm">Sil</button></div></div></div>`)+ + '</div></div>';+};+const page = ({ layout = 'narrow', shell = 'classic', deleteModal = true, signedIn = 'ownedqa', entries = 'buttons' } = {}) => `<!doctype html><meta charset="utf-8">+<style>body{margin:0;font:15px sans-serif}button{padding:8px}.columns-area__panels{display:flex}.columns-area__panels__main{width:600px}.navigation-panel{width:300px}+.modal-root__overlay{position:fixed;inset:0;background:rgba(0,0,0,.4)}.modal-root__container{position:fixed;inset:0;display:flex;align-items:center;justify-content:center}+.safety-action-modal{position:relative;background:#fff;padding:20px}svg{width:12px;height:12px;display:inline-block}</style>+<script id="initial-state" type="application/json">${JSON.stringify({ meta: { me: '1', delete_modal: deleteModal },+ accounts: { 1: { id: '1', username: signedIn, acct: signedIn, url: `${origin}/@${signedIn}` } } })}</script>+<div class="app-holder" id="mastodon"><div class="ui"><div class="columns-area__panels">${layout === 'wide' ? composer : ''}+<div class="columns-area__panels__main"><div class="column" role="region" aria-label="Anasayfa"><div role="feed" class="item-list">+${status('200', 'Test gönderisi / Test post')}${status('201', 'WebBrain test gönderisi')}${status('300', 'Başka birinin gönderisi', 'otherqa')}+</div></div></div>${navigation(layout !== 'hidden-account')}</div><div class="modal-root"></div></div></div>+<script>+window.qaDeletes = []; window.qaModal = ${JSON.stringify(confirmation(shell))};+window.qaMenu = ${JSON.stringify(entries === 'links' ? menu.replace(/<button data-index="(\d+)"( id="[^"]+")?>([^<]*)<\/button>/g, '<a href="#" role="button" tabindex="0" data-index="$1"$2>$3</a>') : menu)};+const ui = document.querySelector('.ui'), modalRoot = document.querySelector('.modal-root');+// ModalRoot: every sibling of .modal-root is inert while a modal is open.+const background = inert => { for (const sibling of ui.children) if (sibling !== modalRoot) inert ? sibling.setAttribute('inert', '') : sibling.removeAttribute('inert'); };+window.qaCloseModal = () => { modalRoot.innerHTML = ''; background(false); };+window.qaOpenModal = onConfirm => {+ modalRoot.innerHTML = qaModal; background(true);+ document.querySelector('#confirm').onclick = event => { event.preventDefault(); onConfirm(); qaCloseModal(); };+ document.querySelector('#cancel').onclick = event => { event.preventDefault(); qaCloseModal(); };+};+for (const id of ['200', '201', '300']) {+ const more = document.querySelector('#more-' + id);+ more.onclick = () => {+ if (document.querySelector('[id^="menu-2"],[id^="menu-3"]')) return;+ more.setAttribute('aria-expanded', 'true'); more.setAttribute('aria-controls', 'menu-' + id);+ more.querySelector('svg').setAttribute('class', 'icon icon-close');+ document.body.insertAdjacentHTML('beforeend', qaMenu.replace('menu-X', 'menu-' + id));+ const close = () => { document.querySelector('#menu-' + id)?.remove(); more.setAttribute('aria-expanded', 'false');+ more.querySelector('svg').setAttribute('class', 'icon icon-ellipsis-h'); };+ for (const item of document.querySelectorAll('#menu-' + id + ' [data-index]')) item.onclick = event => {+ event.preventDefault(); close();+ if (!item.closest('.dropdown-menu__item--dangerous')) return;+ // The confirmation's code loads a moment after the click.+ if (${deleteModal}) setTimeout(() => qaOpenModal(() => qaDeletes.push(id)), 60);+ else qaDeletes.push(id);+ };+ };+}+</script>`;++for (const [build, engine] of [['chrome', chromium], ['firefox', firefox]]) {+ const { Agent } = await import(`../src/${build}/src/agent/agent.js`);+ test(`${build}: a Mastodon delete confirmation opened by WebBrain's own click keeps its post`, async t => {+ const browser = await engine.launch({ headless: true });+ try {+ async function fixture(options = {}) {+ const tab = await browser.newPage({ viewport: { width: 1126, height: 745 } });+ await tab.route('**/*', route => route.fulfill({ contentType: 'text/html', body: page(options) }));+ await tab.goto(`${origin}/home`);+ let scope = null;+ const runProbe = (tool, args) => tab.evaluate(({ source, tool, args }) => (0, eval)(`(${source})`)(tool, args),+ { source: Agent._submitActionProbe.toString(), tool, args });+ // A caption reading of null is a caption no model has read yet.+ const probe = (selector, read = fixtureControlEffectReading, overrides = {}) => probeWithReadings(runProbe, 'click', { selector,+ __wbNativeResourceAdapter: 'mastodon', __wbResourceRunToken: 'owned-run', __wbResourceTaskKey: 'owned-task',+ ...(scope ? { __wbOwnedResourceScope: scope } : {}), ...overrides }, read);+ // As the agent carries a delivered, non-submitting click's resource+ // to its next probe.+ const adopt = result => {+ if (result?.actionResource?.complete && result.isSubmit !== true) scope = { ...result.actionResource,+ document: result.frameDocumentIdentity, taskKey: 'owned-task', popupLauncherToken: result.popupLauncherToken || '',+ launcherDispatched: true };+ };+ // Playwright's click is trusted input; the trace's menu click was a+ // synthetic one.+ const click = async (selector, synthetic = false) => {+ if (synthetic) await tab.evaluate(selector => document.querySelector(selector).click(), selector);+ else await tab.click(selector);+ await tab.waitForTimeout(250);+ };+ const deletes = () => tab.evaluate(() => window.qaDeletes);+ return { tab, probe, adopt, click, deletes, get scope() { return scope; } };+ }+ const unread = () => null;++ await t.test('the trace: Sil in the menu not read yet, the confirmation it opens keeps the post', async () => {+ const f = await fixture();+ try {+ const more = await f.probe('#more-200');+ assert.equal(more.actionResource?.url, own('200')); assert.ok(more.popupLauncherToken);+ f.adopt(more); await f.click('#more-200');+ const item = await f.probe('#menu-delete', unread);+ assert.equal(item.isSubmit, false); assert.equal(item.resolvedPreparatoryTarget, true);+ assert.equal(item.mutationKind, 'delete', "Mastodon's dangerous entry of the user's own post deletes it");+ assert.equal(item.actionResource?.url, own('200')); assert.ok(item.popupLauncherToken);+ f.adopt(item); await f.click('#menu-delete', true);+ assert.deepEqual(await f.deletes(), [], 'The menu entry only opens the confirmation');+ const confirm = await f.probe('#confirm');+ assert.equal(confirm.mutationKind, 'delete'); assert.equal(confirm.semanticCommit, true);+ assert.equal(confirm.actionResource?.url, own('200'), 'The confirmation belongs to the post whose menu opened it');++ // The deletion guard then decides on that post, instead of refusing+ // the confirmation as unbound.+ const provider = { chat() {} }, agent = new Agent({ getActive: () => provider });+ agent.conversations.set(1, [{ role: 'system', content: 'system' }, { role: 'user', content: `Delete ${own('200')}.` }]);+ agent._startPlanExecutionGuard(1, 'act', { requestKind: 'execute', requiresStateChange: true, requiresSubmission: true });+ agent._detectLikelySubmitAction = async () => structuredClone(confirm);+ installModelStub(agent);+ assert.equal(await agent._resourceMutationPreSubmitBlock(1, 'click', { selector: '#confirm' }, confirm, provider), null);+ await f.click('#confirm');+ assert.deepEqual(await f.deletes(), ['200']);+ } finally { await f.tab.close(); }+ });++ for (const layout of ['narrow', 'wide']) await t.test(`${layout} window: the page made inert behind the confirmation still holds the post`, async () => {+ const f = await fixture({ layout });+ try {+ const more = await f.probe('#more-200'); f.adopt(more); await f.click('#more-200');+ const item = await f.probe('#menu-delete'); f.adopt(item); await f.click('#menu-delete');+ assert.equal(await f.tab.evaluate(() => document.querySelector('.columns-area__panels').inert), true);+ const confirm = await f.probe('#confirm');+ assert.equal(confirm.mutationKind, 'delete'); assert.equal(confirm.semanticCommit, true);+ assert.equal(confirm.actionResource?.url, own('200'));+ assert.equal(confirm.actionResource?.account, `${origin}/@ownedqa`);+ } finally { await f.tab.close(); }+ });++ // Where a browser lacks native inert, Mastodon's polyfill also stops+ // pointer events on the page behind the dialog.+ await t.test("an inert polyfill's pointer-events behind the confirmation hide nothing", async () => {+ const f = await fixture();+ try {+ await f.tab.addStyleTag({ content: '[inert]{pointer-events:none;cursor:default}' });+ const more = await f.probe('#more-200'); f.adopt(more); await f.click('#more-200');+ const item = await f.probe('#menu-delete'); f.adopt(item); await f.click('#menu-delete');+ assert.equal(await f.tab.evaluate(() => getComputedStyle(document.querySelector('#record-200')).pointerEvents), 'none');+ assert.equal((await f.probe('#confirm')).actionResource?.url, own('200'));+ } finally { await f.tab.close(); }+ });++ await t.test('no caption read at all: page structure alone binds and classifies the confirmation', async () => {+ const f = await fixture();+ try {+ const more = await f.probe('#more-200', unread); f.adopt(more); await f.click('#more-200');+ const item = await f.probe('#menu-delete', unread); f.adopt(item); await f.click('#menu-delete');+ const confirm = await f.probe('#confirm', unread);+ assert.equal(confirm.mutationKind, 'delete', "Mastodon's own confirm button is a deletion without any reading");+ assert.equal(confirm.semanticCommit, true); assert.equal(confirm.actionResource?.url, own('200'));+ } finally { await f.tab.close(); }+ });++ await t.test('Mastodon 4.6 and later: the confirmation form keeps the post', async () => {+ const f = await fixture({ shell: 'form' });+ try {+ const more = await f.probe('#more-201'); f.adopt(more); await f.click('#more-201');+ const item = await f.probe('#menu-delete'); f.adopt(item); await f.click('#menu-delete');+ const confirm = await f.probe('#confirm');+ assert.equal(confirm.mutationKind, 'delete'); assert.equal(confirm.actionResource?.url, own('201'));+ await f.click('#confirm');+ assert.deepEqual(await f.deletes(), ['201']);+ } finally { await f.tab.close(); }+ });++ // Mastodon 4.3 draws the menu's entries as links styled as buttons, and+ // below 1175 px shows no account bar at all.+ await t.test('Mastodon 4.3: link entries, no account bar, the confirmation still keeps the post', async () => {+ const f = await fixture({ entries: 'links', layout: 'hidden-account' });+ try {+ const more = await f.probe('#more-200'); f.adopt(more); await f.click('#more-200');+ assert.equal(await f.tab.evaluate(() => document.querySelector('#menu-delete').tagName), 'A');+ const item = await f.probe('#menu-delete', unread);+ assert.equal(item.mutationKind, 'delete'); assert.equal(item.actionResource?.url, own('200')); assert.ok(item.popupLauncherToken);+ f.adopt(item); await f.click('#menu-delete');+ const confirm = await f.probe('#confirm');+ assert.equal(confirm.mutationKind, 'delete'); assert.equal(confirm.actionResource?.url, own('200'));+ } finally { await f.tab.close(); }+ });++ // The probe identifies the page's posts once per run, however many of+ // its questions need them: a timeline of the user's own posts behind+ // the confirmation stays quick.+ await t.test('the posts behind the confirmation are identified once per probe run', async () => {+ const f = await fixture();+ try {+ const more = await f.probe('#more-200'); f.adopt(more); await f.click('#more-200');+ const item = await f.probe('#menu-delete'); f.adopt(item); await f.click('#menu-delete');+ await f.tab.evaluate(() => {+ window.qaRecordScans = 0;+ const scan = Document.prototype.querySelectorAll;+ Document.prototype.querySelectorAll = function (selector) {+ if (selector === '.status,.detailed-status') window.qaRecordScans++;+ return scan.call(this, selector);+ };+ });+ const readings = { Sil: 'delete_one', 'İptal': 'view' };+ const confirm = await f.probe('#confirm', fixtureControlEffectReading, { __wbCaptionPass: 'final', __wbCaptionReadings: readings });+ assert.equal(confirm.actionResource?.url, own('200'));+ assert.equal(await f.tab.evaluate(() => window.qaRecordScans), 1);+ } finally { await f.tab.close(); }+ });++ await t.test("the signed-in account comes from the app's own state where the navigation does not show it", async () => {+ const f = await fixture({ layout: 'hidden-account' });+ try {+ const more = await f.probe('#more-200'); f.adopt(more); await f.click('#more-200');+ assert.equal(more.actionResource?.url, own('200'));+ const item = await f.probe('#menu-delete'); f.adopt(item); await f.click('#menu-delete');+ assert.equal((await f.probe('#confirm')).actionResource?.url, own('200'));+ } finally { await f.tab.close(); }+ // Another signed-in account owns none of these posts, and an+ // initial state that disagrees with the navigation names no account.+ for (const options of [{ layout: 'hidden-account', signedIn: 'otherqa' }, { signedIn: 'otherqa' }]) {+ const other = await fixture(options);+ try { assert.equal((await other.probe('#more-200'))?.actionResource ?? null, null, JSON.stringify(options)); }+ finally { await other.tab.close(); }+ }+ });++ await t.test("another account's post binds nothing", async () => {+ const f = await fixture();+ try { assert.equal((await f.probe('#more-300'))?.actionResource ?? null, null); } finally { await f.tab.close(); }+ });++ await t.test('an inert page with no Mastodon dialog open still hides its posts', async () => {+ const f = await fixture();+ try {+ await f.tab.evaluate(() => document.querySelector('.columns-area__panels').setAttribute('inert', ''));+ assert.equal((await f.probe('#more-200'))?.actionResource ?? null, null);+ // A closed modal root does not excuse its inert siblings either.+ await f.tab.evaluate(() => { document.querySelector('.modal-root').innerHTML = '<div></div>'; });+ assert.equal((await f.probe('#more-200'))?.actionResource ?? null, null);+ } finally { await f.tab.close(); }+ });++ await t.test('a confirmation the click did not open borrows nothing', async () => {+ const f = await fixture();+ try {+ const more = await f.probe('#more-200'); f.adopt(more); await f.click('#more-200');+ const item = await f.probe('#menu-delete', unread); f.adopt(item);+ // Not clicked: the page opens the same confirmation by itself.+ await f.tab.evaluate(() => { document.querySelector('[id^="menu-"]').remove(); qaOpenModal(() => qaDeletes.push('script')); });+ await f.tab.waitForTimeout(250);+ assert.equal((await f.probe('#confirm'))?.actionResource ?? null, null);+ } finally { await f.tab.close(); }+ });++ await t.test('an ordinary menu entry is no deletion and lends its post to no confirmation', async () => {+ const f = await fixture();+ try {+ const more = await f.probe('#more-200'); f.adopt(more); await f.click('#more-200');+ const edit = await f.probe('#menu-edit', unread);+ assert.notEqual(edit?.mutationKind, 'delete'); assert.ok(!edit?.popupLauncherToken);+ f.adopt(edit); await f.click('#menu-edit');+ await f.tab.evaluate(() => qaOpenModal(() => qaDeletes.push('script')));+ await f.tab.waitForTimeout(250);+ assert.equal((await f.probe('#confirm'))?.actionResource ?? null, null);+ } finally { await f.tab.close(); }+ });++ // With Mastodon's confirmation preference off, its dangerous entry+ // deletes at once: it is checked as the deletion itself, read or not.+ await t.test('confirmation preference off: the dangerous entry is the deletion before any reading', async () => {+ const f = await fixture({ deleteModal: false });+ try {+ const more = await f.probe('#more-200'); f.adopt(more); await f.click('#more-200');+ const item = await f.probe('#menu-delete', unread);+ assert.equal(item.isSubmit, true); assert.equal(item.mutationKind, 'delete');+ assert.equal(item.actionResource?.url, own('200')); assert.equal(item.resolvedPreparatoryTarget, undefined);+ } finally { await f.tab.close(); }+ });+ } finally { await browser.close(); }+ });+}diff --git a/test/quality/mastodon-delete-confirmation-mv3.mjs b/test/quality/mastodon-delete-confirmation-mv3.mjsnew file mode 100644index 000000000..8ef43b060--- /dev/null+++ b/test/quality/mastodon-delete-confirmation-mv3.mjs@@ -0,0 +1,285 @@+import assert from 'node:assert/strict';+import fs from 'node:fs/promises';+import http from 'node:http';+import os from 'node:os';+import path from 'node:path';+import { chromium } from 'playwright';+import { conformFixtureCompletionCall } from './completion-provider-contract.mjs';+import { fixedChoiceQuestion, fixtureControlEffectReading, fixtureFixedChoiceReply, fixturePageTextReply } from '../semantic-decision-stub.mjs';++// A trace: on Mastodon's home timeline, in a 1126 px wide tab beside+// WebBrain's panel, WebBrain opened its own post's "Daha fazla" menu and chose+// "Sil"; the confirmation that click opened was refused as "not inside one+// identifiable record". No model had read "Sil" when the menu entry was+// clicked, and Mastodon marks the page behind its confirmation inert. The page+// follows Mastodon 4.4/4.5 markup at that width: no composer beside the+// timeline, the signed-in account in the navigation panel, the menu mounted at+// the end of the body, the confirmation loaded a moment after the click, and+// ModalRoot marking every sibling of .modal-root inert while it is open. The+// extension, provider pipeline, dispatch and gates are real; the page and the+// model are owned local fixtures.+// By default the menu caption has no reading when its entry is clicked, as in+// the trace; --menu-read has every caption read, which leaves only the inert+// page behind the confirmation. --vague asks only "delete it", as the trace+// did: WebBrain asks once on its own card whether to delete this post, and+// that answer also covers Mastodon's confirmation.+const menuReading = process.argv.includes('--menu-read') ? 'read' : process.env.WEBBRAIN_QUALITY_MASTODON_MENU_READING || 'unread';+assert.ok(['unread', 'read'].includes(menuReading));+const vague = process.argv.includes('--vague');+const variant = `${menuReading}${vague ? '-vague' : ''}`;+const out = path.resolve(process.env.WEBBRAIN_QUALITY_ARTIFACTS+ || `ci/artifacts/quality-audit-2026-10-15/mastodon-delete-confirmation-mv3/${variant}`);+await fs.mkdir(out, { recursive: true });+const account = 'webbrain_qa_owned', postId = '117446231630065843', otherId = '117442625347497184';+const resource = `https://mastoturk.org/@${account}/${postId}`, pageUrl = 'https://mastoturk.org/home';+const named = `Delete only our owned QA test post at "${resource}" with body "Owned QA test post". Deleting this one disposable post is explicitly authorized. Do not delete or publish anything else. Verify it is removed.`;+const task = vague ? 'delete it' : named;+const intent = { request_kind: 'execute', scope_relation: 'new', requires_state_change: true,+ requires_submission: true, messaging: null, deliverables: ['The owned QA test post is deleted and verified.'],+ allows_planner_shaped_result: false, allows_app_state_tool_evidence: false,+ completion_requirements: { download: false }, read_scope: 'visible_page',+ summary: 'Delete and verify only the owned QA test post.',+ steps: [{ id: '1', action: 'Open the post menu, choose Sil, confirm, and verify the post is gone.' }],+ memory: { use_progress_ledger: false, progress_action: null }, scheduling: null, risks: [] };+let deleted = false, actionCalls = 0, judgeCalls = 0, blockedRemote = 0, menuCaptionAsked = 0;+const completionRecovery = { reads: 0 };+const deletes = [], providerRequests = [], judgeEvidence = [];+const textOf = content => typeof content === 'string' ? content : Array.isArray(content)+ ? content.filter(part => part?.type === 'text').map(part => part.text || '').join('\n') : '';+const refFor = (input, name) => {+ for (const message of [...input.messages].reverse()) {+ if (message.role !== 'tool') continue;+ let data; try { data = JSON.parse(textOf(message.content)); } catch {+ const content = textOf(message.content), start = content.indexOf('{');+ try { data = JSON.parse(content.slice(start, content.lastIndexOf('}') + 1)); } catch { continue; }+ }+ const line = String(data.pageContent || '').split('\n').find(line => line.includes(`button "${name}"`));+ const ref = line?.match(/\[(ref_\d+)\]/)?.[1];+ if (ref) return ref;+ }+ const last = [...input.messages].reverse().find(message => message.role === "tool");+ throw new Error(`Owned fixture did not observe ${name}`);+};+const server = http.createServer(async (request, response) => {+ if (request.url === '/resource') {+ response.writeHead(deleted ? 404 : 200, { 'Content-Type': 'text/html' });+ response.end(deleted ? 'The owned QA post is absent.' : 'Owned QA test post'); return;+ }+ if (request.url !== '/v1/chat/completions') { response.writeHead(404).end(); return; }+ let raw = ''; for await (const part of request) raw += part;+ const input = JSON.parse(raw); providerRequests.push(input);+ await new Promise(resolve => setTimeout(resolve, 60));+ const system = textOf(input.messages?.[0]?.content);+ let completion;+ // What the buttons say, read by the model. In the trace "Sil" had no+ // reading yet when its menu entry was clicked: the first time it is asked,+ // this model gives no answer for it.+ const controlEffect = fixedChoiceQuestion(input.messages)?.kind === 'control_effect'+ ? fixtureFixedChoiceReply(input.messages, { control_effect: ({ item }) => {+ if (item?.text === 'Sil' && ++menuCaptionAsked === 1 && menuReading === 'unread') return null;+ return fixtureControlEffectReading(item?.text);+ } }) : null;+ if (system.startsWith('Evaluate only the observable requirements of the genuine user task')) {+ judgeCalls++; judgeEvidence.push(textOf(input.messages[1]?.content));+ completion = { role: 'assistant', content: JSON.stringify({ outcome: 'succeeded',+ reason: 'The exact resource returns HTTP404 after the owned confirmation and the timeline no longer shows it.' }) };+ } else if (system.startsWith('Identify only the exact plain public Mastodon post authorized by the genuine user task.')) {+ completion = { role: 'assistant', content: JSON.stringify({ kind: 'unsupported', body: null, account: null }) };+ } else if (controlEffect) {+ completion = { role: 'assistant', content: controlEffect };+ } else if (fixturePageTextReply(input.messages)) {+ completion = { role: 'assistant', content: fixturePageTextReply(input.messages) };+ } else if (system.startsWith("Answer one fixed-choice question for a browser agent's safety check.")) {+ // The request names exactly this post by its link.+ const request = JSON.parse(textOf(input.messages[1].content)).request;+ const untrusted = textOf(input.messages.at(-1).content);+ const { page } = JSON.parse(untrusted.slice(untrusted.indexOf('{'), untrusted.lastIndexOf('}') + 1));+ const exact = system.includes('"delete_this"') && request === named && page?.link === resource;+ completion = { role: 'assistant', content: JSON.stringify(exact+ ? { choice: 'delete_this', evidence: `Delete only our owned QA test post at "${resource}"` } : { choice: 'unclear', evidence: '' }) };+ } else if (!input.tools?.length) completion = { role: 'assistant', content: JSON.stringify(intent) };+ else {+ const step = actionCalls++;+ const call = step === 1 ? { name: 'click_ax', args: { ref_id: refFor(input, 'Daha fazla') } }+ : step === 3 ? { name: 'click_ax', args: { ref_id: refFor(input, 'Sil') } }+ : step === 5 ? { name: 'click_ax', args: { ref_id: refFor(input, 'Sil') } }+ : step === 6 ? { name: 'fetch_url', args: { url: resource } }+ : step === 7 ? { name: 'read_page', args: { limit: 2000 } }+ : step > 7 ? { name: 'done', args: { outcome: 'success', summary: 'The owned QA test post was deleted once and verified absent.' } }+ : { name: 'get_accessibility_tree', args: { filter: 'all' } };+ const emitted = conformFixtureCompletionCall(input, call, completionRecovery);+ completion = { role: 'assistant', content: '', tool_calls: [{ id: `owned-confirmation-${step}`, type: 'function',+ function: { name: emitted.name, arguments: JSON.stringify(emitted.args) } }] };+ }+ response.writeHead(200, { 'Content-Type': 'application/json' });+ response.end(JSON.stringify({ id: `response-${providerRequests.length}`, choices: [{ message: completion,+ finish_reason: completion.tool_calls ? 'tool_calls' : 'stop' }], usage: { prompt_tokens: 100, completion_tokens: 30 } }));+});+await new Promise(resolve => server.listen(0, '127.0.0.1', resolve));++const post = (id, text, author = account) => `<article data-id="${id}"><div class="status__wrapper status__wrapper-public focusable" tabindex="0" aria-label="QA, ${text}, 15 Eki 21:01, ${author}">+<div class="status status-public"><div class="status__info"><a href="/@${author}/${id}" class="status__relative-time"><time>9m</time></a>+<a href="/@${author}" title="${author}" class="status__display-name"><span class="display-name"><bdi><strong class="display-name__html">QA</strong></bdi> <span class="display-name__account">@${author}</span></span></a></div>+<div class="status__content"><div class="status__content__text status__content__text--visible translate" lang="tr"><p>${text}</p></div></div>+<div class="status__action-bar"><div class="status__action-bar__button-wrapper"><button type="button" aria-label="Yanıtla" title="Yanıtla" class="status__action-bar__button icon-button"><svg class="icon icon-reply" aria-hidden="true"></svg></button></div>+<div class="status__action-bar__button-wrapper"><button type="button" aria-label="Daha fazla" aria-expanded="false" title="Daha fazla" class="status__action-bar__button icon-button"><svg class="icon icon-ellipsis-h" aria-hidden="true"></svg></button></div></div></div></div></article>`;+const menu = '<div class="dropdown-animation dropdown-menu bottom"><div class="dropdown-menu__arrow bottom"></div><div class="dropdown-menu__container"><ul class="dropdown-menu__container__list">'+ + '<li class="dropdown-menu__item"><button data-index="0">Bu gönderiyi genişlet</button></li><li class="dropdown-menu__item"><button data-index="1">Gönderi bağlantısını kopyala</button></li>'+ + '<li class="dropdown-menu__separator"></li><li class="dropdown-menu__item"><button data-index="3">Düzenle</button></li>'+ + '<li class="dropdown-menu__item dropdown-menu__item--dangerous"><button data-index="4">Sil</button></li>'+ + '<li class="dropdown-menu__item dropdown-menu__item--dangerous"><button data-index="5">Sil, Düzenle ve yeniden-paylaş</button></li></ul></div></div>';+const confirmation = '<div style="pointer-events:auto"><div role="presentation" class="modal-root__overlay"></div><div role="dialog" class="modal-root__container">'+ + '<div class="modal-root__modal safety-action-modal"><div class="safety-action-modal__top"><div class="safety-action-modal__confirmation"><h1>Gönderiyi sil?</h1><p>Bu gönderiyi silmek istediğinden emin misin?</p></div></div>'+ + '<div class="safety-action-modal__bottom"><div class="safety-action-modal__actions"><button class="link-button">İptal</button><button type="button" class="button">Sil</button></div></div></div></div></div>';+const pageBody = `<!doctype html><meta charset="utf-8"><title>Anasayfa - MastoTurk</title>+<script id="initial-state" type="application/json">${JSON.stringify({ meta: { me: '1', delete_modal: true },+ accounts: { 1: { id: '1', username: account, acct: account, url: `https://mastoturk.org/@${account}` } } })}</script>+<style>body{margin:0;font:15px sans-serif}button{padding:8px}.columns-area__panels{display:flex}.columns-area__panels__main{width:600px}.navigation-panel{width:300px;padding:8px}+.modal-root__overlay{position:fixed;inset:0;background:rgba(0,0,0,.4)}.modal-root__container{position:fixed;inset:0;display:flex;align-items:center;justify-content:center}+.safety-action-modal{position:relative;background:#fff;padding:20px}.dropdown-menu{background:#fff;border:1px solid #888}svg{width:12px;height:12px;display:inline-block}</style>+<div class="app-holder" id="mastodon"><div class="ui"><div class="columns-area__panels"><div class="columns-area__panels__main"><div class="column" role="region" aria-label="Anasayfa"><div role="feed" class="item-list" id="feed">+${post(postId, 'Owned QA test post')}${post(otherId, 'Another owned QA post')}${post('117439945096942320', 'Someone else', 'otherqa')}+</div></div></div><div class="columns-area__panels__pane columns-area__panels__pane--start columns-area__panels__pane--navigational"><div class="columns-area__panels__pane__inner"><div class="navigation-panel">+<form class="search"><input type="text" class="search__input" placeholder="Ara veya bağlantıyı yapıştır"></form>+<div class="navigation-bar"><div class="account account--minimal"><div class="account__wrapper"><div class="account__info-wrapper"><a class="account__display-name" title="${account}" href="/@${account}"><span class="display-name__account">@${account}</span></a></div></div></div></div>+<div class="navigation-panel__menu"><a class="button navigation-panel__compose-button column-link" href="/publish">Yeni Gönderi</a><a class="column-link" href="/home">Anasayfa</a></div></div></div></div>+</div><div class="modal-root"></div></div></div>+<script>+const ui = document.querySelector('.ui'), modalRoot = document.querySelector('.modal-root');+const background = inert => { for (const sibling of ui.children) if (sibling !== modalRoot) inert ? sibling.setAttribute('inert', '') : sibling.removeAttribute('inert'); };+const closeModal = () => { modalRoot.replaceChildren(); background(false); };+for (const more of document.querySelectorAll('.status__action-bar button[aria-label="Daha fazla"]')) more.onclick = () => {+ if (document.querySelector('#post-menu')) return;+ const id = more.closest('article').dataset.id, holder = document.createElement('div');+ holder.id = 'post-menu'; holder.style.cssText = 'position:absolute;left:560px;top:' + (more.getBoundingClientRect().bottom + 4) + 'px;z-index:5';+ holder.innerHTML = ${JSON.stringify(menu)};+ more.setAttribute('aria-expanded', 'true'); more.setAttribute('aria-controls', 'post-menu');+ more.querySelector('svg').setAttribute('class', 'icon icon-close');+ document.body.append(holder);+ const closeMenu = () => { holder.remove(); more.setAttribute('aria-expanded', 'false'); more.querySelector('svg').setAttribute('class', 'icon icon-ellipsis-h'); };+ for (const item of holder.querySelectorAll('button[data-index]')) item.onclick = () => {+ closeMenu();+ if (item.dataset.index !== '4') return;+ // The confirmation's code loads a moment after the click.+ setTimeout(() => {+ modalRoot.innerHTML = ${JSON.stringify(confirmation)}; background(true);+ modalRoot.querySelector('.link-button').onclick = closeModal;+ modalRoot.querySelector('.button').onclick = async () => {+ const result = await fetch('/api/v1/statuses/' + id, { method: 'DELETE' });+ if (result.ok) { document.querySelector('article[data-id="' + id + '"]').remove(); closeModal(); }+ };+ }, 60);+ };+};+</script>`;++const profile = await fs.mkdtemp(path.join(os.tmpdir(), 'webbrain-mastodon-confirm-mv3-'));+let context;+try {+ const extension = path.join(profile, 'extension'); await fs.cp(path.resolve('src/chrome'), extension, { recursive: true });+ await fs.appendFile(path.join(extension, 'src/background.js'), `+globalThis.confirmationFixtureAgent = agent;+globalThis.confirmationFixtureReceipts = [];+const recordOwnedConfirmationReceipt = agent._recordCompletionSubmitAttempt;+agent._recordCompletionSubmitAttempt = function (...args) {+ const receipt = recordOwnedConfirmationReceipt.apply(this, args);+ if (receipt) confirmationFixtureReceipts.push({ taskKey: receipt.taskKey, runToken: receipt.runToken,+ mutationKind: receipt.mutationKind, resourceUrl: receipt.actionResource?.url });+ return receipt;+};+`);+ context = await chromium.launchPersistentContext(profile, { headless: true, channel: 'chromium',+ viewport: { width: 1126, height: 745 },+ args: [`--disable-extensions-except=${extension}`, `--load-extension=${extension}`,+ '--host-resolver-rules=MAP * ~NOTFOUND, EXCLUDE 127.0.0.1'] });+ await context.route('**/*', async route => {+ const request = route.request(), requested = new URL(request.url());+ if (requested.hostname === '127.0.0.1' && requested.port === String(server.address().port)) return route.continue();+ if (requested.origin === 'https://mastoturk.org') {+ const status = requested.pathname.match(/^\/api\/v1\/statuses\/(\d+)$/)?.[1];+ if (status && request.method() === 'DELETE') {+ deletes.push(status); if (status === postId) deleted = true;+ return route.fulfill({ status: 200, contentType: 'application/json', body: '{}' });+ }+ if (request.isNavigationRequest() && requested.href === pageUrl) return route.fulfill({ contentType: 'text/html', body: pageBody });+ return route.fulfill({ status: 404, body: '' });+ }+ if (/^https?:$/.test(requested.protocol)) { blockedRemote++; return route.abort('blockedbyclient'); }+ return route.continue();+ });+ const worker = context.serviceWorkers()[0] || await context.waitForEvent('serviceworker', { timeout: 30_000 });+ await worker.evaluate(({ resource, bridge }) => {+ const send = fetch.bind(globalThis);+ globalThis.fetch = (input, options) => {+ const requested = new URL(typeof input === 'string' ? input : input.url);+ if (requested.href === resource && (!options?.method || options.method === 'GET')) {+ // A local mapping of the owned origin, not a redirect.+ return send(bridge, options).then(response => Object.defineProperty(response, 'url', { value: requested.href }));+ }+ if (requested.hostname === '127.0.0.1' || ['chrome-extension:', 'data:', 'blob:'].includes(requested.protocol)) return send(input, options);+ return Promise.reject(new Error('Owned confirmation fixture blocks external network requests.'));+ };+ }, { resource, bridge: `http://127.0.0.1:${server.address().port}/resource` });+ 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, tracingEnabled: false,+ autoScreenshot: false, screenshotFallback: false, planBeforeActMode: 'off', planBeforeAct: false,+ planReviewMode: 'never', maxAgentSteps: 14, systemOneEnabled: false, agentAllowLocalNetwork: true,+ askBeforeConsequentialActions: false, openaiAskStreamingEnabled: false }));+ assert.equal((await message('update_provider', { providerId: 'openrouter', config: { apiKey: 'owned-fixture-fake-key',+ baseUrl: `http://127.0.0.1:${server.address().port}/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(pageUrl);+ const tabId = await harness.evaluate(async url => (await chrome.tabs.query({})).find(tab => tab.url === url)?.id, pageUrl);+ // WebBrain's deletion card is answered "Delete"; any other question would be+ // unexpected here.+ const cards = [], unexpected = [];+ let answering = true;+ const answerer = (async () => {+ const answered = new Set();+ while (answering) {+ const pending = await worker.evaluate(tabId => [...(confirmationFixtureAgent._pendingClarifications.get(tabId)?.keys() || [])], tabId);+ for (const clarifyId of pending) {+ if (answered.has(clarifyId)) continue;+ answered.add(clarifyId);+ if (!clarifyId.startsWith('deletion_')) { unexpected.push(clarifyId); continue; }+ cards.push(clarifyId);+ assert.equal((await message('clarify_response', { tabId, clarifyId, answer: 'once', source: 'option' })).ok, true);+ }+ await new Promise(resolve => setTimeout(resolve, 100));+ }+ })();+ const result = await message('chat', { tabId, text: task, mode: 'act', requestId: 'owned-mastodon-confirmation', locale: 'en' });+ answering = false; await answerer;+ const prompts = result.updates.filter(event => event.type === 'clarify' && event.data?.promptKind === 'mutationConfirmation')+ .map(event => event.data.mutationConfirmation);+ const diagnostic = await worker.evaluate(tabId => ({ submit: confirmationFixtureAgent._completionSubmitStates.get(tabId),+ receipts: confirmationFixtureReceipts, currentTaskKey: confirmationFixtureAgent._progressTaskKeyHash(tabId) }), tabId);+ const blocked = result.updates.filter(event => event.type === 'tool_result' && event.data?.result?.actionGuard)+ .map(event => ({ tool: event.data.name, reason: event.data.result.actionGuard.reason }));+ await fs.writeFile(path.join(out, 'evidence.json'), JSON.stringify({ result, diagnostic, deletes, blocked, cards, prompts, unexpected, judgeCalls,+ judgeEvidence, menuCaptionAsked, blockedRemote }, (_key, value) => typeof value === 'string' && value.startsWith('data:image/')+ ? '[owned fixture screenshot omitted]' : value, 2));+ assert.deepEqual(unexpected, [], 'No other question was asked');+ assert.deepEqual(blocked, [], `No step of the deletion was refused: ${JSON.stringify(blocked)}`);+ // A vague request is put to the user once, about this post; the answer+ // holds for Mastodon's own confirmation too. A request naming the post asks+ // nothing.+ assert.equal(cards.length, vague ? 1 : 0, JSON.stringify(prompts));+ if (vague) assert.equal(prompts[0]?.url, resource, JSON.stringify(prompts));+ assert.deepEqual(deletes, [postId], 'The confirmation deleted exactly the post whose menu opened it, once.');+ if (menuReading === 'unread') assert.ok(menuCaptionAsked >= 2, 'The menu caption had no reading when its entry was clicked.');+ assert.deepEqual(diagnostic.receipts, [{ taskKey: diagnostic.currentTaskKey, runToken: diagnostic.submit.runToken,+ mutationKind: 'delete', resourceUrl: resource }], 'One deletion receipt, bound to the post; the menu entry made none.');+ const done = result.updates.findLast(event => event.type === 'tool_result' && event.data?.name === 'done')?.data?.result;+ assert.equal(done?.done, true, JSON.stringify(done)); assert.equal(done?.outcome, 'success', JSON.stringify(done));+ assert.ok(judgeEvidence.some(text => /404/.test(text)), 'The post being gone reaches the completion check.');+ console.log(JSON.stringify({ passed: true, installedMV3: true, menuReading, vague, deletes, receipts: diagnostic.receipts.length,+ blocked: blocked.length, cards: cards.length, judgeCalls, blockedRemote }));+} finally {+ await context?.close(); await new Promise(resolve => server.close(resolve));+ const resolved = path.resolve(profile);+ if (!resolved.startsWith(path.resolve(os.tmpdir()) + path.sep + 'webbrain-mastodon-confirm-mv3-')) throw new Error('Unexpected temporary profile path.');+ await fs.rm(resolved, { recursive: true, force: true });+}