Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust
Rust ai-agentsai-toolsbrowserbrowser-automationcloud-browserheadlessheadless-browserkitesurfplaywrightpuppeteerrustservoweb-crawlerweb-crawlingweb-scraperweb-scraping
test(webmcp): port pinned Chromium compatibility coverage
ldm045a34211e72e
diff --git a/moli-core/tests/wpt_compat.rs b/moli-core/tests/wpt_compat.rsindex 69ee0c783..524f11eb1 100644--- a/moli-core/tests/wpt_compat.rs+++ b/moli-core/tests/wpt_compat.rs@@ -42,7 +42,78 @@ wpt_explicit_default_excluded_cases! {}wpt_compat_cases! {+ wpt_compat_case_chromium_webmcp_model_context => "chromium-webmcp-model-context",+ wpt_compat_case_chromium_webmcp_duplicate_tool_registration => "chromium-webmcp-duplicate-tool-registration",+ wpt_compat_case_chromium_webmcp_register_tool_name_validation => "chromium-webmcp-register-tool-name-validation",+ wpt_compat_case_chromium_webmcp_register_tool_no_schema => "chromium-webmcp-register-tool-no-schema",+ wpt_compat_case_chromium_webmcp_register_tool_with_schema => "chromium-webmcp-register-tool-with-schema",+ wpt_compat_case_chromium_webmcp_register_tool_invalid_json_schema => "chromium-webmcp-register-tool-invalid-json-schema",+ wpt_compat_case_chromium_webmcp_register_tool_with_empty_annotation => "chromium-webmcp-register-tool-with-empty-annotation",+ wpt_compat_case_chromium_webmcp_get_tools => "chromium-webmcp-get-tools",+ wpt_compat_case_chromium_webmcp_get_tools_imperative_annotations => "chromium-webmcp-get-tools-imperative-annotations",+ wpt_compat_case_chromium_webmcp_get_tools_imperative_schema => "chromium-webmcp-get-tools-imperative-schema",+ wpt_compat_case_chromium_webmcp_register_tool_title => "chromium-webmcp-register-tool-title",+ wpt_compat_case_chromium_webmcp_register_tool_signal => "chromium-webmcp-register-tool-signal",+ wpt_compat_case_chromium_webmcp_register_tool_toolchange => "chromium-webmcp-register-tool-toolchange",+ wpt_compat_case_chromium_webmcp_object_arguments => "chromium-webmcp-object-arguments",+ wpt_compat_case_chromium_webmcp_execute_tool_abort => "chromium-webmcp-execute-tool-abort",+ wpt_compat_case_chromium_webmcp_tool_activated_event => "chromium-webmcp-tool-activated-event",+ wpt_compat_case_chromium_webmcp_tool_cancel_event => "chromium-webmcp-tool-cancel-event",+ wpt_compat_case_chromium_webmcp_get_tools_declarative_schema => "chromium-webmcp-get-tools-declarative-schema",+ wpt_compat_case_chromium_webmcp_declarative_duplicate_tool_name => "chromium-webmcp-declarative-duplicate-tool-name",+ wpt_compat_case_chromium_webmcp_declarative_toolchange_on_attribute_mutation => "chromium-webmcp-declarative-toolchange-on-attribute-mutation",+ wpt_compat_case_chromium_webmcp_declarative_toolchange_on_control_add_remove => "chromium-webmcp-declarative-toolchange-on-control-add-remove",+ wpt_compat_case_chromium_webmcp_declarative_toolchange_on_name_change => "chromium-webmcp-declarative-toolchange-on-name-change",+ wpt_compat_case_chromium_webmcp_declarative_no_frame_documents => "chromium-webmcp-declarative-no-frame-documents",+ wpt_compat_case_chromium_webmcp_declarative_respond_with_reject => "chromium-webmcp-declarative-respond-with-reject",+ wpt_compat_case_chromium_webmcp_declarative_respond_with_circular_object => "chromium-webmcp-declarative-respond-with-circular-object",+ wpt_compat_case_chromium_webmcp_declarative_invalid_input => "chromium-webmcp-declarative-invalid-input",wpt_compat_case_eventtarget_basic => "eventtarget-basic",+ wpt_compat_case_chromium_webmcp_declarative_execute_tool_abort => "chromium-webmcp-declarative-execute-tool-abort",+ wpt_compat_case_chromium_webmcp_declarative_execute_tool_flexible_types => "chromium-webmcp-declarative-execute-tool-flexible-types",+ wpt_compat_case_chromium_webmcp_declarative_execute_tool_no_autosubmit => "chromium-webmcp-declarative-execute-tool-no-autosubmit",+ wpt_compat_case_chromium_webmcp_declarative_execute_tool_pseudo_classes => "chromium-webmcp-declarative-execute-tool-pseudo-classes",+ wpt_compat_case_chromium_webmcp_declarative_execute_tool_respond_with => "chromium-webmcp-declarative-execute-tool-respond-with",+ wpt_compat_case_chromium_webmcp_declarative_execute_tool_change_event => "chromium-webmcp-declarative-execute-tool-change-event",+ wpt_compat_case_chromium_webmcp_declarative_execute_tool_submit_from_js => "chromium-webmcp-declarative-execute-tool-submit-from-js",+ wpt_compat_case_chromium_webmcp_declarative_form_removal_submit_crash => "chromium-webmcp-declarative-form-removal-submit-crash",+ wpt_compat_case_chromium_webmcp_declarative_select_multiple_events => "chromium-webmcp-declarative-select-multiple-events",+ wpt_compat_case_chromium_webmcp_declarative_unregister_during_execute_tool => "chromium-webmcp-declarative-unregister-during-execute-tool",+ wpt_compat_case_chromium_webmcp_declarative_execute_tool_navigation => "chromium-webmcp-declarative-execute-tool-navigation",+ wpt_compat_case_chromium_webmcp_declarative_execute_tool_detach_toolactivated => "chromium-webmcp-declarative-execute-tool-detach-toolactivated",+ wpt_compat_case_chromium_webmcp_declarative_opaque_origin_tools => "chromium-webmcp-declarative-opaque-origin-tools",+ wpt_compat_case_chromium_webmcp_declarative_sandboxed_iframe => "chromium-webmcp-declarative-sandboxed-iframe",+ wpt_compat_case_chromium_webmcp_imperative_cancel_reentrancy_crash => "chromium-webmcp-imperative-cancel-reentrancy-crash",+ wpt_compat_case_chromium_webmcp_imperative_detached_frame_execute_tool => "chromium-webmcp-imperative-detached-frame-execute-tool",+ wpt_compat_case_chromium_webmcp_imperative_detached_frame_get_tools => "chromium-webmcp-imperative-detached-frame-get-tools",+ wpt_compat_case_chromium_webmcp_imperative_detached_frame_model_context => "chromium-webmcp-imperative-detached-frame-model-context",+ wpt_compat_case_chromium_webmcp_imperative_detached_frame_register_tool => "chromium-webmcp-imperative-detached-frame-register-tool",+ wpt_compat_case_chromium_webmcp_imperative_execute_tool_across_trees => "chromium-webmcp-imperative-execute-tool-across-trees",+ wpt_compat_case_chromium_webmcp_imperative_execute_tool_caller_navigate_abort => "chromium-webmcp-imperative-execute-tool-caller-navigate-abort",+ wpt_compat_case_chromium_webmcp_imperative_execute_tool_detach_toolactivated => "chromium-webmcp-imperative-execute-tool-detach-toolactivated",+ wpt_compat_case_chromium_webmcp_imperative_execute_tool_detach_toolcancel => "chromium-webmcp-imperative-execute-tool-detach-toolcancel",+ wpt_compat_case_chromium_webmcp_imperative_execute_tool_error_window_onerror => "chromium-webmcp-imperative-execute-tool-error-window-onerror",+ wpt_compat_case_chromium_webmcp_imperative_execute_tool_events => "chromium-webmcp-imperative-execute-tool-events",+ wpt_compat_case_chromium_webmcp_imperative_execute_tool_invalid_dictionary => "chromium-webmcp-imperative-execute-tool-invalid-dictionary",+ wpt_compat_case_chromium_webmcp_imperative_execute_tool_same_document_navigation_crash => "chromium-webmcp-imperative-execute-tool-same-document-navigation-crash",+ wpt_compat_case_chromium_webmcp_imperative_execute_tool_signal_cross_origin => "chromium-webmcp-imperative-execute-tool-signal-cross-origin",+ wpt_compat_case_chromium_webmcp_imperative_execute_tool_target_detachment => "chromium-webmcp-imperative-execute-tool-target-detachment",+ wpt_compat_case_chromium_webmcp_imperative_execute_tool_target_navigation => "chromium-webmcp-imperative-execute-tool-target-navigation",+ wpt_compat_case_chromium_webmcp_imperative_execute_tool_unauthorized_origin => "chromium-webmcp-imperative-execute-tool-unauthorized-origin",+ wpt_compat_case_chromium_webmcp_imperative_execute_tool_unregister_resolution_race => "chromium-webmcp-imperative-execute-tool-unregister-resolution-race",+ wpt_compat_case_chromium_webmcp_imperative_exposed_to_cross_origin_child => "chromium-webmcp-imperative-exposed-to-cross-origin-child",+ wpt_compat_case_chromium_webmcp_imperative_exposed_to_defaults_cross_origin => "chromium-webmcp-imperative-exposed-to-defaults-cross-origin",+ wpt_compat_case_chromium_webmcp_imperative_exposed_to_defaults_same_origin => "chromium-webmcp-imperative-exposed-to-defaults-same-origin",+ wpt_compat_case_chromium_webmcp_imperative_exposed_to_invalid_origins => "chromium-webmcp-imperative-exposed-to-invalid-origins",+ wpt_compat_case_chromium_webmcp_imperative_exposed_to_multiple_children => "chromium-webmcp-imperative-exposed-to-multiple-children",+ wpt_compat_case_chromium_webmcp_imperative_exposed_to_window_open => "chromium-webmcp-imperative-exposed-to-window-open",+ wpt_compat_case_chromium_webmcp_imperative_get_tools_filtering => "chromium-webmcp-imperative-get-tools-filtering",+ wpt_compat_case_chromium_webmcp_imperative_initial_about_blank_shared_tool => "chromium-webmcp-imperative-initial-about-blank-shared-tool",+ wpt_compat_case_chromium_webmcp_imperative_non_secure => "chromium-webmcp-imperative-non-secure",+ wpt_compat_case_chromium_webmcp_imperative_opaque_origin_tools => "chromium-webmcp-imperative-opaque-origin-tools",+ wpt_compat_case_chromium_webmcp_imperative_permissions_policy => "chromium-webmcp-imperative-permissions-policy",+ wpt_compat_case_chromium_webmcp_imperative_same_origin_iframe_register_tool_regression => "chromium-webmcp-imperative-same-origin-iframe-register-tool-regression",+ wpt_compat_case_chromium_webmcp_imperative_unregister_during_execute_tool => "chromium-webmcp-imperative-unregister-during-execute-tool",wpt_compat_case_event_internal_dispatch_regression_basic => "event-internal-dispatch-regression-basic",wpt_compat_case_urlsearchparams_basic => "urlsearchparams-basic",wpt_compat_case_url_basic => "url-basic",diff --git a/moli-wpt-compat/fixtures/wpt/expected.toml b/moli-wpt-compat/fixtures/wpt/expected.tomlindex a689a8ffa..45831d96d 100644--- a/moli-wpt-compat/fixtures/wpt/expected.toml+++ b/moli-wpt-compat/fixtures/wpt/expected.toml@@ -1746,3 +1746,216 @@ status = "pass"[expectations.testharness-no-handler-crashtest]status = "pass"++[expectations.chromium-webmcp-model-context]+status = "pass"++[expectations.chromium-webmcp-duplicate-tool-registration]+status = "pass"++[expectations.chromium-webmcp-register-tool-name-validation]+status = "pass"++[expectations.chromium-webmcp-register-tool-no-schema]+status = "pass"++[expectations.chromium-webmcp-register-tool-with-schema]+status = "pass"++[expectations.chromium-webmcp-register-tool-invalid-json-schema]+status = "pass"++[expectations.chromium-webmcp-register-tool-with-empty-annotation]+status = "pass"++[expectations.chromium-webmcp-get-tools]+status = "pass"++[expectations.chromium-webmcp-get-tools-imperative-annotations]+status = "pass"++[expectations.chromium-webmcp-get-tools-imperative-schema]+status = "pass"++[expectations.chromium-webmcp-register-tool-title]+status = "pass"++[expectations.chromium-webmcp-register-tool-signal]+status = "pass"++[expectations.chromium-webmcp-register-tool-toolchange]+status = "pass"++[expectations.chromium-webmcp-object-arguments]+status = "pass"++[expectations.chromium-webmcp-execute-tool-abort]+status = "pass"++[expectations.chromium-webmcp-tool-activated-event]+status = "pass"++[expectations.chromium-webmcp-tool-cancel-event]+status = "pass"++[expectations.chromium-webmcp-get-tools-declarative-schema]+status = "pass"++[expectations.chromium-webmcp-declarative-duplicate-tool-name]+status = "pass"++[expectations.chromium-webmcp-declarative-toolchange-on-attribute-mutation]+status = "pass"++[expectations.chromium-webmcp-declarative-toolchange-on-control-add-remove]+status = "pass"++[expectations.chromium-webmcp-declarative-toolchange-on-name-change]+status = "pass"++[expectations.chromium-webmcp-declarative-no-frame-documents]+status = "pass"++[expectations.chromium-webmcp-declarative-respond-with-reject]+status = "pass"++[expectations.chromium-webmcp-declarative-respond-with-circular-object]+status = "pass"++[expectations.chromium-webmcp-declarative-invalid-input]+status = "pass"++[expectations.chromium-webmcp-declarative-execute-tool-abort]+status = "pass"++[expectations.chromium-webmcp-declarative-execute-tool-flexible-types]+status = "pass"++[expectations.chromium-webmcp-declarative-execute-tool-no-autosubmit]+status = "pass"++[expectations.chromium-webmcp-declarative-execute-tool-pseudo-classes]+status = "pass"++[expectations.chromium-webmcp-declarative-execute-tool-respond-with]+status = "pass"++[expectations.chromium-webmcp-declarative-execute-tool-change-event]+status = "pass"++[expectations.chromium-webmcp-declarative-execute-tool-submit-from-js]+status = "pass"++[expectations.chromium-webmcp-declarative-form-removal-submit-crash]+status = "pass"++[expectations.chromium-webmcp-declarative-select-multiple-events]+status = "pass"++[expectations.chromium-webmcp-declarative-unregister-during-execute-tool]+status = "pass"++[expectations.chromium-webmcp-declarative-execute-tool-navigation]+status = "pass"++[expectations.chromium-webmcp-declarative-execute-tool-detach-toolactivated]+status = "pass"++[expectations.chromium-webmcp-declarative-opaque-origin-tools]+status = "pass"++[expectations.chromium-webmcp-declarative-sandboxed-iframe]+status = "pass"++[expectations.chromium-webmcp-imperative-cancel-reentrancy-crash]+status = "pass"++[expectations.chromium-webmcp-imperative-detached-frame-execute-tool]+status = "pass"++[expectations.chromium-webmcp-imperative-detached-frame-get-tools]+status = "pass"++[expectations.chromium-webmcp-imperative-detached-frame-model-context]+status = "pass"++[expectations.chromium-webmcp-imperative-detached-frame-register-tool]+status = "pass"++[expectations.chromium-webmcp-imperative-execute-tool-across-trees]+status = "pass"++[expectations.chromium-webmcp-imperative-execute-tool-caller-navigate-abort]+status = "pass"++[expectations.chromium-webmcp-imperative-execute-tool-detach-toolactivated]+status = "pass"++[expectations.chromium-webmcp-imperative-execute-tool-detach-toolcancel]+status = "pass"++[expectations.chromium-webmcp-imperative-execute-tool-error-window-onerror]+status = "pass"++[expectations.chromium-webmcp-imperative-execute-tool-events]+status = "pass"++[expectations.chromium-webmcp-imperative-execute-tool-invalid-dictionary]+status = "pass"++[expectations.chromium-webmcp-imperative-execute-tool-same-document-navigation-crash]+status = "pass"++[expectations.chromium-webmcp-imperative-execute-tool-signal-cross-origin]+status = "pass"++[expectations.chromium-webmcp-imperative-execute-tool-target-detachment]+status = "pass"++[expectations.chromium-webmcp-imperative-execute-tool-target-navigation]+status = "pass"++[expectations.chromium-webmcp-imperative-execute-tool-unauthorized-origin]+status = "pass"++[expectations.chromium-webmcp-imperative-execute-tool-unregister-resolution-race]+status = "pass"++[expectations.chromium-webmcp-imperative-exposed-to-cross-origin-child]+status = "pass"++[expectations.chromium-webmcp-imperative-exposed-to-defaults-cross-origin]+status = "pass"++[expectations.chromium-webmcp-imperative-exposed-to-defaults-same-origin]+status = "pass"++[expectations.chromium-webmcp-imperative-exposed-to-invalid-origins]+status = "pass"++[expectations.chromium-webmcp-imperative-exposed-to-multiple-children]+status = "pass"++[expectations.chromium-webmcp-imperative-exposed-to-window-open]+status = "pass"++[expectations.chromium-webmcp-imperative-get-tools-filtering]+status = "pass"++[expectations.chromium-webmcp-imperative-initial-about-blank-shared-tool]+status = "pass"++[expectations.chromium-webmcp-imperative-non-secure]+status = "pass"++[expectations.chromium-webmcp-imperative-opaque-origin-tools]+status = "pass"++[expectations.chromium-webmcp-imperative-permissions-policy]+status = "pass"++[expectations.chromium-webmcp-imperative-same-origin-iframe-register-tool-regression]+status = "pass"++[expectations.chromium-webmcp-imperative-unregister-during-execute-tool]+status = "pass"diff --git a/moli-wpt-compat/fixtures/wpt/manifest.toml b/moli-wpt-compat/fixtures/wpt/manifest.tomlindex 73448177b..e5671bf1e 100644--- a/moli-wpt-compat/fixtures/wpt/manifest.toml+++ b/moli-wpt-compat/fixtures/wpt/manifest.toml@@ -20675,3 +20675,1211 @@ timeout_ms = 5000suite = "broad"tags = ["testharness", "crashtest"]notes = "Exercise HTTPS fixture selection and load-driven crash reporting independently of browser features."++[[test]]+id = "chromium-webmcp-model-context"+upstream = "web-platform-tests/webmcp/imperative/model_context.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/model_context.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/model_context.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-duplicate-tool-registration"+upstream = "web-platform-tests/webmcp/imperative/duplicate_tool_registration.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/duplicate_tool_registration.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/duplicate_tool_registration.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-register-tool-name-validation"+upstream = "web-platform-tests/webmcp/imperative/register_tool_name_validation.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/register_tool_name_validation.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/register_tool_name_validation.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-register-tool-no-schema"+upstream = "web-platform-tests/webmcp/imperative/register_tool_no_schema.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/register_tool_no_schema.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/register_tool_no_schema.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-register-tool-with-schema"+upstream = "web-platform-tests/webmcp/imperative/register_tool_with_schema.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/register_tool_with_schema.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/register_tool_with_schema.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-register-tool-invalid-json-schema"+upstream = "web-platform-tests/webmcp/imperative/register_tool_invalid_json_schema.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/register_tool_invalid_json_schema.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/register_tool_invalid_json_schema.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-register-tool-with-empty-annotation"+upstream = "web-platform-tests/webmcp/imperative/register_tool_with_empty_annotation.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/register_tool_with_empty_annotation.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/register_tool_with_empty_annotation.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-get-tools"+upstream = "web-platform-tests/webmcp/imperative/getTools.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/getTools.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/getTools.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-get-tools-imperative-annotations"+upstream = "web-platform-tests/webmcp/imperative/getTools-imperative-annotations.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/getTools-imperative-annotations.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/getTools-imperative-annotations.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-get-tools-imperative-schema"+upstream = "web-platform-tests/webmcp/imperative/getTools-imperative-schema.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/getTools-imperative-schema.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/getTools-imperative-schema.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-register-tool-title"+upstream = "web-platform-tests/webmcp/imperative/register-tool-title.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/register-tool-title.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/register-tool-title.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-register-tool-signal"+upstream = "web-platform-tests/webmcp/imperative/register_tool_signal.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/register_tool_signal.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/register_tool_signal.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-register-tool-toolchange"+upstream = "web-platform-tests/webmcp/imperative/register_tool_toolchange.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/register_tool_toolchange.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/register_tool_toolchange.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-object-arguments"+upstream = "web-platform-tests/webmcp/imperative/object-arguments.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/object-arguments.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/object-arguments.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-execute-tool-abort"+upstream = "web-platform-tests/webmcp/imperative/executeTool-abort.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/executeTool-abort.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/executeTool-abort.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-tool-activated-event"+upstream = "web-platform-tests/webmcp/tool-activated-event.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/tool-activated-event.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/tool-activated-event.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-tool-cancel-event"+upstream = "web-platform-tests/webmcp/tool-cancel-event.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/tool-cancel-event.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/tool-cancel-event.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-get-tools-declarative-schema"+upstream = "web-platform-tests/webmcp/declarative/getTools-declarative-schema.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/declarative/getTools-declarative-schema.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/declarative/getTools-declarative-schema.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "declarative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-declarative-duplicate-tool-name"+upstream = "web-platform-tests/webmcp/declarative/duplicate-tool-name.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/declarative/duplicate-tool-name.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/declarative/duplicate-tool-name.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "declarative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-declarative-toolchange-on-attribute-mutation"+upstream = "web-platform-tests/webmcp/declarative/toolchange-on-attribute-mutation.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/declarative/toolchange-on-attribute-mutation.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/declarative/toolchange-on-attribute-mutation.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "declarative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-declarative-toolchange-on-control-add-remove"+upstream = "web-platform-tests/webmcp/declarative/toolchange-on-control-add-remove.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/declarative/toolchange-on-control-add-remove.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/declarative/toolchange-on-control-add-remove.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "declarative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-declarative-toolchange-on-name-change"+upstream = "web-platform-tests/webmcp/declarative/toolchange-on-name-change.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/declarative/toolchange-on-name-change.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/declarative/toolchange-on-name-change.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "declarative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-declarative-no-frame-documents"+upstream = "web-platform-tests/webmcp/declarative/no-frame-documents.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/declarative/no-frame-documents.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/declarative/no-frame-documents.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "declarative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-declarative-respond-with-reject"+upstream = "web-platform-tests/webmcp/declarative/executeTool-respondWith-reject.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/declarative/executeTool-respondWith-reject.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/declarative/executeTool-respondWith-reject.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "declarative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-declarative-respond-with-circular-object"+upstream = "web-platform-tests/webmcp/declarative/executeTool-respondWith-circular-object.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/declarative/executeTool-respondWith-circular-object.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/declarative/executeTool-respondWith-circular-object.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "declarative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-declarative-invalid-input"+upstream = "web-platform-tests/webmcp/declarative/executeTool-invalid-input.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/declarative/executeTool-invalid-input.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/declarative/executeTool-invalid-input.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "declarative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-declarative-execute-tool-abort"+upstream = "web-platform-tests/webmcp/declarative/executeTool-abort.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/declarative/executeTool-abort.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/declarative/executeTool-abort.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "declarative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-declarative-execute-tool-flexible-types"+upstream = "web-platform-tests/webmcp/declarative/executeTool-flexible-types.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/declarative/executeTool-flexible-types.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/declarative/executeTool-flexible-types.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "declarative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-declarative-execute-tool-no-autosubmit"+upstream = "web-platform-tests/webmcp/declarative/executeTool-no-autosubmit.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/declarative/executeTool-no-autosubmit.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/declarative/executeTool-no-autosubmit.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "declarative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-declarative-execute-tool-pseudo-classes"+upstream = "web-platform-tests/webmcp/declarative/executeTool-pseudo-classes.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/declarative/executeTool-pseudo-classes.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/declarative/executeTool-pseudo-classes.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "declarative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-declarative-execute-tool-respond-with"+upstream = "web-platform-tests/webmcp/declarative/executeTool-respondWith.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/declarative/executeTool-respondWith.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/declarative/executeTool-respondWith.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "declarative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-declarative-execute-tool-change-event"+upstream = "web-platform-tests/webmcp/declarative/execute_tool_change_event.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/declarative/execute_tool_change_event.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/declarative/execute_tool_change_event.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "declarative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-declarative-execute-tool-submit-from-js"+upstream = "web-platform-tests/webmcp/declarative/execute_tool_submit_from_js.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/declarative/execute_tool_submit_from_js.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/declarative/execute_tool_submit_from_js.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "declarative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-declarative-form-removal-submit-crash"+upstream = "web-platform-tests/webmcp/declarative/form_removal_submit_crash.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/declarative/form_removal_submit_crash.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/declarative/form_removal_submit_crash.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "declarative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-declarative-select-multiple-events"+upstream = "web-platform-tests/webmcp/declarative/select-multiple-events.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/declarative/select-multiple-events.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/declarative/select-multiple-events.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "declarative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-declarative-unregister-during-execute-tool"+upstream = "web-platform-tests/webmcp/declarative/unregister-during-executeTool.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/declarative/unregister-during-executeTool.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/declarative/unregister-during-executeTool.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "declarative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-declarative-execute-tool-navigation"+upstream = "web-platform-tests/webmcp/declarative/executeTool-navigation.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/declarative/executeTool-navigation.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/declarative/executeTool-navigation.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "declarative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-declarative-execute-tool-detach-toolactivated"+upstream = "web-platform-tests/webmcp/declarative/executeTool-detach-toolactivated.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/declarative/executeTool-detach-toolactivated.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/declarative/executeTool-detach-toolactivated.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "declarative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-declarative-opaque-origin-tools"+upstream = "web-platform-tests/webmcp/declarative/opaque-origin-tools.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/declarative/opaque-origin-tools.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/declarative/opaque-origin-tools.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "declarative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-declarative-sandboxed-iframe"+upstream = "web-platform-tests/webmcp/declarative/sandboxed-iframe.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/declarative/sandboxed-iframe.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/declarative/sandboxed-iframe.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "declarative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-imperative-cancel-reentrancy-crash"+upstream = "web-platform-tests/webmcp/imperative/cancel-reentrancy-crash.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/cancel-reentrancy-crash.https.html"+type = "crashtest"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/cancel-reentrancy-crash.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-imperative-detached-frame-execute-tool"+upstream = "web-platform-tests/webmcp/imperative/detached-frame-executeTool.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/detached-frame-executeTool.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/detached-frame-executeTool.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-imperative-detached-frame-get-tools"+upstream = "web-platform-tests/webmcp/imperative/detached-frame-getTools.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/detached-frame-getTools.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/detached-frame-getTools.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-imperative-detached-frame-model-context"+upstream = "web-platform-tests/webmcp/imperative/detached-frame-modelContext.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/detached-frame-modelContext.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/detached-frame-modelContext.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-imperative-detached-frame-register-tool"+upstream = "web-platform-tests/webmcp/imperative/detached-frame-registerTool.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/detached-frame-registerTool.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/detached-frame-registerTool.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-imperative-execute-tool-across-trees"+upstream = "web-platform-tests/webmcp/imperative/executeTool-across-trees.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/executeTool-across-trees.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/executeTool-across-trees.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-imperative-execute-tool-caller-navigate-abort"+upstream = "web-platform-tests/webmcp/imperative/executeTool-caller-navigate-abort.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/executeTool-caller-navigate-abort.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/executeTool-caller-navigate-abort.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-imperative-execute-tool-detach-toolactivated"+upstream = "web-platform-tests/webmcp/imperative/executeTool-detach-toolactivated.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/executeTool-detach-toolactivated.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/executeTool-detach-toolactivated.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-imperative-execute-tool-detach-toolcancel"+upstream = "web-platform-tests/webmcp/imperative/executeTool-detach-toolcancel.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/executeTool-detach-toolcancel.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/executeTool-detach-toolcancel.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-imperative-execute-tool-error-window-onerror"+upstream = "web-platform-tests/webmcp/imperative/executeTool-error-window-onerror.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/executeTool-error-window-onerror.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/executeTool-error-window-onerror.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-imperative-execute-tool-events"+upstream = "web-platform-tests/webmcp/imperative/executeTool-events.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/executeTool-events.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/executeTool-events.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-imperative-execute-tool-invalid-dictionary"+upstream = "web-platform-tests/webmcp/imperative/executeTool-invalid-dictionary.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/executeTool-invalid-dictionary.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/executeTool-invalid-dictionary.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-imperative-execute-tool-same-document-navigation-crash"+upstream = "web-platform-tests/webmcp/imperative/executeTool-same-document-navigation-crash.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/executeTool-same-document-navigation-crash.https.html"+type = "crashtest"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/executeTool-same-document-navigation-crash.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-imperative-execute-tool-signal-cross-origin"+upstream = "web-platform-tests/webmcp/imperative/executeTool-signal-cross-origin.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/executeTool-signal-cross-origin.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/executeTool-signal-cross-origin.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-imperative-execute-tool-target-detachment"+upstream = "web-platform-tests/webmcp/imperative/executeTool-target-detachment.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/executeTool-target-detachment.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/executeTool-target-detachment.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-imperative-execute-tool-target-navigation"+upstream = "web-platform-tests/webmcp/imperative/executeTool-target-navigation.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/executeTool-target-navigation.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/executeTool-target-navigation.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-imperative-execute-tool-unauthorized-origin"+upstream = "web-platform-tests/webmcp/imperative/executeTool-unauthorized-origin.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/executeTool-unauthorized-origin.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/executeTool-unauthorized-origin.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-imperative-execute-tool-unregister-resolution-race"+upstream = "web-platform-tests/webmcp/imperative/executeTool-unregister-resolution-race.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/executeTool-unregister-resolution-race.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/executeTool-unregister-resolution-race.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-imperative-exposed-to-cross-origin-child"+upstream = "web-platform-tests/webmcp/imperative/exposedTo-cross-origin-child.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/exposedTo-cross-origin-child.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 60000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/exposedTo-cross-origin-child.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-imperative-exposed-to-defaults-cross-origin"+upstream = "web-platform-tests/webmcp/imperative/exposedTo-defaults-cross-origin.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/exposedTo-defaults-cross-origin.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 60000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/exposedTo-defaults-cross-origin.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-imperative-exposed-to-defaults-same-origin"+upstream = "web-platform-tests/webmcp/imperative/exposedTo-defaults-same-origin.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/exposedTo-defaults-same-origin.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/exposedTo-defaults-same-origin.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-imperative-exposed-to-invalid-origins"+upstream = "web-platform-tests/webmcp/imperative/exposedTo-invalid-origins.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/exposedTo-invalid-origins.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/exposedTo-invalid-origins.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-imperative-exposed-to-multiple-children"+upstream = "web-platform-tests/webmcp/imperative/exposedTo-multiple-children.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/exposedTo-multiple-children.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 60000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/exposedTo-multiple-children.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-imperative-exposed-to-window-open"+upstream = "web-platform-tests/webmcp/imperative/exposedTo-window-open.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/exposedTo-window-open.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 60000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/exposedTo-window-open.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-imperative-get-tools-filtering"+upstream = "web-platform-tests/webmcp/imperative/getTools-filtering.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/getTools-filtering.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 60000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/getTools-filtering.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-imperative-initial-about-blank-shared-tool"+upstream = "web-platform-tests/webmcp/imperative/initial-about-blank-shared-tool.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/initial-about-blank-shared-tool.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/initial-about-blank-shared-tool.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-imperative-non-secure"+upstream = "web-platform-tests/webmcp/imperative/non-secure.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/non-secure.html"+type = "testharness"+global = "window"+status = "pass"+origin = "insecure"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/non-secure.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-imperative-opaque-origin-tools"+upstream = "web-platform-tests/webmcp/imperative/opaque-origin-tools.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/opaque-origin-tools.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/opaque-origin-tools.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-imperative-permissions-policy"+upstream = "web-platform-tests/webmcp/imperative/permissions-policy.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/permissions-policy.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/permissions-policy.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-imperative-same-origin-iframe-register-tool-regression"+upstream = "web-platform-tests/webmcp/imperative/same-origin-iframe-registerTool-regression.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/same-origin-iframe-registerTool-regression.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/same-origin-iframe-registerTool-regression.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."++[[test]]+id = "chromium-webmcp-imperative-unregister-during-execute-tool"+upstream = "web-platform-tests/webmcp/imperative/unregister-during-executeTool.https.html"+upstream_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+local_path = "upstream/webmcp/imperative/unregister-during-executeTool.https.html"+type = "testharness"+global = "window"+status = "pass"+wait_until = "load"+timeout_ms = 5000+suite = "broad"+source = "chromium-wpt"+source_path = "webmcp/imperative/unregister-during-executeTool.https.html"+source_commit = "2d184faab9fb11e1070fb1eeafebf291f6e85923"+tags = ["webmcp", "chromium", "upstream-wpt", "imperative"]+notes = "Unmodified WPT imported from Chromium third_party/blink/web_tests/external/wpt at the recorded commit."diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/duplicate-tool-name.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/duplicate-tool-name.https.htmlnew file mode 100644index 000000000..dd998c066--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/duplicate-tool-name.https.html@@ -0,0 +1,95 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>WebMCP: Duplicate declarative tool registrations do not crash and only register the first</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<body>+<script>+promise_test(async t => {+ const f1 = document.createElement('form');+ f1.id = 'f1';+ f1.setAttribute('toolname', 'duplicate_tool');+ f1.setAttribute('tooldescription', 'First tool description');++ const f2 = document.createElement('form');+ f2.id = 'f2';+ f2.setAttribute('toolname', 'duplicate_tool');+ f2.setAttribute('tooldescription', 'Second tool description');++ t.add_cleanup(async () => {+ const removalPromise = new Promise(resolve => {+ document.modelContext.ontoolchange = resolve;+ });+ f1.remove();+ f2.remove();+ await removalPromise;+ const remainingTools = await document.modelContext.getTools();+ assert_equals(remainingTools.length, 0, "No tools should remain after form removal");+ document.modelContext.ontoolchange = null;+ });++ const p = new Promise(resolve => {+ document.modelContext.ontoolchange = () => {+ document.modelContext.ontoolchange = t.unreached_func("ontoolchange should not be called a second time for the duplicate form");+ resolve();+ };+ });++ document.body.append(f1);+ document.body.append(f2);++ await p;++ const tools = await document.modelContext.getTools();+ assert_equals(tools.length, 1, "Exactly one tool should be registered");++ const tool = tools[0];+ assert_equals(tool.name, "duplicate_tool", "Tool name matches form attribute");+ assert_equals(tool.description, "First tool description", "Tool description matches the first form");+}, "Test that duplicate declarative tools with different descriptions do not crash and only the first is registered");++promise_test(async t => {+ const f1 = document.createElement('form');+ f1.id = 'f1';+ f1.setAttribute('toolname', 'duplicate_same_desc');+ f1.setAttribute('tooldescription', 'Same tool description');++ const f2 = document.createElement('form');+ f2.id = 'f2';+ f2.setAttribute('toolname', 'duplicate_same_desc');+ f2.setAttribute('tooldescription', 'Same tool description');++ t.add_cleanup(async () => {+ const removalPromise = new Promise(resolve => {+ document.modelContext.ontoolchange = resolve;+ });+ f1.remove();+ f2.remove();+ await removalPromise;+ const remainingTools = await document.modelContext.getTools();+ assert_equals(remainingTools.length, 0, "No tools should remain after form removal");+ document.modelContext.ontoolchange = null;+ });++ const p = new Promise(resolve => {+ document.modelContext.ontoolchange = () => {+ document.modelContext.ontoolchange = t.unreached_func("ontoolchange should not be called a second time for duplicate form with identical description");+ resolve();+ };+ });++ document.body.append(f1);+ document.body.append(f2);++ await p;++ const tools = await document.modelContext.getTools();+ assert_equals(tools.length, 1, "Exactly one tool should be registered");++ const tool = tools[0];+ assert_equals(tool.name, "duplicate_same_desc", "Tool name matches form attribute");+ assert_equals(tool.description, "Same tool description");+}, "Test that duplicate declarative tools with identical descriptions do not crash and only the first is registered");+</script>+</body>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/executeTool-abort.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/executeTool-abort.https.htmlnew file mode 100644index 000000000..3a0e0b72f--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/executeTool-abort.https.html@@ -0,0 +1,105 @@+<!DOCTYPE html>+<meta charset="utf-8">+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script src="/webmcp/resources/helpers.js"></script>++<form id="form1" toolname="submit_test" tooldescription="Submit test form1">+ <button id="button1" type=submit>Submit</button>+</form>+<form id="form2" toolname="submit_test2" tooldescription="Submit test form2">+ <button id="button2" type=submit>Submit</button>+</form>++<script>+promise_test(async t => {+ await waitForTool('submit_test');++ const form1 = document.querySelector('#form1');+ const form2 = document.querySelector('#form2');+ const button1 = document.querySelector('#button1');+ const button2 = document.querySelector('#button2');++ assert_false(form1.matches(':tool-form-active'));+ assert_false(form2.matches(':tool-form-active'));+ assert_false(button1.matches(':tool-submit-active'));+ assert_false(button2.matches(':tool-submit-active'));++ const assertActiveDuringToolactivated = e => {+ assert_equals(e.toolName, 'submit_test');+ assert_true(form1.matches(':tool-form-active'));+ assert_false(form2.matches(':tool-form-active'));+ assert_true(button1.matches(':tool-submit-active'));+ assert_false(button2.matches(':tool-submit-active'));+ };++ const events = [];++ const modelContextEvents = [];+ const modelContextToolActivatedPromise = new Promise(r => {+ const handler = e => {+ modelContextEvents.push(e);+ assertActiveDuringToolactivated(e);+ r();+ };+ document.modelContext.addEventListener('toolactivated', handler);+ t.add_cleanup(() => document.modelContext.removeEventListener('toolactivated', handler));+ });++ const tools = await document.modelContext.getTools();+ const tool = tools.find(t => t.name === 'submit_test');++ const controller = new AbortController();+ const executionPromise = document.modelContext.executeTool(tool, {}, { signal: controller.signal });++ await modelContextToolActivatedPromise;++ assert_equals(modelContextEvents.length, 1);+ const modelContextEvent = modelContextEvents[0];+ assert_true(modelContextEvent instanceof ToolActivatedEvent);+ assert_equals(modelContextEvent.target, document.modelContext);++ const assertInactiveDuringToolcancel = e => {+ assert_equals(e.toolName, 'submit_test');+ assert_false(form1.matches(':tool-form-active'), "form1 matches during toolcancel");+ assert_false(form2.matches(':tool-form-active'), "form2 matches during toolcancel");+ assert_false(button1.matches(':tool-submit-active'), "button1 matches during toolcancel");+ assert_false(button2.matches(':tool-submit-active'), "button2 matches during toolcancel");+ };++ const modelContextCancelEvents = [];+ const modelContextToolCancelPromise = new Promise(r => {+ const handler = e => {+ modelContextCancelEvents.push(e);+ assertInactiveDuringToolcancel(e);+ r();+ };+ document.modelContext.addEventListener('toolcancel', handler);+ t.add_cleanup(() => document.modelContext.removeEventListener('toolcancel', handler));+ });++ controller.abort();+ let executionRejectionValue = null;+ await Promise.all([+ executionPromise.catch(e => {events.push('execution_rejected'); executionRejectionValue = e}),+ modelContextToolCancelPromise.then(() => events.push('toolcancel')),+ ]);++ assert_array_equals(events, ['execution_rejected', 'toolcancel'],+ 'the execution rejects before toolcancel is dispatched');+ assert_array_equals(modelContextEvents, [modelContextEvent], 'toolactivated is dispatched once per execution');++ assert_equals(modelContextCancelEvents.length, 1, 'toolcancel is dispatched once per execution');+ assert_true(modelContextCancelEvents[0] instanceof ToolCancelEvent);+ assert_equals(modelContextCancelEvents[0].target, document.modelContext);++ assert_true(executionRejectionValue instanceof DOMException);+ assert_equals(executionRejectionValue.name, "AbortError");++ assert_false(form1.matches(':tool-form-active'), "form1 matches");+ assert_false(form2.matches(':tool-form-active'), "form2 matches");+ assert_false(button1.matches(':tool-submit-active'), "button1 matches");+ assert_false(button2.matches(':tool-submit-active'), "button2 matches");+}, 'executeTool signal successfully resets tool pseudo-classes');+</script>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/executeTool-detach-toolactivated.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/executeTool-detach-toolactivated.https.htmlnew file mode 100644index 000000000..9b04cb27d--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/executeTool-detach-toolactivated.https.html@@ -0,0 +1,45 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>WebMCP: toolactivated is not dispatched when filling a declarative tool form detaches its document</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script src="/webmcp/resources/helpers.js"></script>++<body>+<script>+promise_test(async t => {+ const iframe = document.createElement('iframe');+ iframe.src = '/common/blank.html';+ const loadPromise = new Promise(resolve => iframe.onload = resolve);+ document.body.appendChild(iframe);+ t.add_cleanup(() => iframe.remove());+ await loadPromise;++ const iframeDocument = iframe.contentDocument;+ const iframeModelContext = iframeDocument.modelContext;++ iframeDocument.body.innerHTML = `+ <form toolname="detaching_form_tool" tooldescription="Form that detaches its document">+ <input name="text" type="text">+ <button type="submit">Submit</button>+ </form>`;+ const tool = await waitForTool('detaching_form_tool');++ // Filling out the form synchronously detaches the document hosting the+ // tool.+ iframeDocument.querySelector('input').addEventListener('input',+ () => iframe.remove(), { once: true });++ const events = [];+ iframeModelContext.addEventListener('toolactivated', e => events.push(e));++ await promise_rejects_dom(t, 'UnknownError',+ document.modelContext.executeTool(tool, { text: 'hello' }));++ assert_false(iframe.isConnected, 'the iframe is detached');+ assert_array_equals(events, [],+ 'toolactivated is not dispatched at the detached document ModelContext');+}, 'toolactivated is not dispatched when filling out a declarative tool form ' ++ 'detaches the tool document');+</script>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/executeTool-flexible-types.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/executeTool-flexible-types.https.htmlnew file mode 100644index 000000000..571115c79--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/executeTool-flexible-types.https.html@@ -0,0 +1,64 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>WebMCP: declarative form tool execution with flexible input argument types</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script src="../resources/helpers.js"></script>++<form toolautosubmit toolname="flexible_tool" tooldescription="Flexible types tool" action="about:blank" target="flex_iframe">+ <input id="text" name="text" type="text">+ <input id="number" name="number" type="number">+ <input id="check1" name="check1" type="checkbox">+ <select id="select" name="select">+ <option value="1">One</option>+ <option value="2">Two</option>+ <option value="3">Three</option>+ </select>+</form>+<iframe name="flex_iframe" style="display:none"></iframe>++<script>+promise_test(async t => {+ const form = document.querySelector('form');+ const textInput = document.querySelector('#text');+ const numberInput = document.querySelector('#number');+ const checkboxInput = document.querySelector('#check1');+ const selectElement = document.querySelector('#select');++ let textVal, numberVal, checkVal, selectVal;++ form.addEventListener('submit', e => {+ textVal = textInput.value;+ numberVal = numberInput.value;+ checkVal = checkboxInput.checked;+ selectVal = selectElement.value;+ e.preventDefault();+ e.respondWith(Promise.resolve('done'));+ });++ const tool = await waitForTool('flexible_tool');++ // Test with numeric value for text, string for number, numeric 1 for checkbox, and number for select.+ await document.modelContext.executeTool(tool, {+ text: 123,+ number: "456",+ check1: 1,+ select: 2,+ });++ assert_equals(textVal, '123', 'Number should be coerced to string for text input');+ assert_equals(numberVal, '456', 'String should populate number input');+ assert_true(checkVal, '1 should check checkbox');+ assert_equals(selectVal, '2', 'Number 2 should select option with value "2"');++ // Test with boolean string for checkbox and numeric string for select.+ await document.modelContext.executeTool(tool, {+ check1: 'false',+ select: '3',+ });++ assert_false(checkVal, '"false" should uncheck checkbox');+ assert_equals(selectVal, '3', 'String "3" should select option with value "3"');+}, 'Declarative form tool coerces flexible input types appropriately');+</script>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/executeTool-invalid-input.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/executeTool-invalid-input.https.htmlnew file mode 100644index 000000000..8eb63b928--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/executeTool-invalid-input.https.html@@ -0,0 +1,79 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>WebMCP: executeTool with declarative invalid input arguments and validation errors</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script src="../resources/helpers.js"></script>++<form toolautosubmit toolname="invalid_input_tool" tooldescription="Invalid input tool">+ <input type="text" name="query">+</form>++<form toolautosubmit toolname="invalid_select_tool" tooldescription="Invalid select tool">+ <select name="choice">+ <option value="a">A</option>+ <option value="b">B</option>+ </select>+</form>++<form toolautosubmit toolname="pattern_tool" tooldescription="Pattern tool">+ <input type="text" name="query" pattern="[a-z]+">+ <button type="submit">Submit</button>+</form>++<form toolautosubmit toolname="validation_tool" tooldescription="Validation tool">+ <input type="text" name="text_required" required>+ <input type="number" name="number_min" min="10">+ <button type="submit">Submit</button>+</form>++<script>+promise_test(async t => {+ const tool = await waitForTool('invalid_input_tool');+ assert_true(!!tool, 'Tool should be registered');++ await promise_rejects_dom(+ t,+ 'UnknownError',+ document.modelContext.executeTool(tool, { nonexistent: 'value' }),+ 'executeTool should reject when input contains parameter not in form'+ );+}, 'executeTool rejects when input contains a parameter that does not exist in the form');++promise_test(async t => {+ const tool = await waitForTool('invalid_select_tool');+ assert_true(!!tool, 'Tool should be registered');++ await promise_rejects_dom(+ t,+ 'UnknownError',+ document.modelContext.executeTool(tool, { choice: 'c' }),+ 'executeTool should reject when select option is invalid'+ );+}, 'executeTool rejects when input contains an invalid value for select element');++promise_test(async t => {+ const tool = await waitForTool('pattern_tool');+ assert_true(!!tool, 'Tool should be registered');++ await promise_rejects_dom(+ t,+ 'UnknownError',+ document.modelContext.executeTool(tool, { query: '123' }),+ 'executeTool should reject when input violates pattern constraint'+ );+}, 'executeTool rejects when form input violates pattern constraint');++promise_test(async t => {+ const tool = await waitForTool('validation_tool');+ assert_true(!!tool, 'Tool should be registered');++ await promise_rejects_dom(+ t,+ 'UnknownError',+ document.modelContext.executeTool(tool, { text_required: '', number_min: 5 }),+ 'executeTool should reject when form input violates required and min constraints'+ );+}, 'executeTool rejects when form inputs violate required and min constraints');+</script>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/executeTool-navigation.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/executeTool-navigation.https.htmlnew file mode 100644index 000000000..d791096d1--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/executeTool-navigation.https.html@@ -0,0 +1,28 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>WebMCP: executeTool with declarative form navigation</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script src="../resources/helpers.js"></script>++<form toolautosubmit toolname="nav_search_tool" tooldescription="Search the web" action="/common/blank.html" target="target_iframe">+ <input type="text" name="query">+</form>+<iframe name="target_iframe"></iframe>++<script>+promise_test(async t => {+ const iframe = document.querySelector('iframe');+ const navPromise = new Promise(resolve => iframe.addEventListener('load', resolve, { once: true }));++ const tool = await waitForTool('nav_search_tool');+ assert_true(!!tool, 'Tool should be registered');++ const result = await document.modelContext.executeTool(tool, { query: 'testing' });+ assert_equals(result, null, 'executeTool should resolve with null when navigation is triggered');+ assert_equals(document.querySelector('input').value, 'testing', 'Input value should be populated');++ await navPromise;+}, 'executeTool resolves with null and triggers standard form navigation');+</script>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/executeTool-no-autosubmit.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/executeTool-no-autosubmit.https.htmlnew file mode 100644index 000000000..277947dba--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/executeTool-no-autosubmit.https.html@@ -0,0 +1,116 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>WebMCP: declarative form tool execution without toolautosubmit</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script src="../resources/helpers.js"></script>++<form id="no_auto_submit_form" toolname="no_auto_tool" tooldescription="No auto submit tool" action="about:blank" target="no_auto_iframe">+ <input type="text" name="query">+ <button type="submit">Submit</button>+</form>+<iframe name="no_auto_iframe" style="display:none"></iframe>++<form id="reset_form" toolname="reset_tool" tooldescription="Reset tool" action="about:blank" target="reset_iframe">+ <input type="text" name="query">+ <button type="submit">Submit</button>+</form>+<iframe name="reset_iframe" style="display:none"></iframe>++<form id="unrelated_form" toolname="unrelated_tool" tooldescription="Unrelated submit tool" action="about:blank" target="unrelated_iframe">+ <input type="text" name="query">+ <button type="submit">Submit</button>+</form>+<iframe name="unrelated_iframe" style="display:none"></iframe>++<script>+promise_test(async t => {+ const form = document.querySelector('#no_auto_submit_form');+ const button = form.querySelector('button');+ let submitEventFired = false;++ form.addEventListener('submit', e => {+ submitEventFired = true;+ e.preventDefault();+ e.respondWith(Promise.resolve('result value'));+ });++ const tool = await waitForTool('no_auto_tool');+ const executePromise = document.modelContext.executeTool(tool, { query: 'testing' });++ // Wait until tool populates the form and focuses the button.+ while (document.activeElement !== button) {+ await new Promise(r => t.step_timeout(r, 10));+ }++ assert_equals(document.activeElement, button, 'Submit button should be focused');+ assert_true(form.matches(':tool-form-active'), 'Form should match :tool-form-active while awaiting user submit');+ assert_false(submitEventFired, 'Submit event should not have fired yet without toolautosubmit');++ // Manually click to submit.+ button.click();++ const result = await executePromise;+ assert_true(submitEventFired, 'Submit event should fire after manual button click');+ assert_equals(result, 'result value', 'executeTool should resolve with result value');+ assert_false(form.matches(':tool-form-active'), 'Form should not match :tool-form-active after submission completes');+}, 'executeTool without toolautosubmit focuses submit button and waits for manual submit');++promise_test(async t => {+ const form = document.querySelector('#reset_form');+ const button = form.querySelector('button');++ const tool = await waitForTool('reset_tool');+ const executePromise = document.modelContext.executeTool(tool, { query: 'testing' });++ // Wait until button is focused.+ while (document.activeElement !== button) {+ await new Promise(r => t.step_timeout(r, 10));+ }++ assert_true(form.matches(':tool-form-active'), 'Form should match :tool-form-active');++ // Reset the form.+ form.reset();++ await promise_rejects_dom(+ t,+ 'UnknownError',+ executePromise,+ 'executeTool should reject when form is reset while execution is pending'+ );++ assert_false(form.matches(':tool-form-active'), 'Form should not match :tool-form-active after reset');+}, 'form.reset() cancels pending executeTool execution and clears :tool-form-active');++promise_test(async t => {+ const form = document.querySelector('#unrelated_form');+ const button = form.querySelector('button');++ const tool = await waitForTool('unrelated_tool');+ const executePromise = document.modelContext.executeTool(tool, { query: 'testing' });++ // Wait until button is focused.+ while (document.activeElement !== button) {+ await new Promise(r => t.step_timeout(r, 10));+ }++ assert_true(form.matches(':tool-form-active'), 'Form should match :tool-form-active');++ // Trigger unrelated submit and remove form.+ form.addEventListener('submit', e => {+ e.preventDefault();+ e.respondWith(Promise.resolve('dummy'));+ });+ form.requestSubmit();+ form.remove();++ await promise_rejects_dom(+ t,+ 'UnknownError',+ executePromise,+ 'executeTool should reject when unrelated submit and remove occurs'+ );+}, 'Unrelated form submission and removal cancels pending tool execution');+</script>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/executeTool-pseudo-classes.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/executeTool-pseudo-classes.https.htmlnew file mode 100644index 000000000..486cdd09f--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/executeTool-pseudo-classes.https.html@@ -0,0 +1,96 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>WebMCP: declarative tool execution pseudo-classes and toolactivated event</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script src="../resources/helpers.js"></script>++<style>+ form:tool-form-active { background-color: rgb(0, 255, 0); }+ button:tool-submit-active { color: rgb(255, 0, 0); }+</style>++<form id="pseudo_form" toolautosubmit toolname="pseudo_tool" tooldescription="Pseudo classes tool" action="about:blank" target="pseudo_iframe">+ <input type="text" name="query">+ <button type="submit">Submit</button>+</form>+<iframe name="pseudo_iframe" style="display:none"></iframe>++<form id="populate_form" toolautosubmit toolname="populate_tool" tooldescription="Form populated at event tool" action="about:blank" target="populate_iframe">+ <input type="text" name="query" value="initial">+</form>+<iframe name="populate_iframe" style="display:none"></iframe>++<script>+promise_test(async t => {+ const form = document.querySelector('#pseudo_form');+ const button = form.querySelector('button');+ const input = form.querySelector('input');++ let formActiveDuringSubmit = null;+ let formSubmitActiveDuringSubmit = null;+ let buttonActiveDuringSubmit = null;+ let inputFormActiveDuringSubmit = null;+ let inputSubmitActiveDuringSubmit = null;+ let formBgDuringSubmit = null;+ let buttonColorDuringSubmit = null;++ form.addEventListener('submit', e => {+ formActiveDuringSubmit = form.matches(':tool-form-active');+ formSubmitActiveDuringSubmit = form.matches(':tool-submit-active');+ buttonActiveDuringSubmit = button.matches(':tool-submit-active');+ inputFormActiveDuringSubmit = input.matches(':tool-form-active');+ inputSubmitActiveDuringSubmit = input.matches(':tool-submit-active');+ formBgDuringSubmit = getComputedStyle(form).backgroundColor;+ buttonColorDuringSubmit = getComputedStyle(button).color;+ e.preventDefault();+ e.respondWith(Promise.resolve('result'));+ });++ const tool = await waitForTool('pseudo_tool');+ await document.modelContext.executeTool(tool, { query: 'testing' });++ assert_true(formActiveDuringSubmit, 'Form should match :tool-form-active during submit');+ assert_false(formSubmitActiveDuringSubmit, 'Form should not match :tool-submit-active');+ assert_true(buttonActiveDuringSubmit, 'Button should match :tool-submit-active during submit');+ assert_false(inputFormActiveDuringSubmit, 'Input should not match :tool-form-active');+ assert_false(inputSubmitActiveDuringSubmit, 'Input should not match :tool-submit-active');+ assert_equals(formBgDuringSubmit, 'rgb(0, 255, 0)', 'Form should be styled by :tool-form-active');+ assert_equals(buttonColorDuringSubmit, 'rgb(255, 0, 0)', 'Button should be styled by :tool-submit-active');++ assert_false(form.matches(':tool-form-active'), 'Form should not match :tool-form-active after completion');+ assert_false(button.matches(':tool-submit-active'), 'Button should not match :tool-submit-active after completion');+}, 'Pseudo-classes :tool-form-active and :tool-submit-active apply correctly during execution and are removed upon completion');++promise_test(async t => {+ const form = document.querySelector('#populate_form');+ const input = form.querySelector('input');++ const modelContextEvents = [];+ const inputValuesAtModelContextToolactivated = [];++ const modelContextHandler = e => {+ if (e.toolName === 'populate_tool') {+ modelContextEvents.push(e);+ inputValuesAtModelContextToolactivated.push(input.value);+ }+ };+ document.modelContext.addEventListener('toolactivated', modelContextHandler);+ t.add_cleanup(() => document.modelContext.removeEventListener('toolactivated', modelContextHandler));++ form.addEventListener('submit', e => {+ e.preventDefault();+ e.respondWith(Promise.resolve('done'));+ });++ const tool = await waitForTool('populate_tool');+ await document.modelContext.executeTool(tool, { query: 'testing' });++ assert_equals(modelContextEvents.length, 1, 'toolactivated event should have fired at document.modelContext');+ assert_true(modelContextEvents[0] instanceof ToolActivatedEvent);+ assert_equals(modelContextEvents[0].target, document.modelContext);+ assert_array_equals(inputValuesAtModelContextToolactivated, ['testing'],+ 'Form controls should be populated when toolactivated fires at document.modelContext');+}, 'Form controls are populated with arguments when toolactivated event fires');+</script>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/executeTool-respondWith-circular-object.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/executeTool-respondWith-circular-object.https.htmlnew file mode 100644index 000000000..2f6fda2bd--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/executeTool-respondWith-circular-object.https.html@@ -0,0 +1,35 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>WebMCP: executeTool with declarative tool returning circular object via respondWith</title>+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script src="../resources/helpers.js"></script>+<body>+<form id="form" toolname="circular_tool" tooldescription="Declarative tool returning circular object" toolautosubmit>+</form>++<script>+promise_test(async t => {+ await waitForTool('circular_tool');++ const form = document.querySelector('#form');+ form.addEventListener('submit', (e) => {+ e.preventDefault();+ let a = {};+ a['a'] = a;+ e.respondWith(Promise.resolve(a));+ });++ const tools = await document.modelContext.getTools();+ const tool = tools.find(t => t.name === 'circular_tool');+ assert_true(!!tool, 'Tool should be registered');++ await promise_rejects_dom(+ t,+ 'UnknownError',+ document.modelContext.executeTool(tool),+ 'executeTool() should reject with UnknownError when respondWith is passed a circular object'+ );+}, 'Declarative tool executeTool() rejects when respondWith() receives a circular object');+</script>+</body>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/executeTool-respondWith-reject.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/executeTool-respondWith-reject.https.htmlnew file mode 100644index 000000000..1d0fe2c3f--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/executeTool-respondWith-reject.https.html@@ -0,0 +1,36 @@+<!DOCTYPE html>+<meta charset="utf-8">+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script src="/webmcp/resources/helpers.js"></script>++<form id="reject_form" toolautosubmit toolname="reject_tool" tooldescription="Reject tool" action="about:blank">+ <input type="text" name="query">+ <button type="submit">Submit</button>+</form>++<script>+setup({ allow_uncaught_exception: true });++promise_test(async t => {+ const form = document.querySelector('#reject_form');+ let submitFired = false;++ form.addEventListener('submit', e => {+ submitFired = true;+ e.preventDefault();+ e.respondWith(Promise.reject('rejection'));+ });++ const tool = await waitForTool('reject_tool');+ await promise_rejects_dom(+ t,+ 'UnknownError',+ document.modelContext.executeTool(tool, { query: 'testing' }),+ 'executeTool should reject when respondWith promise is rejected'+ );++ assert_true(submitFired, 'submit event should have fired');+}, 'executeTool rejects when respondWith() promise is rejected');+</script>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/executeTool-respondWith.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/executeTool-respondWith.https.htmlnew file mode 100644index 000000000..7ad95e3e4--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/executeTool-respondWith.https.html@@ -0,0 +1,164 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>WebMCP: declarative tool submit event and respondWith() behavior</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script src="../resources/helpers.js"></script>++<form id="spa_form" toolautosubmit toolname="spa_tool" tooldescription="SPA tool" action="about:blank" target="spa_iframe">+ <input type="text" name="query">+ <button type="submit">Submit</button>+</form>+<iframe name="spa_iframe" style="display:none"></iframe>++<form id="no_respond_form" toolautosubmit toolname="no_respond_tool" tooldescription="No respondWith tool" action="about:blank" target="no_respond_iframe">+ <input type="text" name="query">+ <button type="submit">Submit</button>+</form>+<iframe name="no_respond_iframe" style="display:none"></iframe>++<form id="no_prevent_default_form" toolautosubmit toolname="no_prevent_default_tool" tooldescription="No preventDefault tool" action="/common/blank.html" target="no_prevent_default_iframe">+ <input type="text" name="query">+ <button type="submit">Submit</button>+</form>+<iframe name="no_prevent_default_iframe" style="display:none"></iframe>++<form id="manual_form" action="about:blank" target="manual_iframe">+ <input type="text" name="query">+</form>+<iframe name="manual_iframe" style="display:none"></iframe>++<form id="late_respond_form" toolautosubmit toolname="late_respond_tool" tooldescription="Late respondWith tool" action="about:blank" target="late_respond_iframe">+ <input type="text" name="query">+</form>+<iframe name="late_respond_iframe" style="display:none"></iframe>++<form id="navigate_form" toolautosubmit toolname="navigate_tool" tooldescription="Navigate tool" action="about:blank" target="navigate_iframe">+ <input type="text" name="query">+ <button type="submit">Submit</button>+</form>+<iframe name="navigate_iframe" style="display:none"></iframe>++<script>+promise_test(async t => {+ const form = document.querySelector('#spa_form');+ const input = form.querySelector('input');+ let submitEventFired = false;+ let inputValueAtSubmit = '';++ form.addEventListener('submit', e => {+ submitEventFired = true;+ inputValueAtSubmit = input.value;+ assert_true(e.agentInvoked, 'agentInvoked should be true during tool invocation');+ e.preventDefault();+ e.respondWith(Promise.resolve('result value'));+ });++ const tool = await waitForTool('spa_tool');+ const result = await document.modelContext.executeTool(tool, { query: 'testing' });++ assert_true(submitEventFired, 'submit event should have fired');+ assert_equals(inputValueAtSubmit, 'testing', 'Input value should match tool arguments during submit');+ assert_equals(result, 'result value', 'executeTool should resolve to the respondWith promise value');+}, 'executeTool resolves with respondWith() value when preventDefault() is called');++promise_test(async t => {+ const form = document.querySelector('#no_respond_form');+ form.addEventListener('submit', e => {+ e.preventDefault();+ });++ const tool = await waitForTool('no_respond_tool');+ await promise_rejects_dom(+ t,+ 'UnknownError',+ document.modelContext.executeTool(tool, { query: 'testing' }),+ 'executeTool should reject when submit is preventDefaulted without calling respondWith'+ );+}, 'executeTool rejects when preventDefault() is called without respondWith()');++promise_test(async t => {+ const form = document.querySelector('#no_prevent_default_form');+ const iframe = document.querySelector('iframe[name="no_prevent_default_iframe"]');+ const navPromise = new Promise(resolve => iframe.addEventListener('load', resolve, { once: true }));+ let respondWithError = null;++ form.addEventListener('submit', e => {+ try {+ e.respondWith(Promise.resolve('result'));+ } catch (err) {+ respondWithError = err;+ }+ });++ const tool = await waitForTool('no_prevent_default_tool');+ const result = await document.modelContext.executeTool(tool, { query: 'testing' });++ assert_true(respondWithError instanceof DOMException, 'respondWith should throw DOMException');+ assert_equals(respondWithError.name, 'InvalidStateError', 'respondWith should throw InvalidStateError when preventDefault() was not called');+ assert_equals(result, null, 'executeTool should resolve to null when form navigates');++ await navPromise;+}, 'respondWith() throws InvalidStateError if preventDefault() was not called, and form navigates');++test(() => {+ const form = document.querySelector('#manual_form');+ let agentInvoked = undefined;+ let error = null;++ form.addEventListener('submit', e => {+ agentInvoked = e.agentInvoked;+ try {+ e.respondWith(Promise.resolve('result'));+ } catch (err) {+ error = err;+ }+ e.preventDefault();+ });++ form.requestSubmit();++ assert_false(agentInvoked, 'agentInvoked should be false for manual submission');+ assert_true(error instanceof DOMException, 'respondWith should throw DOMException');+ assert_equals(error.name, 'InvalidStateError', 'respondWith should throw InvalidStateError on manual submit');+}, 'respondWith() throws InvalidStateError and agentInvoked is false when submit is not agent-invoked');++promise_test(async t => {+ const form = document.querySelector('#late_respond_form');+ let savedEvent = null;++ form.addEventListener('submit', e => {+ savedEvent = e;+ e.preventDefault();+ e.respondWith(Promise.resolve('result'));+ });++ const tool = await waitForTool('late_respond_tool');+ const result = await document.modelContext.executeTool(tool, { query: 'testing' });+ assert_equals(result, 'result');++ assert_throws_dom('InvalidStateError', () => {+ savedEvent.respondWith(Promise.resolve('late'));+ }, 'late call to respondWith should throw InvalidStateError');+}, 'Calling respondWith() after submit event dispatch throws InvalidStateError');++promise_test(async t => {+ const form = document.querySelector('#navigate_form');+ const iframe = document.querySelector('iframe[name="navigate_iframe"]');+ const navPromise = new Promise(resolve => iframe.addEventListener('load', resolve, { once: true }));++ form.addEventListener('submit', e => {+ e.preventDefault();+ e.respondWith(Promise.resolve('result value'));+ iframe.src = '/common/blank.html';+ });++ const tool = await waitForTool('navigate_tool');+ const result = await document.modelContext.executeTool(tool, { query: 'testing' });++ assert_equals(result, 'result value', 'executeTool should resolve to respondWith value even if navigation occurs');++ await navPromise;+}, 'executeTool resolves successfully with respondWith() value even if a navigation is initiated');+</script>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/execute_tool_change_event.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/execute_tool_change_event.https.htmlnew file mode 100644index 000000000..b332cc924--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/execute_tool_change_event.https.html@@ -0,0 +1,76 @@+<!DOCTYPE html>+<meta charset="utf-8">+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script src="/webmcp/resources/helpers.js"></script>++<form toolname="fill_text" tooldescription="Fill some text"+ toolautosubmit target="hidden_iframe" action="about:blank">+ <input id="myinput" name="text" type="text">+ <input id="mynumber" name="number" type="number">+ <input id="mycheckbox" name="checkbox" type="checkbox" value="check1">+ <input id="myradio" name="radio" type="radio" value="radio1">+ <input id="myradio2" name="radio" type="radio" value="radio2">+ <textarea id="mytextarea" name="textarea"></textarea>+ <select id="myselect" name="select">+ <option value="opt1">Opt 1</option>+ <option value="opt2">Opt 2</option>+ </select>+</form>+<iframe name=hidden_iframe style="display:none"></iframe>++<script>+promise_test(async t => {+ const tool = await waitForTool('fill_text');+ assert_true(!!tool, 'Tool should be registered');++ let form = document.querySelector('form');+ let inputs = form.querySelectorAll('input, textarea, select');+ let events = {};++ for (let el of inputs) {+ if (el.id) {+ events[el.id] = { inputFired: false, changeFired: false };+ el.addEventListener('change', () => { events[el.id].changeFired = true; });+ el.addEventListener('input', () => { events[el.id].inputFired = true; });+ }+ }++ let inputObject = {+ text: "regular text",+ number: 42,+ checkbox: true,+ radio: "radio2",+ textarea: "some text area content",+ select: "opt2"+ };++ await document.modelContext.executeTool(tool, inputObject);++ assert_equals(document.getElementById('myinput').value, 'regular text');+ assert_true(events['myinput'].inputFired, 'text input event should fire');+ assert_true(events['myinput'].changeFired, 'text change event should fire');++ assert_equals(document.getElementById('mynumber').value, '42');+ assert_true(events['mynumber'].inputFired, 'number input event should fire');+ assert_true(events['mynumber'].changeFired, 'number change event should fire');++ assert_true(document.getElementById('mycheckbox').checked);+ assert_true(events['mycheckbox'].inputFired, 'checkbox input event should fire');+ assert_true(events['mycheckbox'].changeFired, 'checkbox change event should fire');++ assert_false(document.getElementById('myradio').checked);+ assert_true(document.getElementById('myradio2').checked);+ assert_true(events['myradio2'].inputFired, 'radio input event should fire');+ assert_true(events['myradio2'].changeFired, 'radio change event should fire');++ assert_equals(document.getElementById('mytextarea').value, 'some text area content');+ assert_true(events['mytextarea'].inputFired, 'textarea input event should fire');+ assert_true(events['mytextarea'].changeFired, 'textarea change event should fire');++ assert_equals(document.getElementById('myselect').value, 'opt2');+ assert_true(events['myselect'].inputFired, 'select input event should fire');+ assert_true(events['myselect'].changeFired, 'select change event should fire');+}, 'executeTool triggers input and change events');+</script>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/execute_tool_submit_from_js.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/execute_tool_submit_from_js.https.htmlnew file mode 100644index 000000000..fa6cb031c--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/execute_tool_submit_from_js.https.html@@ -0,0 +1,31 @@+<!DOCTYPE html>+<meta charset="utf-8">+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script src="/webmcp/resources/helpers.js"></script>++<form toolname="submit_test" tooldescription="Submit test form" target="hidden_iframe" action="about:blank" toolautosubmit>+</form>+<iframe name="hidden_iframe" style="display:none"></iframe>++<script>+promise_test(async t => {+ const tool = await waitForTool('submit_test');+ assert_true(!!tool, 'Tool should be registered');++ let form = document.querySelector('form');+ let submitFired = false;++ form.addEventListener('submit', (e) => {+ submitFired = true;+ e.preventDefault();+ form.submit();+ });++ // Call executeTool. If it throws, the test fails automatically.+ await document.modelContext.executeTool(tool);++ assert_true(submitFired, 'submit event should have fired');+}, 'executeTool resolves successfully when submit handler calls form.submit()');+</script>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/form_removal_submit_crash.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/form_removal_submit_crash.https.htmlnew file mode 100644index 000000000..4d4b0980d--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/form_removal_submit_crash.https.html@@ -0,0 +1,44 @@+<!DOCTYPE html>+<title>Form removal on submit crash test</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script src="/webmcp/resources/helpers.js"></script>++<form toolname="crash_test" tooldescription="the crashy form!" toolautosubmit target="iframe" action="about:blank">+ <input name="dummy" type="text">+</form>+<iframe name="iframe"></iframe>++<script>+promise_test(async t => {+ const form = document.querySelector('form');+ let submitFired = false;++ form.addEventListener('submit', (e) => {+ submitFired = true;+ e.preventDefault();+ e.respondWith(Promise.resolve());++ // This synchronously unregisters the tool. The previously crashy path was+ // when the internal form infrastructure relied on the form still being+ // registered as a tool immediately after the submit event is fired.+ // Specifically, we reacted to the Promise above, and the Promise reaction+ // relied on the tool registration still being valid.+ //+ // See https://crbug.com/493850055.+ form.remove();+ });++ const tool = await waitForTool('crash_test');+ assert_true(!!tool, 'Tool should be found');++ // Execute the tool. This asynchronously fires the `submit` event at the form.+ // The tool execution should resolve successfully even if the form is removed+ // from the document during submission.+ const promise = document.modelContext.executeTool(tool);+ await promise;++ assert_true(submitFired);+}, "Form removal on submit with respondWith does not crash the renderer");+</script>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/getTools-declarative-schema.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/getTools-declarative-schema.https.htmlnew file mode 100644index 000000000..66f79afa4--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/getTools-declarative-schema.https.html@@ -0,0 +1,44 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>WebMCP: getTools() retrieves declarative schema at registration time</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script src="../resources/helpers.js"></script>+<body>++<form toolname="search_tool" tooldescription="Search the web">+ <input type="text" name="query" required toolparamdescription="The search query">+ <input type="number" name="limit" toolparamdescription="Max results count">+ <input type="checkbox" name="safe_search" toolparamdescription="Enable safe search filtering">+</form>++<script>+ promise_test(async t => {+ let expected_schema_obj = {+ type: "object",+ properties: {+ query: {+ type: "string",+ description: "The search query"+ },+ limit: {+ type: "number",+ multipleOf: 1,+ description: "Max results count"+ },+ safe_search: {+ type: "boolean",+ description: "Enable safe search filtering"+ }+ },+ required: ["query"]+ };++ const tool = await waitForFormToolSchemaToMatch(expected_schema_obj);++ assert_equals(tool.name, "search_tool", "Tool name matches");+ assert_equals(tool.description, "Search the web", "Tool description matches");+ }, "WebMCP: getTools() retrieves declarative schema at registration time");+</script>+</body>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/no-frame-documents.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/no-frame-documents.https.htmlnew file mode 100644index 000000000..6cdddcc76--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/no-frame-documents.https.html@@ -0,0 +1,54 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>WebMCP: Declarative tools in documents without browsing context are not registered</title>+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script src="../resources/helpers.js"></script>+<body>+<script>+promise_test(async t => {+ const doc = document.implementation.createHTMLDocument();+ const form = doc.createElement('form');+ form.setAttribute('toolname', 'mytool');+ form.setAttribute('tooldescription', 'description');+ doc.body.append(form);++ const tools = await document.modelContext.getTools();+ assert_equals(tools.length, 0, "No tools should be registered from a frame-less document");+}, "Declarative tool in document without active frame is not registered");++promise_test(async t => {+ const parser = new DOMParser();+ const doc = parser.parseFromString(`+ <form toolname="mytool" tooldescription="description"></form>+ `, 'text/html');++ const tools = await document.modelContext.getTools();+ assert_equals(tools.length, 0, "No tools should be registered from DOMParser document");+}, "Declarative tool in DOMParser document is not registered");++promise_test(async t => {+ const doc = document.implementation.createHTMLDocument();+ const form = doc.createElement('form');+ form.setAttribute('toolname', 'mytool');+ doc.body.append(form);++ const tools = await document.modelContext.getTools();+ assert_equals(tools.length, 0, "No tools should be registered from a frame-less document with name only");+}, "Declarative tool with name only in document without active frame is not registered");++promise_test(async t => {+ const iframe = document.createElement('iframe');+ document.body.append(iframe);+ iframe.contentDocument.body.innerHTML =+ `<form toolname="mytool" tooldescription="description"></form>`;+ const tool = await waitForTool('mytool');+ assert_equals(tool.name, 'mytool');+ assert_equals(tool.description, 'description');++ const form = iframe.contentDocument.querySelector('form');+ iframe.remove();+ form.setAttribute('toolname', 'differenttool');+}, "Declarative tool in iframe removed after registration does not crash on attribute modification");+</script>+</body>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/opaque-origin-tools.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/opaque-origin-tools.https.htmlnew file mode 100644index 000000000..ffed048e6--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/opaque-origin-tools.https.html@@ -0,0 +1,61 @@+<!DOCTYPE html>+<html>+<head>+<title>WebMCP Opaque Origin Declarative Tool</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script src="../resources/helpers.js"></script>+</head>+<body>++<form toolname="opaque_tool" tooldescription="Opaque tool description">+ <input type="text" name="param1">+</form>++<script>+promise_test(async t => {+ // Assert that our CSP header took effect.+ assert_equals(self.origin, 'null');++ // Wait for the tool to register (happens synchronously upon parsing, but+ // getTools is async)+ const tool = await waitForTool('opaque_tool');+ assert_true(!!tool, "Tool should be successfully registered from an opaque origin");++ await promise_rejects_dom(+ t,+ 'NotSupportedError',+ document.modelContext.executeTool(tool, {"param1":"value"}),+ 'executeTool() must reject with NotSupportedError in opaque origin documents'+ );+}, 'An opaque origin document can register but not execute its own declarative tools');++promise_test(async t => {+ const tools = await document.modelContext.getTools();+ const tool = tools.find(t => t.name === 'opaque_tool');++ let events = [];+ const p = document.modelContext.executeTool(tool);++ // Since `executeTool()` synchronously rejects the Promise for opaque origins,+ // the microtask to run the catch reaction is already queued before+ // `queueMicrotask()` is invoked below.+ p.catch(() => events.push('rejection'));++ // Queue another microtask immediately after.+ queueMicrotask(() => events.push('microtask'));++ await promise_rejects_dom(+ t,+ 'NotSupportedError',+ document.modelContext.executeTool(tool, {"param1":"value"}),+ 'executeTool() must reject with NotSupportedError in opaque origin documents'+ );++ assert_array_equals(events, ['rejection', 'microtask'],+ 'returned promise is rejected before custom microtask is queued');+}, 'executeTool() rejects synchronously for opaque origins');+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/opaque-origin-tools.https.html.headers b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/opaque-origin-tools.https.html.headersnew file mode 100644index 000000000..1efcf8c22--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/opaque-origin-tools.https.html.headers@@ -0,0 +1 @@+Content-Security-Policy: sandbox allow-scriptsdiff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/sandboxed-iframe.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/sandboxed-iframe.https.htmlnew file mode 100644index 000000000..dc07d4318--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/sandboxed-iframe.https.html@@ -0,0 +1,42 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>WebMCP: Declarative tools in sandboxed iframe without allow-scripts are not registered</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script src="../resources/helpers.js"></script>+<body>+<script>+promise_test(async t => {+ const sandboxedIframe = document.createElement('iframe');+ sandboxedIframe.sandbox = 'allow-same-origin';+ document.body.append(sandboxedIframe);++ const allowedIframe = document.createElement('iframe');+ allowedIframe.sandbox = 'allow-same-origin allow-scripts';+ document.body.append(allowedIframe);++ sandboxedIframe.contentDocument.body.innerHTML = `+ <form toolname="sandboxed_tool" tooldescription="description">+ <input type="text" name="sandboxed_input">+ </form>`;++ allowedIframe.contentDocument.body.innerHTML = `+ <form toolname="allowed_tool" tooldescription="description">+ <input type="text" name="allowed_input">+ </form>`;++ await waitForFormToolSchemaToMatch({+ type: 'object',+ properties: {+ allowed_input: {type: 'string'},+ },+ required: [],+ });++ const tools = await document.modelContext.getTools();+ assert_equals(tools.length, 1);+ assert_equals(tools[0].name, 'allowed_tool');+}, "Declarative tool in sandboxed iframe without allow-scripts is not registered");+</script>+</body>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/select-multiple-events.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/select-multiple-events.https.htmlnew file mode 100644index 000000000..016417476--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/select-multiple-events.https.html@@ -0,0 +1,59 @@+<!DOCTYPE html>+<title>WebMCP: executeTool on <select multiple> dispatches events</title>+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script src="/webmcp/resources/helpers.js"></script>++<!-- We'll submit the form to this frame. -->+<iframe name=hidden_iframe style="display:none"></iframe>++<form+ toolname=select_fruits+ tooldescription="Select fruits you like"+ toolautosubmit+ target=hidden_iframe+ action="about:blank">+ <select id=fruits name=fruits multiple>+ <option value=apple>Apple</option>+ <option value=orange>Orange</option>+ <option value=banana>Banana</option>+ </select>+ <input type=submit>+</form>++<script>+promise_test(async t => {+ const tool = await waitForTool('select_fruits');+ assert_true(!!tool, 'Tool should be registered');++ let fruits = document.getElementById('fruits');+ let inputEventCount = 0;+ let changeEventCount = 0;++ fruits.addEventListener('input', () => {+ inputEventCount++;+ });+ fruits.addEventListener('change', () => {+ changeEventCount++;+ });++ let inputObject = { fruits: ['apple', 'banana'] };++ // This should dispatch events.+ await document.modelContext.executeTool(tool, inputObject);++ assert_true(fruits.options[0].selected);+ assert_false(fruits.options[1].selected);+ assert_true(fruits.options[2].selected);++ assert_equals(inputEventCount, 1);+ assert_equals(changeEventCount, 1);++ // Executing with the same arguments again does not trigger events.+ await document.modelContext.executeTool(tool, inputObject);++ assert_equals(inputEventCount, 1);+ assert_equals(changeEventCount, 1);+}, 'executeTool() on a <select multiple> dispatches input and change events');++</script>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/toolchange-on-attribute-mutation.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/toolchange-on-attribute-mutation.https.htmlnew file mode 100644index 000000000..070096b25--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/toolchange-on-attribute-mutation.https.html@@ -0,0 +1,175 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>WebMCP: toolchange event and getTools() update on form attribute mutation</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script src="../resources/helpers.js"></script>+<body>++<form id="f1" toolname="my_tool" tooltitle="My Title" tooldescription="desc">+ <input id="input1" type="text" name="input_name">+</form>++<script>+function waitForToolChange() {+ return new Promise(resolve => {+ document.modelContext.addEventListener('toolchange', resolve, { once: true });+ });+}++promise_test(async t => {+ const form = document.getElementById('f1');++ // Wait for initial registration to complete.+ const tool = await waitForTool('my_tool');+ assert_equals(tool.name, 'my_tool');+ assert_equals(tool.title, 'My Title');+ assert_equals(tool.description, 'desc');++ // Test updating tooltitle attribute+ {+ const changePromise = waitForToolChange();+ form.setAttribute('tooltitle', 'New Title');+ await changePromise;++ let tools = await document.modelContext.getTools();+ assert_equals(tools.length, 1, "Still one tool");+ assert_equals(tools[0].title, 'New Title', "Title is updated");+ }++ // Test updating tooldescription attribute+ {+ const changePromise = waitForToolChange();+ form.setAttribute('tooldescription', 'New Description');+ await changePromise;++ let tools = await document.modelContext.getTools();+ assert_equals(tools.length, 1);+ assert_equals(tools[0].description, 'New Description', "Description is updated");+ }++ // Test updating toolname attribute+ {+ const changePromise = waitForToolChange();+ form.setAttribute('toolname', 'new_tool_name');+ await changePromise;++ let tools = await document.modelContext.getTools();+ assert_equals(tools.length, 1);+ assert_equals(tools[0].name, 'new_tool_name', "Name is updated");+ }++ // Test removing tooltitle attribute (should fall back to empty string)+ {+ const changePromise = waitForToolChange();+ form.removeAttribute('tooltitle');+ await changePromise;++ let tools = await document.modelContext.getTools();+ assert_equals(tools.length, 1);+ assert_equals(tools[0].title, '', "Title should fall back to empty string");+ }++ // Test removing tooldescription attribute (should unregister the tool since it's required)+ {+ const changePromise = waitForToolChange();+ form.removeAttribute('tooldescription');+ await changePromise;++ let tools = await document.modelContext.getTools();+ assert_equals(tools.length, 0, "Tool should be unregistered when description is removed");+ }++ // Restore the description attribute to re-register the tool+ {+ const changePromise = waitForToolChange();+ form.setAttribute('tooldescription', 'Restored Description');+ await changePromise;++ let tools = await document.modelContext.getTools();+ assert_equals(tools.length, 1);+ assert_equals(tools[0].name, 'new_tool_name');+ assert_equals(tools[0].description, 'Restored Description');+ }++ // Test adding toolautosubmit attribute+ {+ const changePromise = waitForToolChange();+ form.setAttribute('toolautosubmit', '');+ await changePromise;++ let tools = await document.modelContext.getTools();+ assert_equals(tools.length, 1, "Tool still registered after adding toolautosubmit");+ assert_equals(tools[0].name, 'new_tool_name', "Tool name is still the same");+ }++ // Test removing toolautosubmit attribute+ {+ const changePromise = waitForToolChange();+ form.removeAttribute('toolautosubmit');+ await changePromise;++ let tools = await document.modelContext.getTools();+ assert_equals(tools.length, 1, "Tool still registered after removing toolautosubmit");+ assert_equals(tools[0].name, 'new_tool_name', "Tool name is still the same");+ }++ // Test removing toolname attribute (should unregister the tool since it's required)+ {+ const changePromise = waitForToolChange();+ form.removeAttribute('toolname');+ await changePromise;++ let tools = await document.modelContext.getTools();+ assert_equals(tools.length, 0, "Tool should be unregistered when name is removed");+ }+}, "Test that mutating or removing form attributes (toolname, tooldescription, tooltitle, toolautosubmit) fires toolchange and updates getTools() correctly");++promise_test(async t => {+ const form = document.createElement('form');+ form.setAttribute('toolname', 'attr_test_tool');+ form.setAttribute('tooldescription', 'desc');+ const input = document.createElement('input');+ input.name = 'input_name';+ form.appendChild(input);+ document.body.appendChild(form);+ t.add_cleanup(() => form.remove());++ await waitForTool('attr_test_tool');++ let toolchangeCount = 0;+ const listener = () => toolchangeCount++;+ document.modelContext.addEventListener('toolchange', listener);+ t.add_cleanup(() => document.modelContext.removeEventListener('toolchange', listener));++ input.setAttribute('data-unrelated', 'value');+ await new Promise(resolve => t.step_timeout(resolve, 50));+ assert_equals(toolchangeCount, 0, 'toolchange should not fire on unrelated attribute');+}, "No toolchange event on unrelated attribute mutation");++promise_test(async t => {+ const form = document.createElement('form');+ form.setAttribute('toolname', 'redundant_test_tool');+ form.setAttribute('tooldescription', 'desc');+ const input = document.createElement('input');+ input.name = 'input_name';+ form.appendChild(input);+ document.body.appendChild(form);+ t.add_cleanup(() => form.remove());++ await waitForTool('redundant_test_tool');++ let toolchangeCount = 0;+ const listener = () => toolchangeCount++;+ document.modelContext.addEventListener('toolchange', listener);+ t.add_cleanup(() => document.modelContext.removeEventListener('toolchange', listener));++ input.remove();+ form.appendChild(input);+ await new Promise(resolve => t.step_timeout(resolve, 50));+ assert_equals(toolchangeCount, 0, 'toolchange should not fire on redundant schema mutation');+}, "No toolchange event on redundant schema mutation");+</script>+</body>+diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/toolchange-on-control-add-remove.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/toolchange-on-control-add-remove.https.htmlnew file mode 100644index 000000000..3612d3ac6--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/toolchange-on-control-add-remove.https.html@@ -0,0 +1,36 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>WebMCP: toolchange event on control add/remove</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script src="../resources/helpers.js"></script>+<body>++<form id="f1" toolname="my_tool" tooldescription="desc">+ <input id="input1" type="text" name="input_name">+</form>++<script>++ promise_test(async t => {+ const form = document.getElementById('f1');++ // Wait for the baseline form schema.+ await waitForFormToolSchemaToMatch({"type":"object","properties":{"input_name":{"type":"string"}},"required":[]});++ // Test adding an input+ const i = document.createElement('input');+ i.type = 'text';+ i.name = 'new_input';+ i.id = 'new_input';+ form.appendChild(i);+ await waitForFormToolSchemaToMatch({"type":"object","properties":{"input_name":{"type":"string"},"new_input":{"type":"string"}},"required":[]});++ // Test removing an input+ const newInput = document.getElementById('new_input');+ form.removeChild(newInput);+ await waitForFormToolSchemaToMatch({"type":"object","properties":{"input_name":{"type":"string"}},"required":[]});+ }, "Test that toolchange event fires when controls are added or removed");+</script>+</body>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/toolchange-on-name-change.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/toolchange-on-name-change.https.htmlnew file mode 100644index 000000000..26da1ad83--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/toolchange-on-name-change.https.html@@ -0,0 +1,62 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>WebMCP: toolchange event on name change</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<body>+ <form toolname="my_tool" tooldescription="desc">+ <input id="input1" type="text" name="input_name">+ <input id="input2" type="checkbox" name="checkbox_name">+ <select id="select1" name="select_name">+ <option value="a">A</option>+ <option value="b">B</option>+ </select>+ <textarea id="textarea1" name="textarea_name"></textarea>+ </form>+ <script>+ function waitForToolChange() {+ return new Promise(resolve => {+ document.modelContext.addEventListener('toolchange', resolve, { once: true });+ });+ }++ promise_test(async t => {+ const testMutations = [+ // input1 (text)+ { id: 'input1', action: el => el.setAttribute('name', 'new_input_name') },+ { id: 'input1', action: el => el.type = 'number' },+ { id: 'input1', action: el => el.required = true },+ { id: 'input1', action: el => el.setAttribute('toolparamdescription', 'new desc') },++ // input2 (checkbox)+ { id: 'input2', action: el => el.setAttribute('name', 'new_checkbox_name') },+ { id: 'input2', action: el => el.type = 'radio' },+ { id: 'input2', action: el => el.required = true },+ { id: 'input2', action: el => el.setAttribute('toolparamdescription', 'new desc') },++ // select1+ { id: 'select1', action: el => el.setAttribute('name', 'new_select_name') },+ { id: 'select1', action: el => el.multiple = true },+ { id: 'select1', action: el => el.required = true },+ { id: 'select1', action: el => el.setAttribute('toolparamdescription', 'new desc') },++ // textarea1+ { id: 'textarea1', action: el => el.setAttribute('name', 'new_textarea_name') },+ { id: 'textarea1', action: el => el.required = true },+ { id: 'textarea1', action: el => el.setAttribute('toolparamdescription', 'new desc') }+ ];++ for (let i = 0; i < testMutations.length; i++) {+ const m = testMutations[i];+ const el = document.getElementById(m.id);+ assert_true(!!el, `Element ${m.id} should exist`);++ const promise = waitForToolChange();+ m.action(el);+ await promise;+ // If we reach here, the event was fired.+ }+ }, "Test that toolchange event fires on various mutations of form controls");+ </script>+</body>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/unregister-during-executeTool.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/unregister-during-executeTool.https.htmlnew file mode 100644index 000000000..3ed0444ce--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/declarative/unregister-during-executeTool.https.html@@ -0,0 +1,103 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>WebMCP: executeTool with Unregistered Declarative Tool</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script src="../resources/helpers.js"></script>+<body>+<script>+promise_test(async t => {+ const form = document.createElement('form');+ form.setAttribute('toolname', 'endless_tool');+ form.setAttribute('tooldescription', 'Endless declarative tool');+ form.setAttribute('toolautosubmit', '');+ document.body.appendChild(form);+ t.add_cleanup(() => form.remove());++ await waitForTool('endless_tool');++ let resolveRespondWith;+ const submitted_promise = new Promise((resolve) => {+ form.addEventListener('submit', (e) => {+ e.preventDefault();+ // Respond with a Promise that resolves when resolveRespondWith is called.+ e.respondWith(new Promise(res => {+ resolveRespondWith = res;+ }));+ resolve();+ });+ });++ const tools = await document.modelContext.getTools();+ const tool = tools.find(t => t.name === 'endless_tool');+ assert_true(!!tool, 'Tool should be registered');++ const execute_promise = document.modelContext.executeTool(tool);++ // Wait deterministically for the form to submit and call respondWith().+ await submitted_promise;++ const toolChangePromise = new Promise(resolve =>+ document.modelContext.addEventListener('toolchange', resolve, { once: true }));++ // Unregister the declarative tool by removing the form element while execution is pending.+ form.remove();+ await toolChangePromise;++ const currentTools = await document.modelContext.getTools();+ assert_array_equals(currentTools, [], 'Unregistered tool should no longer be returned by getTools()');++ resolveRespondWith('form_dom_result');++ const result = await execute_promise;+ assert_equals(result, 'form_dom_result', 'Pending execution Promise should resolve to tool result even if form element was removed from DOM');+}, 'Pending executeTool() Promise resolves successfully when target declarative tool is unregistered via DOM removal');++promise_test(async t => {+ const form = document.createElement('form');+ form.setAttribute('toolname', 'endless_tool_attr');+ form.setAttribute('tooldescription', 'Endless declarative tool attribute');+ form.setAttribute('toolautosubmit', '');+ document.body.appendChild(form);+ t.add_cleanup(() => form.remove());++ await waitForTool('endless_tool_attr');++ let resolveRespondWith;+ const submitted_promise = new Promise((resolve) => {+ form.addEventListener('submit', (e) => {+ e.preventDefault();+ e.respondWith(new Promise(res => {+ resolveRespondWith = res;+ }));+ resolve();+ });+ });++ const tools = await document.modelContext.getTools();+ const tool = tools.find(t => t.name === 'endless_tool_attr');+ assert_true(!!tool, 'Tool should be registered');++ const execute_promise = document.modelContext.executeTool(tool);++ // Wait deterministically for the form to submit and call respondWith().+ await submitted_promise;++ const toolChangePromise = new Promise(resolve =>+ document.modelContext.addEventListener('toolchange', resolve, { once: true }));++ // Unregister by removing required tooldescription attribute while execution is pending.+ form.removeAttribute('tooldescription');+ await toolChangePromise;++ const currentTools = await document.modelContext.getTools();+ assert_array_equals(currentTools, [], 'Unregistered tool should no longer be returned by getTools()');++ resolveRespondWith('form_attr_result');++ const result = await execute_promise;+ assert_equals(result, 'form_attr_result', 'Pending execution Promise should resolve to tool result even if form attribute was removed');+}, 'Pending executeTool() Promise resolves successfully when target declarative tool is unregistered via attribute removal');+</script>+</body>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/cancel-reentrancy-crash.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/cancel-reentrancy-crash.https.htmlnew file mode 100644index 000000000..ec095691d--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/cancel-reentrancy-crash.https.html@@ -0,0 +1,56 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>WebMCP: Cancel execution reentrancy crash test</title>+<script src="/webmcp/resources/helpers.js"></script>++<script>+window.onload = async () => {+ const controllerA = new AbortController();++ let resolveAStart;+ const promiseAStart = new Promise(r => resolveAStart = r);+ await document.modelContext.registerTool({+ name: "toolA",+ description: "hangs",+ execute: async () => {+ resolveAStart();+ return new Promise(() => {}); // Never resolves+ }+ });++ let resolveBStart;+ const promiseBStart = new Promise(r => resolveBStart = r);+ let resolveBCompletion;+ const promiseBCompletion = new Promise(r => resolveBCompletion = r);+ await document.modelContext.registerTool({+ name: "toolB",+ description: "manual resolve",+ execute: async () => {+ resolveBStart();+ return promiseBCompletion;+ }+ });++ document.modelContext.addEventListener('toolcancel', (event) => {+ if (event.toolName === 'toolA') {+ // Synchronously resolve toolB promise during toolA cancel.+ // This will queue the microtask to remove toolB from pending_executions_+ // and trigger a re-hash.+ resolveBCompletion("doneB");+ }+ });++ const tools = await document.modelContext.getTools();+ const regA = tools.find(t => t.name === 'toolA');+ const regB = tools.find(t => t.name === 'toolB');++ document.modelContext.executeTool(regA, {}, { signal: controllerA.signal });+ document.modelContext.executeTool(regB);++ // Wait for both tool execute callbacks to run and return, ensuring they are+ // inserted into pending_executions_.+ await Promise.all([promiseAStart, promiseBStart]);++ controllerA.abort();+};+</script>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/detached-frame-executeTool.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/detached-frame-executeTool.https.htmlnew file mode 100644index 000000000..872ba3342--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/detached-frame-executeTool.https.html@@ -0,0 +1,47 @@+<!DOCTYPE html>+<html>+<head>+<title>executeTool() in detached frame</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+</head>+<body>+<script>+promise_test(async t => {+ const iframe = document.createElement('iframe');+ iframe.src = '/common/blank.html';++ const load_promise = new Promise(resolve => iframe.onload = resolve);+ document.body.append(iframe);+ await load_promise;++ const iDOMException = iframe.contentWindow.DOMException;+ const iframe_modelContext = iframe.contentWindow.document.modelContext;++ // Register a dummy tool so we have a valid tool object before detaching the frame.+ const toolchange_promise = new Promise(resolve => {+ iframe_modelContext.addEventListener('toolchange', resolve, { once: true });+ });++ iframe_modelContext.registerTool({+ name: 'dummy_tool',+ description: 'Dummy tool',+ execute: async () => {}+ });++ await toolchange_promise;++ const tools = await iframe_modelContext.getTools();+ const tool = tools.find(t => t.name === 'dummy_tool');+ assert_true(!!tool, 'Tool should be registered');++ // Detach the iframe context.+ iframe.remove();++ // Calling executeTool() should reject with InvalidStateError.+ await promise_rejects_dom(t, 'InvalidStateError', iDOMException, iframe_modelContext.executeTool(tool));+}, 'executeTool() throws `InvalidStateError` in detached frame');+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/detached-frame-getTools.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/detached-frame-getTools.https.htmlnew file mode 100644index 000000000..fe60e5a01--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/detached-frame-getTools.https.html@@ -0,0 +1,26 @@+<!DOCTYPE html>+<html>+<head>+<title>getTools() in detached frame</title>+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+</head>+<body>+<script>+promise_test(async t => {+ const iframe = document.createElement('iframe');+ iframe.src = '/common/blank.html';++ const load_promise = new Promise(resolve => iframe.onload = resolve);+ document.body.append(iframe);+ await load_promise;++ const iDOMException = iframe.contentWindow.DOMException;+ const iframe_modelContext = iframe.contentWindow.document.modelContext;+ iframe.remove();++ await promise_rejects_dom(t, 'InvalidStateError', iDOMException, iframe_modelContext.getTools());+}, 'getTools() throws `InvalidStateError` in detached frame');+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/detached-frame-modelContext.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/detached-frame-modelContext.https.htmlnew file mode 100644index 000000000..ae1634dd4--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/detached-frame-modelContext.https.html@@ -0,0 +1,28 @@+<!DOCTYPE html>+<html>+<head>+<title>document.modelContext in detached frame</title>+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+</head>+<body>+<script>+promise_test(async t => {+ const iframe = document.createElement('iframe');+ iframe.src = '/common/blank.html';++ const load_promise = new Promise(resolve => iframe.onload = resolve);+ document.body.append(iframe);+ await load_promise;++ const iframe_doc = iframe.contentDocument;+ const iDOMException = iframe.contentWindow.DOMException;+ iframe.remove();++ assert_not_equals(iframe_doc.modelContext, undefined);+ await promise_rejects_dom(t, 'InvalidStateError', iDOMException,+ iframe_doc.modelContext.getTools());+}, 'document.modelContext in detached frame');+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/detached-frame-registerTool.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/detached-frame-registerTool.https.htmlnew file mode 100644index 000000000..0ce409913--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/detached-frame-registerTool.https.html@@ -0,0 +1,31 @@+<!DOCTYPE html>+<html>+<head>+<title>registerTool() in detached frame</title>+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+</head>+<body>+<script>+promise_test(async t => {+ const iframe = document.createElement('iframe');+ iframe.src = '/common/blank.html';++ const load_promise = new Promise(resolve => iframe.onload = resolve);+ document.body.append(iframe);+ await load_promise;++ const iDOMException = iframe.contentWindow.DOMException;+ const iframe_modelContext = iframe.contentWindow.document.modelContext;+ iframe.remove();++ return promise_rejects_dom(t, 'InvalidStateError', iDOMException,+ iframe_modelContext.registerTool({+ name: 'detached_tool',+ description: 'Tool registered in detached frame',+ execute: async () => 'hello'+ }), 'Rejects InvalidStateError for detached frame');+}, 'registerTool() rejects `InvalidStateError` in detached frame');+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/duplicate_tool_registration.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/duplicate_tool_registration.https.htmlnew file mode 100644index 000000000..bb00f4a54--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/duplicate_tool_registration.https.html@@ -0,0 +1,33 @@+<!DOCTYPE html>+<html>+<head>+<title>WebMCP modelContext duplicate tool registration</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+</head>+<body>+<script>+promise_test(async t => {+ function empty() {+ return 'empty';+ }++ await document.modelContext.registerTool({+ name: 'empty',+ description: 'echo empty',+ execute: empty,+ });++ return promise_rejects_dom(t, 'InvalidStateError',+ document.modelContext.registerTool({+ name: 'empty',+ description: 'echo empty',+ execute: empty,+ }),+ 'duplicate tool registration is invalid.',+ );+}, 'duplicate tool registration is invalid.');+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-abort.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-abort.https.htmlnew file mode 100644index 000000000..cb074e462--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-abort.https.html@@ -0,0 +1,235 @@+<!DOCTYPE html>+<html>+<head>+<title>WebMCP executeTool AbortSignal basic behavior</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+</head>+<body>+<script>+promise_test(async t => {+ const regController = new AbortController();+ t.add_cleanup(() => regController.abort());++ let received_signal = null;+ await document.modelContext.registerTool({+ name: 'default_signal_tool',+ description: 'Test default signal',+ execute: async (input, options) => {+ received_signal = options.signal;+ return 'success';+ }+ }, { signal: regController.signal });++ const [tool] = await document.modelContext.getTools();+ const result = await document.modelContext.executeTool(tool);+ assert_equals(result, 'success');+ assert_true(received_signal instanceof AbortSignal, 'options.signal should be an AbortSignal instance');+ assert_false(received_signal.aborted, 'signal should not be aborted');+}, 'executeTool() provides a non-aborted default AbortSignal when called without options');++promise_test(async t => {+ const regController = new AbortController();+ t.add_cleanup(() => regController.abort());++ const events = [];++ const modelContextEvents = [];+ const {+ promise: modelContextToolActivatedPromise,+ resolve: resolveModelContextToolActivated+ } = Promise.withResolvers();+ const modelContextHandler = e => {+ assert_equals(e.toolName, 'abort_propagate_tool');+ events.push('toolactivated');+ modelContextEvents.push(e);+ resolveModelContextToolActivated();+ };+ document.modelContext.addEventListener('toolactivated', modelContextHandler);+ t.add_cleanup(() => document.modelContext.removeEventListener('toolactivated', modelContextHandler));++ const { promise: toolStartedPromise, resolve: resolveToolStarted } = Promise.withResolvers();+ const { promise: signalAbortPromise, resolve: resolveSignalAbort } = Promise.withResolvers();+ let targetSignalAbortReason = null;++ await document.modelContext.registerTool({+ name: 'abort_propagate_tool',+ description: 'Test abort propagation',+ execute: (input, options) => new Promise((resolve, reject) => {+ options.signal.onabort = () => {+ targetSignalAbortReason = options.signal.reason;+ events.push('signal_aborted');+ resolveSignalAbort();+ };+ events.push('tool started');+ resolveToolStarted();+ })+ }, { signal: regController.signal });++ const [tool] = await document.modelContext.getTools();++ const controller = new AbortController();+ const executionPromise = document.modelContext.executeTool(tool, {}, { signal: controller.signal });++ const modelContextCancelEvents = [];+ const {+ promise: modelContextToolCancelPromise,+ resolve: resolveModelContextToolCancel+ } = Promise.withResolvers();+ const modelContextCancelHandler = e => {+ assert_equals(e.toolName, 'abort_propagate_tool');+ events.push('toolcancel');+ modelContextCancelEvents.push(e);+ resolveModelContextToolCancel();+ };+ document.modelContext.addEventListener('toolcancel', modelContextCancelHandler);+ t.add_cleanup(() => document.modelContext.removeEventListener('toolcancel', modelContextCancelHandler));++ await toolStartedPromise;+ await modelContextToolActivatedPromise;++ assert_equals(modelContextEvents.length, 1);+ const modelContextEvent = modelContextEvents[0];+ assert_true(modelContextEvent instanceof ToolActivatedEvent,+ 'toolactivated dispatched at the ModelContext is a ToolActivatedEvent');+ assert_equals(modelContextEvent.toolName, 'abort_propagate_tool');+ assert_equals(modelContextEvent.target, document.modelContext);++ controller.abort('custom cancellation reason');++ let executionRejectionValue = null;+ await Promise.all([+ executionPromise.catch(e => { events.push('execution_rejected'); executionRejectionValue = e; }),+ signalAbortPromise,+ modelContextToolCancelPromise,+ ]);++ assert_array_equals(events, ['tool started', 'toolactivated', 'execution_rejected', 'signal_aborted', 'toolcancel']);+ assert_array_equals(modelContextEvents, [modelContextEvent], 'toolactivated is dispatched once per execution');++ assert_equals(modelContextCancelEvents.length, 1, 'toolcancel is dispatched once per execution');+ const modelContextCancelEvent = modelContextCancelEvents[0];+ assert_true(modelContextCancelEvent instanceof ToolCancelEvent,+ 'toolcancel dispatched at the ModelContext is a ToolCancelEvent');+ assert_equals(modelContextCancelEvent.toolName, 'abort_propagate_tool');+ assert_equals(modelContextCancelEvent.target, document.modelContext);++ assert_equals(executionRejectionValue, 'custom cancellation reason');+ assert_true(targetSignalAbortReason instanceof DOMException);+ assert_equals(targetSignalAbortReason.name, 'AbortError');+}, 'caller abort propagates to tool callback options.signal');++promise_test(async t => {+ const regController = new AbortController();+ t.add_cleanup(() => regController.abort());++ await document.modelContext.registerTool({+ name: 'already_aborted_tool',+ description: 'Test already aborted signal',+ execute: t.unreached_func('tool never executes'),+ }, { signal: regController.signal });++ const [tool] = await document.modelContext.getTools();+ const signal = AbortSignal.abort('already aborted');+ let executionRejectionValue = null;+ document.modelContext.executeTool(tool, {}, { signal }).catch(e => executionRejectionValue = e);++ // Await a Promise that resolved synchronously, so that we guarantee that in+ // the next microtask, `execute_promise` has already rejected. This asserts+ // that the timing of the execution rejection is synchronous, and never goes+ // "in parallel".+ await Promise.resolve();+ assert_equals(executionRejectionValue, 'already aborted');+}, 'executeTool() with already-aborted tool synchronously rejects');++promise_test(async t => {+ const regController = new AbortController();+ t.add_cleanup(() => regController.abort());++ const { promise: toolExecutePromise, resolve: resolveToolExecute } = Promise.withResolvers();++ await document.modelContext.registerTool({+ name: 'async_resolve_after_abort_tool',+ description: 'Test resolving promise after abort',+ execute: (input, options) => {+ options.signal.onabort = () => {+ resolveToolExecute('late resolved value');+ };+ return toolExecutePromise;+ }+ }, { signal: regController.signal });++ const [tool] = await document.modelContext.getTools();+ const controller = new AbortController();+ const executePromise =+ document.modelContext.executeTool(tool, {}, { signal: controller.signal });++ // By the time this `abort()` is processed, the tool will have already started+ // running and the abort handler will have already been registered.+ controller.abort();+ await promise_rejects_dom(t, 'AbortError', executePromise,+ 'Promise must reject with AbortError even if tool callback resolves');++ // For good measure, just await what happens when the tool tries to resolve a+ // value *after* it has been aborted, to make sure there are no tricky+ // lifetime bugs/crashes when tool resolution is happened after abort.+ const lateResult = await toolExecutePromise;+ assert_equals(lateResult, 'late resolved value');+}, 'executeTool() promise remains rejected even if tool callback resolves after abort');++promise_test(async t => {+ const regController = new AbortController();+ t.add_cleanup(() => regController.abort());++ const signals = [];+ const { promise: exec1Started, resolve: resolveExec1Started } = Promise.withResolvers();+ const { promise: exec2Started, resolve: resolveExec2Started } = Promise.withResolvers();+ const { promise: signal1Aborted, resolve: resolveSignal1Aborted } = Promise.withResolvers();+ const { promise: exec2Complete, resolve: resolveExec2Complete } = Promise.withResolvers();++ let execCount = 0;+ await document.modelContext.registerTool({+ name: 'concurrent_tool',+ description: 'Test concurrent executions',+ execute: (input, options) => {+ execCount++;+ signals.push(options.signal);+ if (execCount === 1) {+ options.signal.onabort = resolveSignal1Aborted;+ resolveExec1Started();+ // The first execution hangs forever, since we abort it mid-execution.+ return new Promise(() => {});+ } else {+ resolveExec2Started();+ // The second execution resolves without being aborted, later in the+ // test.+ return exec2Complete;+ }+ }+ }, { signal: regController.signal });++ const [tool] = await document.modelContext.getTools();++ const c1 = new AbortController();+ const c2 = new AbortController();++ const execPromise1 = document.modelContext.executeTool(tool, {}, { signal: c1.signal });+ const execPromise2 = document.modelContext.executeTool(tool, {}, { signal: c2.signal });++ await Promise.all([exec1Started, exec2Started]);++ c1.abort('cancel 1');++ await promise_rejects_exactly(t, 'cancel 1', execPromise1);+ await signal1Aborted;++ assert_true(signals[0].aborted, 'execution 1 signal should be aborted');+ assert_false(signals[1].aborted, 'execution 2 signal should not be aborted');++ resolveExec2Complete('exec2 result');+ assert_equals(await execPromise2, 'exec2 result');+}, 'concurrent executions of the same tool have independent AbortSignals');+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-across-trees.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-across-trees.https.htmlnew file mode 100644index 000000000..633e6fe69--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-across-trees.https.html@@ -0,0 +1,38 @@+<!DOCTYPE html>+<html>+<head>+<title>WebMCP executeTool across trees</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+</head>+<body>+<script>+promise_test(async t => {+ const windowB = window.open('/common/blank.html', '_blank');+ t.add_cleanup(() => windowB.close());++ // Wait for window B to load.+ await new Promise(resolve => {+ windowB.onload = resolve;+ });++ // Register tool directly in window B.+ await windowB.document.modelContext.registerTool({+ name: 'target_tool',+ description: 'Target tool in other window',+ execute: async () => 'test'+ });++ const tools = await document.modelContext.getTools();+ assert_array_equals(tools, [], "We do not see the other document's tool");++ const [tool] = await windowB.document.modelContext.getTools();+ assert_equals(tool.window, windowB);+ const execute_promise = document.modelContext.executeTool(tool);++ await promise_rejects_dom(t, 'UnknownError', execute_promise);+}, 'executeTool() rejects when the tool is hosted in another frame tree');+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-caller-navigate-abort.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-caller-navigate-abort.https.htmlnew file mode 100644index 000000000..08ee86a56--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-caller-navigate-abort.https.html@@ -0,0 +1,91 @@+<!DOCTYPE html>+<html>+<head>+<title>WebMCP executeTool with Caller Navigation (Abort)</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script src="/common/get-host-info.sub.js"></script>+<script src="resources/helpers.js"></script>+</head>+<body>+<script>+function timeout_promise(t, msg) {+ return new Promise((_, reject) => {+ t.step_timeout(() => reject(msg), 3000);+ });+}++const child_origins = [self.origin, get_host_info().HTTPS_REMOTE_ORIGIN];+for (const origin of child_origins) {+ run_test(origin);+}++function run_test(origin) {+ const origin_for_description =+ origin === self.origin ? 'same-origin' : 'cross-origin';++ promise_test(async t => {+ const iframe = document.createElement('iframe');+ iframe.src = origin + '/webmcp/imperative/resources/iframe-caller.html';+ iframe.allow = `tools ${origin}`;++ const load_promise = new Promise(resolve => iframe.onload = resolve);+ document.body.appendChild(iframe);+ t.add_cleanup(() => iframe.remove());+ await load_promise;++ let resolve_tool_started;+ const tool_started_promise =+ new Promise(resolve => { resolve_tool_started = resolve; });++ let resolve_signal_aborted, reject_signal_aborted;+ const signal_aborted_promise = new Promise((resolve, reject) => {+ resolve_signal_aborted = resolve;+ reject_signal_aborted = reject;+ });++ const controller = new AbortController();+ await document.modelContext.registerTool({+ name: 'parent_tool',+ description: 'Parent tool',+ execute: async (input, opts) => {+ resolve_tool_started();++ // If an `AbortSignal` is not passed into the `execute()` callback, reject+ // `signal_aborted_promise`.+ if (!opts || !opts.signal) {+ reject_signal_aborted('signal not provided to execute()');+ return;+ }++ opts.signal.onabort = resolve_signal_aborted;++ // The parent's tool runs "forever", waiting for the signal to abort.+ await new Promise(() => {});+ }+ }, { exposedTo: [origin], signal: controller.signal });+ t.add_cleanup(() => controller.abort());++ iframe.contentWindow.postMessage(+ {+ action: 'invoke',+ name: 'parent_tool',+ options: {fromOrigins: [self.origin]}+ },+ '*');+ await Promise.race([tool_started_promise, timeout_promise(t, 'tool never ran')]);++ // The iframe navigates away before the tool has finished executing. Instead+ // of navigating the iframe with its `src` attribute, we request it initiate+ // its own navigation, just so if the `signal` above aborts, we're sure that+ // it's not incidentally aborting due to any bookkeeping `this` Window is+ // doing regarding navigations and tool executions.+ iframe.contentWindow.postMessage({action: 'navigate'}, '*');++ await Promise.race([signal_aborted_promise, timeout_promise(t, 'signal never aborted')]);+ }, `executeTool() aborts target signal when the invoker document (${origin_for_description}) navigates away`);+}+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-detach-toolactivated.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-detach-toolactivated.https.htmlnew file mode 100644index 000000000..f804483d3--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-detach-toolactivated.https.html@@ -0,0 +1,88 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>WebMCP: toolactivated is not dispatched when an imperative tool detaches its document</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>++<body>+<script>+async function createSameOriginIframe(t) {+ const iframe = document.createElement('iframe');+ iframe.src = '/common/blank.html';+ const loadPromise = new Promise(resolve => iframe.onload = resolve);+ document.body.appendChild(iframe);+ t.add_cleanup(() => iframe.remove());+ await loadPromise;+ return iframe;+}++promise_test(async t => {+ const iframe = await createSameOriginIframe(t);+ const iframeModelContext = iframe.contentDocument.modelContext;++ // The `execute` callback lives in this (parent) realm, which stays alive+ // after the iframe is detached.+ await iframeModelContext.registerTool({+ name: 'detaching_tool',+ description: 'Tool that detaches its own document',+ execute: () => {+ iframe.remove();+ return 'result';+ },+ });++ // The listener is also from this (parent) realm, so it could still be+ // invoked if the event were dispatched at the detached document.+ const events = [];+ iframeModelContext.addEventListener('toolactivated', e => events.push(e));++ const tools = await document.modelContext.getTools();+ const tool = tools.find(tool => tool.name === 'detaching_tool');+ assert_true(!!tool, '"detaching_tool" is visible to the parent document');++ await promise_rejects_dom(t, 'UnknownError',+ document.modelContext.executeTool(tool, {}));++ assert_false(iframe.isConnected, 'the iframe is detached');+ assert_array_equals(events, [],+ 'toolactivated is not dispatched at the detached document ModelContext');+}, 'toolactivated is not dispatched when a tool execute callback from ' ++ 'another realm detaches the tool document');++promise_test(async t => {+ const iframe = await createSameOriginIframe(t);+ const iframeWindow = iframe.contentWindow;+ const iframeModelContext = iframe.contentDocument.modelContext;++ // The `execute` callback lives in the iframe realm, and detaches its own+ // frame.+ await iframeModelContext.registerTool({+ name: 'self_detaching_tool',+ description: 'Tool that detaches its own document from its own realm',+ execute: new iframeWindow.Function(+ 'window.frameElement.remove(); return "result";'),+ });++ // One listener from this (parent) realm and one from the iframe realm.+ const events = [];+ iframeModelContext.addEventListener('toolactivated', e => events.push(e));+ iframeWindow.toolActivatedEvents = [];+ iframeModelContext.addEventListener('toolactivated',+ new iframeWindow.Function('e', 'window.toolActivatedEvents.push(e);'));++ const tools = await document.modelContext.getTools();+ const tool = tools.find(tool => tool.name === 'self_detaching_tool');+ assert_true(!!tool, '"self_detaching_tool" is visible to the parent document');++ await promise_rejects_dom(t, 'UnknownError',+ document.modelContext.executeTool(tool, {}));++ assert_false(iframe.isConnected, 'the iframe is detached');+ assert_array_equals(events, [],+ 'toolactivated is not dispatched to listeners from the parent realm');+ assert_array_equals(iframeWindow.toolActivatedEvents, [],+ 'toolactivated is not dispatched to listeners from the iframe realm');+}, 'toolactivated is not dispatched when a tool execute callback detaches ' ++ 'its own document');+</script>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-detach-toolcancel.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-detach-toolcancel.https.htmlnew file mode 100644index 000000000..0a6c05e35--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-detach-toolcancel.https.html@@ -0,0 +1,99 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>WebMCP: toolcancel is not dispatched when an imperative tool detaches its document on abort</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>++<body>+<script>+async function createSameOriginIframe(t) {+ const iframe = document.createElement('iframe');+ iframe.src = '/common/blank.html';+ const loadPromise = new Promise(resolve => iframe.onload = resolve);+ document.body.appendChild(iframe);+ t.add_cleanup(() => iframe.remove());+ await loadPromise;+ return iframe;+}++promise_test(async t => {+ const iframe = await createSameOriginIframe(t);+ const iframeModelContext = iframe.contentDocument.modelContext;++ // The `execute` callback lives in this (parent) realm, which stays alive+ // after the iframe is detached.+ await iframeModelContext.registerTool({+ name: 'detaching_tool',+ description: 'Tool that detaches its own document when aborted',+ execute: (input, { signal }) => {+ signal.addEventListener('abort', () => iframe.remove());+ return new Promise(() => {});+ },+ });++ // The listener is also from this (parent) realm, so it could still be+ // invoked if the event were dispatched at the detached document.+ const events = [];+ iframeModelContext.addEventListener('toolcancel', e => events.push(e));++ const tools = await document.modelContext.getTools();+ const tool = tools.find(tool => tool.name === 'detaching_tool');+ assert_true(!!tool, '"detaching_tool" is visible to the parent document');++ const controller = new AbortController();+ const execPromise = document.modelContext.executeTool(+ tool, {}, { signal: controller.signal });+ const rejectPromise = promise_rejects_dom(t, 'AbortError', execPromise);+ controller.abort();+ await rejectPromise;++ await t.step_wait(() => !iframe.isConnected, 'the iframe is detached');+ assert_array_equals(events, [],+ 'toolcancel is not dispatched at the detached document ModelContext');+}, 'toolcancel is not dispatched when a tool abort handler from another ' ++ 'realm detaches the tool document');++promise_test(async t => {+ const iframe = await createSameOriginIframe(t);+ const iframeWindow = iframe.contentWindow;+ const iframeModelContext = iframe.contentDocument.modelContext;++ // The `execute` callback lives in the iframe realm, and detaches its own+ // frame when aborted.+ await iframeModelContext.registerTool({+ name: 'self_detaching_tool',+ description: 'Tool that detaches its own document from its own realm ' ++ 'when aborted',+ execute: new iframeWindow.Function('input', 'options', `+ options.signal.addEventListener('abort',+ () => window.frameElement.remove());+ return new Promise(() => {});`),+ });++ // One listener from this (parent) realm and one from the iframe realm.+ const events = [];+ iframeModelContext.addEventListener('toolcancel', e => events.push(e));+ iframeWindow.toolCancelEvents = [];+ iframeModelContext.addEventListener('toolcancel',+ new iframeWindow.Function('e', 'window.toolCancelEvents.push(e);'));++ const tools = await document.modelContext.getTools();+ const tool = tools.find(tool => tool.name === 'self_detaching_tool');+ assert_true(!!tool, '"self_detaching_tool" is visible to the parent document');++ const controller = new AbortController();+ const execPromise = document.modelContext.executeTool(+ tool, {}, { signal: controller.signal });+ const rejectPromise = promise_rejects_dom(t, 'AbortError', execPromise);+ controller.abort();+ await rejectPromise;++ await t.step_wait(() => !iframe.isConnected, 'the iframe is detached');+ assert_array_equals(events, [],+ 'toolcancel is not dispatched to listeners from the parent realm');+ assert_array_equals(iframeWindow.toolCancelEvents, [],+ 'toolcancel is not dispatched to listeners from the iframe realm');+}, 'toolcancel is not dispatched when a tool abort handler detaches its own ' ++ 'document');+</script>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-error-window-onerror.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-error-window-onerror.https.htmlnew file mode 100644index 000000000..4bd1282a9--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-error-window-onerror.https.html@@ -0,0 +1,76 @@+<!DOCTYPE html>+<html>+<head>+<title>WebMCP failed tool execution does not fire window.onerror</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+</head>+<body>+<script>+promise_test(async t => {+ let errorFired = false;+ const errorHandler = () => {+ errorFired = true;+ };+ window.addEventListener('error', errorHandler);+ t.add_cleanup(() => {+ window.removeEventListener('error', errorHandler);+ });++ // Register a tool that throws an error when executed.+ await document.modelContext.registerTool({+ name: 'throwing_tool',+ description: 'A tool that throws an error',+ execute: async () => {+ throw new Error('Tool execution failed intentionally');+ }+ });++ const tools = await document.modelContext.getTools();+ const tool = tools.find(t => t.name === 'throwing_tool');+ assert_true(!!tool, 'Should find the registered tool');++ // `executeTool()` should reject since the tool execution failed.+ await promise_rejects_dom(t, 'UnknownError',+ document.modelContext.executeTool(tool),+ 'executeTool() rejects when the tool execution throws');++ assert_false(errorFired, 'window.onerror/error event should not be fired');+}, 'Failed tool execution does not trigger window.onerror');++promise_test(async t => {+ let errorFired = false;+ const errorHandler = () => {+ errorFired = true;+ };+ window.addEventListener('error', errorHandler);+ t.add_cleanup(() => {+ window.removeEventListener('error', errorHandler);+ });++ // Register a tool that returns a circular object when executed.+ await document.modelContext.registerTool({+ name: 'circular_tool',+ description: 'A tool that returns a circular object',+ execute: () => {+ let a = {};+ a['a'] = a;+ return a;+ }+ });++ const tools = await document.modelContext.getTools();+ const tool = tools.find(t => t.name === 'circular_tool');+ assert_true(!!tool, 'Should find the registered tool');++ // `executeTool()` should reject since serializing the return value throws a TypeError.+ await promise_rejects_dom(t, 'UnknownError',+ document.modelContext.executeTool(tool),+ 'executeTool() rejects when the tool execution returns a circular object');++ assert_false(errorFired, 'window.onerror/error event should not be fired');+}, 'Tool execution returning circular object rejects and does not trigger window.onerror');+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-events.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-events.https.htmlnew file mode 100644index 000000000..0b9011108--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-events.https.html@@ -0,0 +1,153 @@+<!DOCTYPE html>+<meta charset="utf-8">+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script src="/webmcp/resources/helpers.js"></script>++<script>+promise_test(async t => {+ const modelContextEvents = [];+ const modelContextHandler = e => modelContextEvents.push(e);+ document.modelContext.addEventListener('toolactivated', modelContextHandler);+ document.modelContext.addEventListener('toolcancel', modelContextHandler);+ t.add_cleanup(() => {+ document.modelContext.removeEventListener('toolactivated', modelContextHandler);+ document.modelContext.removeEventListener('toolcancel', modelContextHandler);+ });++ const activatedPromise = new Promise(resolve => {+ document.modelContext.addEventListener('toolactivated', resolve, { once: true });+ });+ const cancelPromise = new Promise(resolve => {+ document.modelContext.addEventListener('toolcancel', resolve, { once: true });+ });++ const regController = new AbortController();+ t.add_cleanup(() => regController.abort());++ await document.modelContext.registerTool({+ name: 'slow',+ description: 'slow tool',+ execute: () => new Promise(() => {}),+ }, { signal: regController.signal });++ const [tool] = await document.modelContext.getTools();++ const controller = new AbortController();+ const execPromise = document.modelContext.executeTool(tool, {}, { signal: controller.signal });++ await activatedPromise;+ assert_equals(modelContextEvents.length, 1);++ // The event dispatched at the ModelContext is a `ToolActivatedEvent`.+ const activatedEvent = modelContextEvents[0];+ assert_true(activatedEvent instanceof ToolActivatedEvent, 'event is a ToolActivatedEvent');+ assert_equals(activatedEvent.type, 'toolactivated');+ assert_equals(activatedEvent.toolName, 'slow');+ assert_equals(activatedEvent.target, document.modelContext, 'event is targeted at the ModelContext');+ assert_false(activatedEvent.bubbles, 'event does not bubble');+ assert_false(activatedEvent.cancelable, 'event is not cancelable');+ assert_false(activatedEvent.composed, 'event is not composed');+ assert_true(activatedEvent.isTrusted, 'event is trusted');++ const rejectPromise = promise_rejects_dom(t, 'AbortError', execPromise);+ controller.abort();+ await cancelPromise;+ await rejectPromise;++ assert_equals(modelContextEvents.length, 2);++ // The event dispatched at the ModelContext is a `ToolCancelEvent`.+ const cancelEvent = modelContextEvents[1];+ assert_true(cancelEvent instanceof ToolCancelEvent, 'event is a ToolCancelEvent');+ assert_equals(cancelEvent.type, 'toolcancel');+ assert_equals(cancelEvent.toolName, 'slow');+ assert_equals(cancelEvent.target, document.modelContext, 'event is targeted at the ModelContext');+ assert_false(cancelEvent.bubbles, 'event does not bubble');+ assert_false(cancelEvent.cancelable, 'event is not cancelable');+ assert_false(cancelEvent.composed, 'event is not composed');+ assert_true(cancelEvent.isTrusted, 'event is trusted');++ assert_array_equals(modelContextEvents, [activatedEvent, cancelEvent],+ 'toolactivated and toolcancel are each dispatched once per execution');+}, 'toolactivated and toolcancel events are dispatched on document.modelContext during tool execution and cancellation');++promise_test(async t => {+ const iframe = document.createElement('iframe');+ iframe.src = '/common/blank.html';+ document.body.appendChild(iframe);+ t.add_cleanup(() => iframe.remove());+ await new Promise(resolve => iframe.onload = resolve);++ const iframeModelContext = iframe.contentDocument.modelContext;+ await iframeModelContext.registerTool({+ name: 'iframe_tool',+ description: 'Tool registered in a same-origin child document',+ execute: () => 'iframe result',+ });++ const callerEvents = [];+ const callerHandler = e => callerEvents.push(e.toolName);+ document.modelContext.addEventListener('toolactivated', callerHandler);+ t.add_cleanup(() => document.modelContext.removeEventListener('toolactivated', callerHandler));++ const targetEvents = [];+ iframeModelContext.addEventListener('toolactivated', e => targetEvents.push(e.toolName));++ const tools = await document.modelContext.getTools();+ const tool = tools.find(tool => tool.name === 'iframe_tool');+ assert_true(!!tool, '"iframe_tool" is visible to the parent document');++ assert_equals(await document.modelContext.executeTool(tool, {}), 'iframe result');++ assert_array_equals(targetEvents, ['iframe_tool'],+ 'toolactivated is dispatched at the ModelContext of the document hosting the tool');+ assert_array_equals(callerEvents, [],+ 'toolactivated is not dispatched at the caller document ModelContext');+}, 'toolactivated is dispatched at the ModelContext of the tool target document');++promise_test(async t => {+ const iframe = document.createElement('iframe');+ iframe.src = '/common/blank.html';+ document.body.appendChild(iframe);+ t.add_cleanup(() => iframe.remove());+ await new Promise(resolve => iframe.onload = resolve);++ const iframeModelContext = iframe.contentDocument.modelContext;+ await iframeModelContext.registerTool({+ name: 'iframe_slow_tool',+ description: 'Slow tool registered in a same-origin child document',+ execute: () => new Promise(() => {}),+ });++ const callerEvents = [];+ const callerHandler = e => callerEvents.push(e.toolName);+ document.modelContext.addEventListener('toolcancel', callerHandler);+ t.add_cleanup(() => document.modelContext.removeEventListener('toolcancel', callerHandler));++ const targetEvents = [];+ const targetCancelPromise = new Promise(resolve => {+ iframeModelContext.addEventListener('toolcancel', e => {+ targetEvents.push(e.toolName);+ resolve();+ });+ });++ const tools = await document.modelContext.getTools();+ const tool = tools.find(tool => tool.name === 'iframe_slow_tool');+ assert_true(!!tool, '"iframe_slow_tool" is visible to the parent document');++ const controller = new AbortController();+ const execPromise = document.modelContext.executeTool(tool, {}, { signal: controller.signal });+ const rejectPromise = promise_rejects_dom(t, 'AbortError', execPromise);+ controller.abort();+ await targetCancelPromise;+ await rejectPromise;++ assert_array_equals(targetEvents, ['iframe_slow_tool'],+ 'toolcancel is dispatched at the ModelContext of the document hosting the tool');+ assert_array_equals(callerEvents, [],+ 'toolcancel is not dispatched at the caller document ModelContext');+}, 'toolcancel is dispatched at the ModelContext of the tool target document');+</script>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-invalid-dictionary.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-invalid-dictionary.https.htmlnew file mode 100644index 000000000..713d0af31--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-invalid-dictionary.https.html@@ -0,0 +1,94 @@+<!DOCTYPE html>+<html>+<head>+<title>WebMCP: executeTool dictionary member validation checks</title>+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+</head>+<body>+<script>+promise_test(async t => {+ // Register a legitimate tool first to retrieve a valid template.+ await document.modelContext.registerTool({+ name: "legit_tool",+ description: "Legitimate tool description",+ execute: async (args) => "success"+ });++ const tools = await document.modelContext.getTools();+ const legit = tools.find(t => t.name === "legit_tool");+ assert_true(!!legit, "Legitimate tool must be successfully discovered");++ // Construct a dictionary containing all required members except the required 'origin' member.+ const invalidTool = {+ name: legit.name,+ description: legit.description,+ window: legit.window+ // 'origin' is intentionally omitted!+ };++ // Invoking executeTool() must return a Promise rejected with TypeError.+ await promise_rejects_js(+ t,+ TypeError,+ document.modelContext.executeTool(invalidTool),+ "executeTool() must reject with TypeError if 'origin' member is omitted"+ );+}, "executeTool() rejects with TypeError when the required 'origin' dictionary member is omitted");++promise_test(async t => {+ await document.modelContext.registerTool({+ name: "json-test-tool",+ description: "Tool for JSON tests",+ execute: async (args) => "success"+ });++ const tools = await document.modelContext.getTools();+ const tool = tools.find(t => t.name === "json-test-tool");+ assert_true(!!tool, "Legitimate tool must be successfully discovered");++ const circularObject = {};+ circularObject.self = circularObject;+ await promise_rejects_js(+ t,+ TypeError,+ document.modelContext.executeTool(tool, circularObject),+ "executeTool() must reject with TypeError for circular JSON input"+ );++ const undefinedToJSON = {+ toJSON: () => undefined+ };+ await promise_rejects_js(+ t,+ TypeError,+ document.modelContext.executeTool(tool, undefinedToJSON),+ "executeTool() must reject with TypeError when toJSON returns undefined"+ );++ await promise_rejects_js(+ t,+ TypeError,+ document.modelContext.executeTool(tool, BigInt(42)),+ "executeTool() must reject with TypeError for non-serializable types JSON input"+ );+}, "executeTool() rejects with TypeError for invalid JSON arguments");++promise_test(async t => {+ const dummyTool = {+ name: "non-existent-tool",+ description: "dummy description",+ window: window,+ origin: self.origin+ };++ await promise_rejects_dom(+ t,+ "UnknownError",+ document.modelContext.executeTool(dummyTool),+ "executeTool() must reject with UnknownError for non-existent tool object"+ );+}, "executeTool() rejects with UnknownError when a non-existent tool object is supplied");+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-same-document-navigation-crash.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-same-document-navigation-crash.https.htmlnew file mode 100644index 000000000..de8afbdb9--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-same-document-navigation-crash.https.html@@ -0,0 +1,26 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>WebMCP executeTool where caller == target document navigation crash test</title>++<script>+window.onload = async () => {+ const iframe = document.createElement("iframe");+ iframe.src = "resources/iframe-caller-and-target-crash.html";+ iframe.allow = "tools *";++ const tool_started_promise = new Promise(resolve => {+ window.addEventListener("message", e => {+ if (e.data && e.data.action === "tool_started") resolve();+ }, {once: true});+ });++ document.body.appendChild(iframe);+ await tool_started_promise;++ const nav_promise = new Promise(resolve => iframe.onload = resolve);+ // Navigate the iframe away during its pending tool execution. In Chromium,+ // this used to crash the browser process.+ iframe.src = "/common/blank.html";+ await nav_promise;+};+</script>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-signal-cross-origin.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-signal-cross-origin.https.htmlnew file mode 100644index 000000000..842573154--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-signal-cross-origin.https.html@@ -0,0 +1,124 @@+<!DOCTYPE html>+<html>+<head>+<title>WebMCP executeTool AbortSignal Cross-Origin routing</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script src="/common/get-host-info.sub.js"></script>+<script src="resources/helpers.js"></script>+</head>+<body>+<script>+const host_info = get_host_info();++promise_test(async t => {+ const iframe = document.createElement('iframe');+ iframe.src = `${host_info.HTTPS_REMOTE_ORIGIN}/webmcp/imperative/resources/iframe-register-tool.html`;+ iframe.allow = 'tools *';++ const load_promise = new Promise(resolve => iframe.onload = resolve);+ document.body.appendChild(iframe);+ t.add_cleanup(() => iframe.remove());+ await load_promise;++ const toolchange_promise = new Promise(resolve => {+ document.modelContext.addEventListener('toolchange', resolve, { once: true });+ });++ iframe.contentWindow.postMessage({+ action: 'register',+ tool: {+ name: 'cross_origin_iframe_tool',+ description: 'Cross origin tool in iframe'+ },+ options: { exposedTo: [self.origin] },+ hangsForeverAndReportsAbort: true+ }, '*');++ await toolchange_promise;++ const tools = await document.modelContext.getTools(+ {fromOrigins: [host_info.HTTPS_REMOTE_ORIGIN]});+ const tool = tools.find(t => t.name === 'cross_origin_iframe_tool');+ assert_true(!!tool, 'Tool should be registered and visible to parent');++ let resolve_tool_started;+ const tool_started = new Promise(r => resolve_tool_started = r);++ let resolve_abort_reported;+ const abort_reported = new Promise(r => resolve_abort_reported = r);++ const message_handler = e => {+ if (e.data && e.data.action === 'tool_started') {+ resolve_tool_started();+ } else if (e.data && e.data.action === 'signal_aborted_result') {+ resolve_abort_reported(e.data);+ }+ };+ window.addEventListener('message', message_handler);+ t.add_cleanup(() => window.removeEventListener('message', message_handler));++ const controller = new AbortController();+ const execute_promise = document.modelContext.executeTool(tool, {}, { signal: controller.signal });++ await tool_started;+ controller.abort('parent cross-origin abort reason');++ await promise_rejects_exactly(t, 'parent cross-origin abort reason', execute_promise);+ const report = await abort_reported;+ assert_equals(report.error, undefined, 'signal should have been provided to iframe tool');+ assert_true(report.reason.includes('AbortError'), 'abort signal should fire in cross-origin iframe tool');+}, 'caller abort in parent document propagates to options.signal in cross-origin iframe tool');++promise_test(async t => {+ let parent_signal_aborted = false;+ let parent_abort_reason = null;+ let resolve_parent_started;+ const parent_started = new Promise(r => resolve_parent_started = r);++ await document.modelContext.registerTool({+ name: 'parent_target_tool',+ description: 'Parent target tool',+ execute: (input, options) => new Promise((resolve) => {+ resolve_parent_started();+ if (options && options.signal) {+ options.signal.addEventListener('abort', () => {+ parent_signal_aborted = true;+ parent_abort_reason = options.signal.reason;+ resolve('aborted');+ });+ }+ })+ }, { exposedTo: [host_info.HTTPS_REMOTE_ORIGIN] });++ const iframe = document.createElement('iframe');+ iframe.src = `${host_info.HTTPS_REMOTE_ORIGIN}/webmcp/imperative/resources/iframe-caller.html`;+ iframe.allow = 'tools *';++ const load_promise = new Promise(resolve => iframe.onload = resolve);+ document.body.appendChild(iframe);+ t.add_cleanup(() => iframe.remove());+ await load_promise;++ iframe.contentWindow.postMessage({+ action: 'invoke_with_abort',+ name: 'parent_target_tool',+ options: { fromOrigins: [self.origin] },+ abortDelayMs: 50,+ abortReason: 'iframe cross-origin abort reason'+ }, '*');++ await parent_started;++ // Wait for the abort to propagate from the iframe to the parent tool+ while (!parent_signal_aborted) {+ await new Promise(r => t.step_timeout(r, 20));+ }++ assert_true(parent_signal_aborted, 'parent tool options.signal should be aborted by cross-origin iframe caller');+ assert_equals(parent_abort_reason.name, 'AbortError', 'abort reason should route from cross-origin iframe caller as AbortError');+}, 'caller abort in cross-origin iframe propagates to options.signal in parent document tool');+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-target-detachment.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-target-detachment.https.htmlnew file mode 100644index 000000000..2278faa5e--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-target-detachment.https.html@@ -0,0 +1,199 @@+<!DOCTYPE html>+<html>+<head>+<title>WebMCP executeTool with Target Frame Detachment</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script src="/common/get-host-info.sub.js"></script>+</head>+<body>+<script>+const host_info = get_host_info();++promise_test(async t => {+ const iframe = document.createElement('iframe');+ iframe.src = host_info.HTTPS_REMOTE_ORIGIN + '/webmcp/imperative/resources/iframe-register-tool.html';+ iframe.allow = 'tools *';++ const load_promise = new Promise(resolve => iframe.onload = resolve);+ document.body.appendChild(iframe);+ t.add_cleanup(() => iframe.remove());+ await load_promise;++ const toolchange_promise = new Promise(resolve => {+ document.modelContext.addEventListener('toolchange', resolve, { once: true });+ });++ // Have the iframe register a tool (it will never execute though).+ iframe.contentWindow.postMessage({+ action: 'register',+ tool: {+ name: 'iframe_tool',+ description: 'Iframe tool description'+ },+ options: {+ exposedTo: [self.origin]+ }+ }, '*');++ await toolchange_promise;++ const tools = await document.modelContext.getTools(+ {fromOrigins: [host_info.HTTPS_REMOTE_ORIGIN]});+ const tool = tools.find(t => t.name === 'iframe_tool');+ assert_true(!!tool, 'Tool should be retrieved successfully');++ // Detach the frame before executing the tool.+ iframe.remove();++ // Calling executeTool() on the detached tool will internally fail to locate+ // the frame, and thus reject the caller's Promise.+ //+ // TODO(https://crbug.com/509555636): It should probably reject with a `NotFoundError`.+ await promise_rejects_dom(+ t,+ 'InvalidStateError',+ document.modelContext.executeTool(tool),+ 'Promise should be rejected with InvalidStateError when target frame is detached before execution'+ );+}, 'executeTool() rejects when target frame is detached before execution');++promise_test(async t => {+ const iframe = document.createElement('iframe');+ iframe.src = host_info.HTTPS_REMOTE_ORIGIN + '/webmcp/imperative/resources/iframe-register-tool.html';+ iframe.allow = 'tools *';++ const load_promise = new Promise(resolve => iframe.onload = resolve);+ document.body.appendChild(iframe);+ t.add_cleanup(() => iframe.remove());+ await load_promise;++ const toolchange_promise = new Promise(resolve => {+ document.modelContext.addEventListener('toolchange', resolve, { once: true });+ });++ // The iframe tool hangs forever, because it must be executing *while* we+ // detach the iframe.+ iframe.contentWindow.postMessage({+ action: 'register',+ hangsForever: true,+ tool: {+ name: 'iframe_tool_hanging',+ description: 'Iframe tool description'+ },+ options: {+ exposedTo: [self.origin]+ }+ }, '*');++ await toolchange_promise;++ const tools = await document.modelContext.getTools(+ {fromOrigins: [host_info.HTTPS_REMOTE_ORIGIN]});+ const tool = tools.find(t => t.name === 'iframe_tool_hanging');+ assert_true(!!tool, 'Tool should be retrieved successfully');++ // Execute the tool (hangs forever).+ const execute_promise = document.modelContext.executeTool(tool);++ iframe.remove();++ // The execute promise rejects because the target document died+ // mid-execution. See the bug referenced from the above test, about making+ // the reason more specific.+ await promise_rejects_dom(+ t,+ 'UnknownError',+ execute_promise,+ 'Promise should be rejected with UnknownError when target frame is detached mid-execution'+ );+}, 'executeTool() rejects when target frame is detached mid-execution');++promise_test(async t => {+ const iframe = document.createElement('iframe');+ iframe.src = '/common/blank.html';+ iframe.allow = 'tools *';++ const load_promise = new Promise(resolve => iframe.onload = resolve);+ document.body.appendChild(iframe);+ t.add_cleanup(() => iframe.remove());+ await load_promise;++ const toolchange_promise = new Promise(resolve => {+ document.modelContext.addEventListener('toolchange', resolve, { once: true });+ });++ await iframe.contentWindow.document.modelContext.registerTool({+ name: 'sync_detach_on_execute',+ description: 'Synchronously detaches its own frame during execute()',+ execute: () => {+ iframe.remove();+ return new Promise(() => {});+ }+ });++ await toolchange_promise;++ const tools = await document.modelContext.getTools();+ const tool = tools.find(t => t.name === 'sync_detach_on_execute');+ assert_true(!!tool, 'Tool should be retrieved successfully');++ await promise_rejects_dom(+ t,+ 'UnknownError',+ document.modelContext.executeTool(tool),+ 'Promise should reject when target frame synchronously detaches itself during execute()'+ );+}, 'executeTool() rejects cleanly when tool callback synchronously detaches its own frame');++promise_test(async t => {+ const iframe = document.createElement('iframe');+ iframe.src = '/common/blank.html';+ iframe.allow = 'tools *';++ const load_promise = new Promise(resolve => iframe.onload = resolve);+ document.body.appendChild(iframe);+ t.add_cleanup(() => iframe.remove());+ await load_promise;++ const toolchange_promise = new Promise(resolve => {+ document.modelContext.addEventListener('toolchange', resolve, { once: true });+ });++ const { promise: toolStarted, resolve: resolveToolStarted } = Promise.withResolvers();+ await iframe.contentWindow.document.modelContext.registerTool({+ name: 'sync_detach_on_abort',+ description: 'Synchronously detaches its own frame when options.signal aborts',+ execute: (input, options) => {+ options.signal.addEventListener('abort', () => {+ iframe.remove();+ });+ resolveToolStarted();+ return new Promise(() => {});+ }+ });++ await toolchange_promise;++ const tools = await document.modelContext.getTools();+ const tool = tools.find(t => t.name === 'sync_detach_on_abort');+ assert_true(!!tool, 'Tool should be retrieved successfully');++ const controller = new AbortController();+ const execute_promise = document.modelContext.executeTool(+ tool, {}, { signal: controller.signal });++ await toolStarted;+ controller.abort('abort and detach');++ await promise_rejects_exactly(+ t,+ 'abort and detach',+ execute_promise,+ 'Promise should reject with abort reason when options.signal abort handler detaches frame'+ );+}, 'executeTool() abort cleanly handles synchronous frame detachment inside options.signal abort listener');+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-target-navigation.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-target-navigation.https.htmlnew file mode 100644index 000000000..e9916447a--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-target-navigation.https.html@@ -0,0 +1,52 @@+<!DOCTYPE html>+<html>+<head>+<title>WebMCP executeTool with Target Navigation</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script src="/common/get-host-info.sub.js"></script>+<script src="resources/helpers.js"></script>+</head>+<body>+<script>+const host_info = get_host_info();++promise_test(async t => {+ const iframe = document.createElement('iframe');+ iframe.src = 'resources/iframe-register-tool.html';+ iframe.allow = 'tools *';++ const load_promise = new Promise(resolve => iframe.onload = resolve);+ document.body.appendChild(iframe);+ t.add_cleanup(() => iframe.remove());+ await load_promise;++ // Tell iframe to register a tool.+ iframe.contentWindow.postMessage({+ action: 'register',+ hangsForever: true,+ tool: {+ name: 'iframe_tool',+ description: 'Iframe tool'+ }+ }, '*');++ // Wait for toolchange.+ await new Promise(resolve => {+ document.modelContext.addEventListener('toolchange', resolve, {once: true});+ });++ // Invoke tool and immediately navigate iframe away.+ const tools = await document.modelContext.getTools();+ const tool = tools.find(t => t.name === 'iframe_tool');+ const promise = document.modelContext.executeTool(tool);+ iframe.src = 'about:blank';++ // The promise should be rejected because the target document died.+ // We expect AbortError or similar. Let's assume AbortError for now.+ await promise_rejects_dom(t, 'UnknownError', promise, 'Promise should be rejected when target document dies');+}, 'executeTool() rejects when target document navigates away');+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-unauthorized-origin.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-unauthorized-origin.https.htmlnew file mode 100644index 000000000..f0f14ebb5--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-unauthorized-origin.https.html@@ -0,0 +1,62 @@+<!DOCTYPE html>+<html>+<head>+<title>WebMCP executeTool on unauthorized origin</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script src="/common/get-host-info.sub.js"></script>+<script src="resources/helpers.js"></script>+</head>+<body>+<script>+const hostInfo = get_host_info();++async function setupCrossOriginIframe(t) {+ const iframe = document.createElement('iframe');+ // Load helper iframe from cross-origin remote host.+ iframe.src = `${hostInfo.HTTPS_REMOTE_ORIGIN}/webmcp/imperative/resources/iframe-register-tool.html`;+ iframe.allow = 'tools *';++ const load_promise = new Promise(resolve => iframe.onload = resolve);+ document.body.appendChild(iframe);+ t.add_cleanup(() => iframe.remove());+ await load_promise;+ return iframe;+}++promise_test(async t => {+ const iframe = await setupCrossOriginIframe(t);++ // Tell the cross-origin iframe to register a tool with no `exposedTo` array (only visible to itself).+ iframe.contentWindow.postMessage({+ action: 'register',+ tool: {+ name: 'iframe_secure_tool',+ description: 'Iframe secure tool description'+ }+ }, '*');++ // Wait briefly to ensure registration has completed in the target frame.+ // Since it's cross-origin, we can't listen to its `toolchange` event directly, so we wait.+ await new Promise(resolve => t.step_timeout(resolve, 1000));++ // Verify that the parent (unexposed origin) cannot see the tool via getTools().+ const tools = await document.modelContext.getTools();+ assert_array_equals(tools, [], 'Parent frame should see no tools');++ // Manually construct a fake RegisteredTool pointing to the cross-origin iframe window.+ const fake_tool = {+ name: 'iframe_secure_tool',+ description: 'Iframe secure tool description',+ window: iframe.contentWindow,+ origin: hostInfo.HTTPS_REMOTE_ORIGIN+ };++ // Parent attempts to execute the unexposed tool directly. This should reject with UnknownError.+ const promise = document.modelContext.executeTool(fake_tool);+ await promise_rejects_dom(t, 'UnknownError', promise, 'executeTool should reject with UnknownError when parent is not authorized to execute the iframe tool');+}, 'executeTool() rejects when parent frame attempts unauthorized execution of cross-origin iframe tool');+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-unregister-resolution-race.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-unregister-resolution-race.https.htmlnew file mode 100644index 000000000..32acc2765--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/executeTool-unregister-resolution-race.https.html@@ -0,0 +1,40 @@+<!DOCTYPE html>+<html>+<head>+<title>WebMCP executeTool unregistration and resolution race</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+</head>+<body>+<script>+promise_test(async t => {+ const ac = new AbortController();++ await document.modelContext.registerTool({+ name: "racy_tool",+ description: "a racy tool",+ execute: async () => {+ return new Promise(resolve => {+ resolve({status: "resolved"});+ // Synchronously unregister the tool after resolving the promise.+ // Unregistering a tool does not cancel pending tool executions,+ // so executeTool() should resolve successfully with the tool's result.+ //+ // (This test was originally written as a regression test from a time+ // when unregistering a tool cancelled pending executions. It no longer+ // does.)+ ac.abort();+ });+ }+ }, {signal: ac.signal});++ const [tool] = await document.modelContext.getTools();+ const execute_promise = document.modelContext.executeTool(tool);++ const result = await execute_promise;+ assert_equals(result, '{"status":"resolved"}');+}, 'executeTool resolves successfully even when tool is unregistered synchronously after its promise resolves');+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/exposedTo-cross-origin-child.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/exposedTo-cross-origin-child.https.htmlnew file mode 100644index 000000000..61f4905fb--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/exposedTo-cross-origin-child.https.html@@ -0,0 +1,223 @@+<!DOCTYPE html>+<html>+<head>+<title>WebMCP Simple Cross-Origin Exposure to Child</title>+<meta name="timeout" content="long">+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script src="/common/get-host-info.sub.js"></script>+<script src="resources/helpers.js"></script>+</head>+<body>+<script>+const host_info = get_host_info();++async function setupIframe(t) {+ const iframe = document.createElement('iframe');+ iframe.src = host_info.HTTPS_REMOTE_ORIGIN + '/webmcp/imperative/resources/iframe-register-tool.html';+ iframe.allow = 'tools *';++ const load_promise = new Promise(resolve => iframe.onload = resolve);+ document.body.appendChild(iframe);+ t.add_cleanup(() => iframe.remove());+ await load_promise;+ return iframe;+}++promise_test(async t => {+ const controller = new AbortController();+ await document.modelContext.registerTool({+ name: 'parent_tool_exposed',+ description: 'Parent tool exposed to child',+ inputSchema: { type: 'object', properties: { query: { type: 'string' } } },+ execute: async () => 'hello'+ }, { exposedTo: [host_info.HTTPS_REMOTE_ORIGIN], signal: controller.signal });++ const iframe = await setupIframe(t);++ // Ask iframe what it sees.+ iframe.contentWindow.postMessage(+ {action: 'getTools', options: {fromOrigins: [self.origin]}}, '*');+ let response = await waitForIframeMessage('getToolsResponse');+ const [tool] = response.tools;+ assert_true(toolsAreEqual(tool, {+ name: 'parent_tool_exposed',+ description: 'Parent tool exposed to child',+ inputSchema: { type: 'object', properties: { query: { type: 'string' } } },+ origin: self.origin+ }), 'Tool details should match');++ // Child executes parent's tool.+ iframe.contentWindow.postMessage(+ {+ action: 'execute',+ name: 'parent_tool_exposed',+ options: {fromOrigins: [self.origin]}+ },+ '*');+ const exec_response = await waitForIframeMessage('executeResponse');+ assert_true(exec_response.success, 'Child should successfully execute parent tool');+ assert_equals(exec_response.result, 'hello', 'Child should get correct result from parent tool');++ // Unregister and verify `toolchange` is fired in iframe.+ iframe.contentWindow.postMessage('listenForToolchange', '*');+ await waitForIframeMessage('toolchange_listening_ack');++ const child_unreg_promise = waitForIframeMessage('toolchange_result');+ const parent_unreg_promise = new Promise(resolve => {+ document.modelContext.addEventListener('toolchange', resolve, {once: true});+ });++ controller.abort();++ const [child_response] = await Promise.all([child_unreg_promise, parent_unreg_promise]);+ assert_equals(child_response.result, 'fired', 'Cross-origin iframe should receive toolchange event on unregistration');++ iframe.contentWindow.postMessage(+ {action: 'getTools', options: {fromOrigins: [self.origin]}}, '*');+ response = await waitForIframeMessage('getToolsResponse');+ assert_array_equals(response.tools, [], 'Cross-origin iframe should no longer see any tools after unregistration');+}, 'Parent exposes tool to cross-origin child');++promise_test(async t => {+ const iframe = await setupIframe(t);++ // Tell iframe to register tool exposed to parent (HTTPS_ORIGIN)+ iframe.contentWindow.postMessage({+ action: 'register',+ tool: {+ name: 'iframe_tool_exposed',+ description: 'Iframe tool exposed to parent',+ inputSchema: { type: 'object', properties: { query: { type: 'string' } } }+ },+ options: { exposedTo: [self.origin] }+ }, '*');++ await new Promise(resolve => {+ document.modelContext.addEventListener('toolchange', resolve, { once: true });+ });++ let tools = await document.modelContext.getTools(+ {fromOrigins: [host_info.HTTPS_REMOTE_ORIGIN]});+ const tool = tools.find(t => t.name === 'iframe_tool_exposed');+ assert_true(toolsAreEqual(tool, {+ name: 'iframe_tool_exposed',+ description: 'Iframe tool exposed to parent',+ inputSchema: { type: 'object', properties: { query: { type: 'string' } } },+ origin: host_info.HTTPS_REMOTE_ORIGIN+ }), 'Tool details should match');++ // Parent executes iframe's tool.+ const result = await document.modelContext.executeTool(tool);+ assert_equals(result, 'hello from iframe', 'Parent should get correct result from iframe tool');++ // Tell the iframe to unregister its tool, and confirm that `toolchange` fires here.+ const toolchange_promise = new Promise(resolve => {+ document.modelContext.addEventListener('toolchange', resolve, { once: true });+ });+ iframe.contentWindow.postMessage({ action: 'unregister', name: 'iframe_tool_exposed' }, '*');+ await toolchange_promise;++ tools = await document.modelContext.getTools(+ {fromOrigins: [host_info.HTTPS_REMOTE_ORIGIN]});+ assert_array_equals(tools, [], 'Parent should no longer see cross-origin iframe tool after unregistration');+}, 'Cross-origin child exposes tool to parent');++promise_test(async t => {+ // Parent exposes tool to an origin that is neither its own, nor its cross-origin iframe's.+ const controller = new AbortController();+ await document.modelContext.registerTool({+ name: 'parent_tool',+ description: 'Parent tool exposed',+ execute: async () => 'hello'+ }, { exposedTo: [host_info.HTTPS_OTHER_NOTSAMESITE_ORIGIN], signal: controller.signal });++ const iframe = await setupIframe(t);++ // Iframe does not see tool.+ iframe.contentWindow.postMessage(+ {action: 'getTools', options: {fromOrigins: [self.origin]}}, '*');+ const response = await waitForIframeMessage('getToolsResponse');+ assert_array_equals(response.tools, [], 'iframe should see no tools');++ // Unregister tool and verify that the iframe does not get `toolchange` fired.+ iframe.contentWindow.postMessage('listenForToolchange', '*');+ await waitForIframeMessage('toolchange_listening_ack');++ const child_unreg_promise = waitForIframeMessage('toolchange_result');+ const parent_unreg_promise = new Promise(resolve => {+ document.modelContext.addEventListener('toolchange', resolve, {once: true});+ });++ controller.abort();++ const [child_response] = await Promise.all([child_unreg_promise, parent_unreg_promise]);+ assert_equals(child_response.result, 'timeout', 'iframe should not receive toolchange event');+}, "Parent exposes tool to origin that is neither its own nor its iframe's");++promise_test(async t => {+ const iframe = await setupIframe(t);++ // No `toolchange` events should be fired in the parent during this test.+ const toolchange_promise = new Promise((resolve, reject) => {+ const listener = () => reject('Parent should not receive toolchange event');+ document.modelContext.addEventListener('toolchange', listener);+ t.add_cleanup(() => document.modelContext.removeEventListener('toolchange', listener));+ });+ const timeout_promise = () => new Promise(resolve => t.step_timeout(resolve, 4000));++ iframe.contentWindow.postMessage({+ action: 'register',+ tool: {+ name: 'iframe_tool',+ description: 'Iframe tool'+ },+ options: { exposedTo: [host_info.HTTPS_OTHER_NOTSAMESITE_ORIGIN] }+ }, '*');++ await Promise.race([toolchange_promise, timeout_promise()]);++ let tools = await document.modelContext.getTools(+ {fromOrigins: [host_info.HTTPS_REMOTE_ORIGIN]});+ assert_array_equals(tools, [], 'Parent should not see iframe tool');++ iframe.contentWindow.postMessage({ action: 'unregister', name: 'iframe_tool_to_c' }, '*');++ await Promise.race([toolchange_promise, timeout_promise()]);++ tools = await document.modelContext.getTools(+ {fromOrigins: [host_info.HTTPS_REMOTE_ORIGIN]});+ assert_array_equals(tools, [], 'Parent should not see iframe tool after unregistration');+}, "Iframe exposes tool to origin that is neither its own nor its parent's");++promise_test(async t => {+ const iframe = document.createElement('iframe');+ iframe.src = host_info.HTTPS_REMOTE_ORIGIN + '/webmcp/imperative/resources/iframe-register-tool.html';++ const load_promise = new Promise(resolve => iframe.onload = resolve);+ document.body.appendChild(iframe);+ t.add_cleanup(() => iframe.remove());+ await load_promise;++ iframe.contentWindow.postMessage('listenForToolchange', '*');+ await waitForIframeMessage('toolchange_listening_ack');++ const toolchange_promise = waitForIframeMessage('toolchange_result');+ const timeout_promise = () => new Promise(resolve => t.step_timeout(() => resolve({ result: 'timeout' }), 4000));++ const controller = new AbortController();+ await document.modelContext.registerTool({+ name: 'parent_tool_no_policy',+ description: 'Parent tool',+ execute: async () => 'hello'+ }, { exposedTo: [host_info.HTTPS_REMOTE_ORIGIN], signal: controller.signal });++ const response = await Promise.race([toolchange_promise, timeout_promise()]);+ assert_equals(response.result, 'timeout', 'Cross-origin iframe without permissions policy should not receive toolchange event');++ controller.abort();+}, 'Cross-origin iframe without permissions policy does not receive toolchange event even if exposed to it');+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/exposedTo-defaults-cross-origin.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/exposedTo-defaults-cross-origin.https.htmlnew file mode 100644index 000000000..ac956ee6c--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/exposedTo-defaults-cross-origin.https.html@@ -0,0 +1,153 @@+<!DOCTYPE html>+<html>+<head>+<title>WebMCP Default Tool Exposure (Cross-Origin)</title>+<meta name="timeout" content="long">+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script src="/common/get-host-info.sub.js"></script>+<script src="resources/helpers.js"></script>+</head>+<body>+<script>+const host_info = get_host_info();++async function setupIframe(t) {+ const iframe = document.createElement('iframe');+ iframe.src = host_info.HTTPS_REMOTE_ORIGIN + '/webmcp/imperative/resources/iframe-register-tool.html';+ iframe.allow = 'tools *';++ const load_promise = new Promise(resolve => iframe.onload = resolve);+ document.body.appendChild(iframe);+ t.add_cleanup(() => iframe.remove());+ await load_promise;+ return iframe;+}++promise_test(async t => {+ const controller = new AbortController();+ await document.modelContext.registerTool({+ name: 'parent_tool_default',+ description: 'Parent tool with default exposure',+ execute: async () => 'hello'+ }, { signal: controller.signal });++ const iframe = await setupIframe(t);++ // Ask iframe what it sees.+ iframe.contentWindow.postMessage('getTools', '*');+ const response = await waitForIframeMessage('getToolsResponse');+ assert_array_equals(response.tools, [], 'Cross-origin iframe should see no tools');++ // Unregister and verify child does NOT get event.+ iframe.contentWindow.postMessage('listenForToolchange', '*');+ await waitForIframeMessage('toolchange_listening_ack');++ const child_unreg_promise = waitForIframeMessage('toolchange_result');+ const parent_unreg_promise = new Promise(resolve => {+ document.modelContext.addEventListener('toolchange', resolve, {once: true});+ });++ controller.abort();++ const [child_response] = await Promise.all([child_unreg_promise, parent_unreg_promise]);+ assert_equals(child_response.result, 'timeout', 'Cross-origin iframe should not receive toolchange event on unregistration');+}, 'Parent tool with no exposedTo array is not visible to cross-origin iframe');++promise_test(async t => {+ const controller = new AbortController();+ await document.modelContext.registerTool({+ name: 'parent_tool_empty',+ description: 'Parent tool with empty exposedTo',+ execute: async () => 'hello'+ }, { exposedTo: [], signal: controller.signal });++ const iframe = await setupIframe(t);++ iframe.contentWindow.postMessage('getTools', '*');+ const response = await waitForIframeMessage('getToolsResponse');+ assert_array_equals(response.tools, [], 'Cross-origin iframe should see no tools');++ // Unregister and verify child does NOT get event.+ iframe.contentWindow.postMessage('listenForToolchange', '*');+ await waitForIframeMessage('toolchange_listening_ack');++ const child_unreg_promise = waitForIframeMessage('toolchange_result');+ const parent_unreg_promise = new Promise(resolve => {+ document.modelContext.addEventListener('toolchange', resolve, {once: true});+ });++ controller.abort();++ const [child_response] = await Promise.all([child_unreg_promise, parent_unreg_promise]);+ assert_equals(child_response.result, 'timeout', 'Cross-origin iframe should not receive toolchange event on unregistration');+}, 'Parent tool with empty exposedTo array is not visible to cross-origin iframe');++promise_test(async t => {+ const iframe = await setupIframe(t);++ // No `toolchange` events should be fired in the parent during this test.+ const toolchange_promise = new Promise((resolve, reject) => {+ const listener = () => reject('Parent should not receive toolchange event');+ document.modelContext.addEventListener('toolchange', listener);+ t.add_cleanup(() => document.modelContext.removeEventListener('toolchange', listener));+ });+ const timeout_promise = () => new Promise(resolve => t.step_timeout(resolve, 4000));++ // Tell the iframe to register a tool with no `exposedTo` array.+ iframe.contentWindow.postMessage({+ action: 'register',+ tool: {+ name: 'iframe_tool_default',+ description: 'Iframe tool with default exposure'+ }+ }, '*');++ await Promise.race([toolchange_promise, timeout_promise()]);++ let tools = await document.modelContext.getTools();+ assert_array_equals(tools, [], 'Parent should see no tools');++ iframe.contentWindow.postMessage({ action: 'unregister', name: 'iframe_tool_default' }, '*');+ await Promise.race([toolchange_promise, timeout_promise()]);++ tools = await document.modelContext.getTools();+ assert_false(tools.some(t => t.name === 'iframe_tool_default'), 'Parent should not see cross-origin iframe tool after unregistration');+}, 'Cross-origin iframe tool with default exposure is not visible to parent');++promise_test(async t => {+ const iframe = await setupIframe(t);++ // No `toolchange` events should be fired in the parent during this test.+ const toolchange_promise = new Promise((resolve, reject) => {+ const listener = () => reject('Parent should not receive toolchange event');+ document.modelContext.addEventListener('toolchange', listener);+ t.add_cleanup(() => document.modelContext.removeEventListener('toolchange', listener));+ });+ const timeout_promise = () => new Promise(resolve => t.step_timeout(resolve, 4000));++ // Tell the iframe to register a tool with an empty `exposedTo` array.+ iframe.contentWindow.postMessage({+ action: 'register',+ tool: {+ name: 'iframe_tool_empty',+ description: 'Iframe tool with empty exposedTo'+ },+ options: { exposedTo: [] }+ }, '*');++ await Promise.race([toolchange_promise, timeout_promise()]);++ let tools = await document.modelContext.getTools();+ assert_array_equals(tools, [], 'Parent should see no tools');++ iframe.contentWindow.postMessage({ action: 'unregister', name: 'iframe_tool_empty' }, '*');+ await Promise.race([toolchange_promise, timeout_promise()]);++ tools = await document.modelContext.getTools();+ assert_false(tools.some(t => t.name === 'iframe_tool_empty'), 'Parent should not see cross-origin iframe tool after unregistration');+}, 'Cross-origin iframe tool with empty exposedTo array is not visible to parent');+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/exposedTo-defaults-same-origin.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/exposedTo-defaults-same-origin.https.htmlnew file mode 100644index 000000000..d37688066--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/exposedTo-defaults-same-origin.https.html@@ -0,0 +1,200 @@+<!DOCTYPE html>+<html>+<head>+<title>Same-origin tool exposure</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script src="resources/helpers.js"></script>+</head>+<body>+<script>+async function setupIframe(t) {+ const iframe = document.createElement('iframe');+ iframe.src = 'resources/iframe-register-tool.html';++ const load_promise = new Promise(resolve => iframe.onload = resolve);+ document.body.appendChild(iframe);+ t.add_cleanup(() => iframe.remove());+ await load_promise;+ return iframe;+}++promise_test(async t => {+ const controller = new AbortController();+ await document.modelContext.registerTool({+ name: 'parent_tool_default',+ description: 'Parent tool with default exposure',+ inputSchema: { type: 'object', properties: { query: { type: 'string' } } },+ annotations: { readOnlyHint: true, untrustedContentHint: false, consequentialHint: false, debugging: false },+ execute: async () => 'hello'+ }, { signal: controller.signal });++ const iframe = await setupIframe(t);++ // Ask iframe what it sees.+ iframe.contentWindow.postMessage('getTools', '*');+ let response = await waitForIframeMessage('getToolsResponse');++ const [tool] = response.tools;+ assert_true(!!tool, 'Same-origin iframe should see parent tool with no exposedTo');+ assert_true(toolsAreEqual(tool, {+ name: 'parent_tool_default',+ description: 'Parent tool with default exposure',+ inputSchema: { type: 'object', properties: { query: { type: 'string' } } },+ annotations: { readOnlyHint: true, untrustedContentHint: false, consequentialHint: false, debugging: false },+ origin: self.origin+ }), 'Tool details should match');++ // Iframe executes parent's tool.+ iframe.contentWindow.postMessage({action: 'execute', name: 'parent_tool_default'}, '*');+ const exec_response = await waitForIframeMessage('executeResponse');+ assert_true(exec_response.success, 'Iframe should successfully execute parent tool');+ assert_equals(exec_response.result, 'hello', 'Iframe should get correct result from parent tool');++ // Unregister and verify child gets event.+ iframe.contentWindow.postMessage('listenForToolchange', '*');+ await waitForIframeMessage('toolchange_listening_ack');++ const child_unreg_promise = waitForIframeMessage('toolchange_result');+ const parent_unreg_promise = new Promise(resolve => {+ document.modelContext.addEventListener('toolchange', resolve, {once: true});+ });++ controller.abort();++ const [child_response] = await Promise.all([child_unreg_promise, parent_unreg_promise]);+ assert_equals(child_response.result, 'fired', 'Same-origin iframe should receive toolchange event on unregistration');++ iframe.contentWindow.postMessage('getTools', '*');+ response = await waitForIframeMessage('getToolsResponse');+ assert_array_equals(response.tools, [], 'Same-origin iframe should no longer see any tools after unregistration');+}, 'Parent tool with missing `exposedTo` array is visible to same-origin iframe');++promise_test(async t => {+ const controller = new AbortController();+ await document.modelContext.registerTool({+ name: 'parent_tool_empty',+ description: 'Parent tool with empty exposedTo',+ inputSchema: { type: 'object', properties: { query: { type: 'string' } } },+ execute: async () => 'hello'+ }, { exposedTo: [], signal: controller.signal });++ const iframe = await setupIframe(t);++ iframe.contentWindow.postMessage('getTools', '*');+ let response = await waitForIframeMessage('getToolsResponse');++ const [tool] = response.tools;+ assert_true(!!tool, 'Same-origin iframe should see parent tool with empty exposedTo');+ assert_true(toolsAreEqual(tool, {+ name: 'parent_tool_empty',+ description: 'Parent tool with empty exposedTo',+ inputSchema: { type: 'object', properties: { query: { type: 'string' } } },+ origin: self.origin+ }), 'Tool details should match');++ // Iframe executes parent's tool.+ iframe.contentWindow.postMessage({action: 'execute', name: 'parent_tool_empty'}, '*');+ const exec_response = await waitForIframeMessage('executeResponse');+ assert_true(exec_response.success, 'Iframe should successfully execute parent tool');+ assert_equals(exec_response.result, 'hello', 'Iframe should get correct result from parent tool');++ // Unregister and verify child gets event.+ iframe.contentWindow.postMessage('listenForToolchange', '*');+ await waitForIframeMessage('toolchange_listening_ack');++ const child_unreg_promise = waitForIframeMessage('toolchange_result');+ const parent_unreg_promise = new Promise(resolve => {+ document.modelContext.addEventListener('toolchange', resolve, {once: true});+ });++ controller.abort();++ const [child_response] = await Promise.all([child_unreg_promise, parent_unreg_promise]);+ assert_equals(child_response.result, 'fired', 'Same-origin iframe should receive toolchange event on unregistration');++ iframe.contentWindow.postMessage('getTools', '*');+ response = await waitForIframeMessage('getToolsResponse');+ assert_array_equals(response.tools, [], 'Same-origin iframe should no longer see any tools after unregistration');+}, 'Parent tool with empty `exposedTo` array is visible to same-origin iframe');++promise_test(async t => {+ const iframe = await setupIframe(t);++ iframe.contentWindow.postMessage({+ action: 'register',+ tool: {+ name: 'iframe_tool_default',+ description: 'Iframe tool with default exposure'+ }+ }, '*');++ await new Promise(resolve => {+ document.modelContext.addEventListener('toolchange', resolve, { once: true });+ });++ let tools = await document.modelContext.getTools();+ const [tool] = tools;+ assert_true(toolsAreEqual(tool, {+ name: 'iframe_tool_default',+ description: 'Iframe tool with default exposure',+ origin: iframe.contentWindow.origin+ }), 'Tool details should match');++ // Parent executes iframe's tool.+ const result = await document.modelContext.executeTool(tool);+ assert_equals(result, 'hello from iframe', 'Parent should get correct result from iframe tool');++ // Unregister tool.+ const unregister_promise = new Promise(resolve => {+ document.modelContext.addEventListener('toolchange', resolve, { once: true });+ });+ iframe.contentWindow.postMessage({ action: 'unregister', name: 'iframe_tool_default' }, '*');+ await unregister_promise;++ tools = await document.modelContext.getTools();+ assert_false(tools.some(t => t.name === 'iframe_tool_default'), 'Same-origin parent should no longer see iframe tool after unregistration');+}, 'Same-origin iframe tool with default exposure is visible to parent');++promise_test(async t => {+ const iframe = await setupIframe(t);++ iframe.contentWindow.postMessage({+ action: 'register',+ tool: {+ name: 'iframe_tool_empty',+ description: 'Iframe tool with empty exposedTo'+ },+ options: { exposedTo: [] }+ }, '*');++ await new Promise(resolve => {+ document.modelContext.addEventListener('toolchange', resolve, { once: true });+ });++ let tools = await document.modelContext.getTools();+ const [tool] = tools;+ assert_true(toolsAreEqual(tool, {+ name: 'iframe_tool_empty',+ description: 'Iframe tool with empty exposedTo',+ origin: iframe.contentWindow.origin+ }), 'Tool details should match');++ // Parent executes iframe's tool.+ const result = await document.modelContext.executeTool(tool);+ assert_equals(result, 'hello from iframe', 'Parent should get correct result from iframe tool');++ // Unregister tool.+ const unregister_promise = new Promise(resolve => {+ document.modelContext.addEventListener('toolchange', resolve, { once: true });+ });+ iframe.contentWindow.postMessage({ action: 'unregister', name: 'iframe_tool_empty' }, '*');+ await unregister_promise;++ tools = await document.modelContext.getTools();+ assert_false(tools.some(t => t.name === 'iframe_tool_empty'), 'Same-origin parent should no longer see iframe tool after unregistration');+}, 'Same-origin iframe tool with empty exposedTo array is visible to parent');+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/exposedTo-invalid-origins.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/exposedTo-invalid-origins.https.htmlnew file mode 100644index 000000000..42235a948--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/exposedTo-invalid-origins.https.html@@ -0,0 +1,98 @@+<!DOCTYPE html>+<html>+<head>+<title>Invalid origins in exposedTo array</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+</head>+<body>+<script>+const test_cases = [+ {success: false, origin: '/'},+ {success: false, origin: '*'},+ {success: false, origin: 'https://example:bogus'},+ {success: false, origin: 'https://\ud800.com'},+ {success: false, origin: 'http://example.com'},+ {success: false, origin: 'ftp://example.com'},+ {success: false, origin: 'about:blank'},+ {success: false, origin: 'about:srcdoc'},++ {success: true, origin: 'https://example.com'},+ {success: true, origin: 'http://localhost:3000'},+];++for (const test of test_cases) {+ promise_test(async t => {+ const register = () => {+ return document.modelContext.registerTool({+ name: 'test_tool_' + Math.random(),+ description: 'Test tool',+ execute: async () => 'hello'+ }, { exposedTo: [test.origin] });+ };++ if (!test.success) {+ return promise_rejects_dom(t, 'SecurityError', register(), `Should throw SecurityError for origin: ${test.origin}`);+ } else {+ try {+ await register();+ } catch (e) {+ throw new Error(`Should not have thrown for ${test.origin}`);+ }+ }}, `registerTool() throws SecurityError for invalid or ` ++ `non-potentially-trustworthy origins like ${test.origin} in exposedTo`);+}++promise_test(async t => {+ const signal = AbortSignal.abort('aborted');+ return promise_rejects_exactly(t, 'aborted', document.modelContext.registerTool({+ name: "name",+ description: "description",+ execute: () => {}+ }, { signal, exposedTo: ['about:blank#invalidOrigin']}) )+}, "registerTool() with abort signal reason because signal is processed before `exposedTo`");++promise_test(async t => {+ const ac1 = new AbortController();++ // 1. Attempt an invalid tool registration whose promise rejects with SecurityError.+ const p1 = document.modelContext.registerTool({+ name: 'target_tool',+ description: 'Target tool',+ execute: async () => 'callback1'+ }, { signal: ac1.signal, exposedTo: ['http://insecure.example'] });+ await promise_rejects_dom(t, 'SecurityError', p1, 'First registration should fail with SecurityError');++ // 2. Valid tool registration with callback2 under the same tool name.+ const ac2 = new AbortController();+ await document.modelContext.registerTool({+ name: 'target_tool',+ description: 'Target tool',+ execute: async () => 'callback2'+ }, { signal: ac2.signal });++ // 3. Cache the RegisteredTool object.+ const [tool] = await document.modelContext.getTools();+ assert_true(!!tool, 'target_tool should be registered');++ // 4. Abort the signal from the first (rejected) registration.+ ac1.abort();++ // 5. Attempt to register a replacement callback3 under the same name.+ // Since ac1.abort() must not unregister target_tool, this duplicate registration must reject with InvalidStateError.+ const p3 = document.modelContext.registerTool({+ name: 'target_tool',+ description: 'Target tool replacement',+ execute: async () => 'callback3'+ });+ await promise_rejects_dom(t, 'InvalidStateError', p3, 'Duplicate registration should reject with InvalidStateError');++ // 6. Execute the cached RegisteredTool.+ // This must execute callback2 and resolve to 'callback2', not callback3.+ const result = await document.modelContext.executeTool(tool);+ assert_equals(result, 'callback2', 'Executing the cached RegisteredTool must run callback2');+}, 'Aborting a signal from a rejected registration must not unregister a later valid tool with the same name');+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/exposedTo-multiple-children.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/exposedTo-multiple-children.https.htmlnew file mode 100644index 000000000..8f7715716--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/exposedTo-multiple-children.https.html@@ -0,0 +1,103 @@+<!DOCTYPE html>+<html>+<head>+<title>WebMCP Complex Origin-Based Exposure</title>+<meta name="timeout" content="long">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script src="/common/get-host-info.sub.js"></script>+<script src="resources/helpers.js"></script>+</head>+<body>+<script>+const host_info = get_host_info();++promise_test(async t => {+ const origin_a = host_info.HTTPS_ORIGIN;+ const origin_b = host_info.HTTPS_REMOTE_ORIGIN;+ const origin_c = host_info.HTTPS_OTHER_NOTSAMESITE_ORIGIN;++ // Setup iframes with multiple origins: Parent=A, Child1=B, Child2=C.+ const iframe_b = document.createElement('iframe');+ iframe_b.src = origin_b + '/webmcp/imperative/resources/iframe-register-tool.html';+ iframe_b.allow = 'tools *';++ const iframe_c = document.createElement('iframe');+ iframe_c.src = origin_c + '/webmcp/imperative/resources/iframe-register-tool.html';+ iframe_c.allow = 'tools *';++ const load_promise_b = new Promise(resolve => iframe_b.onload = resolve);+ const load_promise_c = new Promise(resolve => iframe_c.onload = resolve);++ document.body.appendChild(iframe_b);+ t.add_cleanup(() => iframe_b.remove());+ document.body.appendChild(iframe_c);+ t.add_cleanup(() => iframe_c.remove());++ await Promise.all([load_promise_b, load_promise_c]);++ // Meat of the test begins:++ // Frame B exposes tool to Frame C only. Frame C should observe `toolchange` event.+ iframe_c.contentWindow.postMessage('listenForToolchange', '*');+ await waitForIframeMessage('toolchange_listening_ack');++ const toolchange_promise = waitForIframeMessage('toolchange_result');++ iframe_b.contentWindow.postMessage({+ action: 'register',+ tool: {+ name: 'tool_b_to_c',+ description: 'Tool B exposed to C',+ inputSchema: { type: 'object', properties: { query: { type: 'string' } } }+ },+ options: { exposedTo: [origin_c] }+ }, '*');++ const toolchange_result = await toolchange_promise;+ assert_equals(toolchange_result.result, 'fired', 'Frame C received toolchange event');++ // Parent does not see the tool.+ let tools = await document.modelContext.getTools();+ assert_array_equals(tools, [], "Parent sees no tools");++ // Frame C should see the tool.+ iframe_c.contentWindow.postMessage(+ {action: 'getTools', options: {fromOrigins: [origin_b]}}, '*');+ let response = await waitForIframeMessage('getToolsResponse');+ const [tool] = response.tools;+ assert_true(toolsAreEqual(tool, {+ name: 'tool_b_to_c',+ description: 'Tool B exposed to C',+ inputSchema: { type: 'object', properties: { query: { type: 'string' } } },+ origin: origin_b+ }), 'Tool details should match');++ // Now, we make B unregister the tool, and assert that:+ // 1. `toolchange` fires in C.+ // 3. Frame C can no longer see the tool in `getTools()`.+ iframe_c.contentWindow.postMessage('listenForToolchange', '*');+ await waitForIframeMessage('toolchange_listening_ack');+ const child_unreg_promise = waitForIframeMessage('toolchange_result');++ // 2. `toolchange` does not fire in the parent frame.+ let unreg_fired = false;+ const unreg_listener = () => { unreg_fired = true; };+ document.modelContext.addEventListener('toolchange', unreg_listener);+ const parent_timeout_promise = new Promise(resolve => t.step_timeout(resolve, 4000));++ iframe_b.contentWindow.postMessage({ action: 'unregister', name: 'tool_b_to_c' }, '*');+ const [child_response] = await Promise.all([child_unreg_promise, parent_timeout_promise]);++ document.modelContext.removeEventListener('toolchange', unreg_listener);+ assert_false(unreg_fired, 'Parent should not receive toolchange event on unregistration');+ assert_equals(child_response.result, 'fired', 'Frame C should receive toolchange event on unregistration');++ iframe_c.contentWindow.postMessage(+ {action: 'getTools', options: {fromOrigins: [origin_b]}}, '*');+ response = await waitForIframeMessage('getToolsResponse');+ assert_array_equals(response.tools, [], "Frame C no longer sees B's tool");+}, 'Multi-origin setup with mixed exposure lists');+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/exposedTo-window-open.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/exposedTo-window-open.https.htmlnew file mode 100644index 000000000..3873fc23c--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/exposedTo-window-open.https.html@@ -0,0 +1,56 @@+<!DOCTYPE html>+<html>+<head>+<title>WebMCP Exposure Across window.open()</title>+<meta name="timeout" content="long">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script src="/common/get-host-info.sub.js"></script>+<script src="resources/helpers.js"></script>+</head>+<body>+<script>+const host_info = get_host_info();++promise_test(async t => {+ const origin_a = host_info.HTTPS_ORIGIN;+ const origin_b = host_info.HTTPS_REMOTE_ORIGIN;++ // Frame B exposes to A. Parent A can view, but opened window cannot.+ const iframe_b = document.createElement('iframe');+ iframe_b.src = origin_b + '/webmcp/imperative/resources/iframe-register-tool.html';+ iframe_b.allow = 'tools *';++ const load_promise = new Promise(resolve => iframe_b.onload = resolve);+ document.body.appendChild(iframe_b);+ t.add_cleanup(() => iframe_b.remove());+ await load_promise;++ iframe_b.contentWindow.postMessage({+ action: 'register',+ tool: {+ name: 'tool_b_to_a',+ description: 'Tool B exposed to A',+ },+ options: { exposedTo: [origin_a] }+ }, '*');++ await new Promise(resolve => {+ document.modelContext.addEventListener('toolchange', resolve, { once: true });+ });++ // Parent A can view it.+ const tools = await document.modelContext.getTools({ fromOrigins: [origin_b] });+ assert_true(tools.some(t => t.name === 'tool_b_to_a'), 'Parent A should see tool_b_to_a');++ // Open new window.+ const opened_window = window.open('about:blank');+ t.add_cleanup(() => opened_window.close());++ // Newly opened window does not see the tool.+ const opened_tools = await opened_window.document.modelContext.getTools();+ assert_array_equals(opened_tools, [], "window.open()'d sees no tools");+}, 'Tools are scoped to a frame tree, and are not exposed across opener boundaries.');+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/getTools-filtering.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/getTools-filtering.https.htmlnew file mode 100644index 000000000..c74e87447--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/getTools-filtering.https.html@@ -0,0 +1,103 @@+<!DOCTYPE html>+<html>+<head>+<title>WebMCP getTools() Origin Filtering</title>+<meta name="timeout" content="long">+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script src="/common/get-host-info.sub.js"></script>+<script src="resources/helpers.js"></script>+</head>+<body>+<script>+const host_info = get_host_info();++async function setupIframe(t, origin) {+ const iframe = document.createElement('iframe');+ iframe.src = origin + '/webmcp/imperative/resources/iframe-register-tool.html';+ iframe.allow = 'tools *';++ const load_promise = new Promise(resolve => iframe.onload = resolve);+ document.body.appendChild(iframe);+ t.add_cleanup(() => iframe.remove());+ await load_promise;+ return iframe;+}++promise_test(async t => {+ // 1. Parent (origin A: self.origin) registers tool T_A+ const controller_a = new AbortController();+ await document.modelContext.registerTool({+ name: 'parent_tool',+ description: 'Parent tool',+ execute: async () => 'hello'+ }, { signal: controller_a.signal });++ // 2. Setup cross-origin child B+ const iframe_b = await setupIframe(t, host_info.HTTPS_REMOTE_ORIGIN);++ // 3. Tell B to register tool T_B exposed to A+ const b_reg_promise = new Promise(resolve => {+ document.modelContext.addEventListener('toolchange', resolve, { once: true });+ });+ iframe_b.contentWindow.postMessage({+ action: 'register',+ tool: {+ name: 'iframe_tool_b',+ description: 'Tool from B exposed to parent',+ },+ options: { exposedTo: [self.origin] }+ }, '*');+ await b_reg_promise;++ // 4. Setup cross-origin child C+ const iframe_c = await setupIframe(t, host_info.HTTPS_OTHER_NOTSAMESITE_ORIGIN);++ // 5. Tell C to register tool T_C exposed to A+ const c_reg_promise = new Promise(resolve => {+ document.modelContext.addEventListener('toolchange', resolve, { once: true });+ });+ iframe_c.contentWindow.postMessage({+ action: 'register',+ tool: {+ name: 'iframe_tool_c',+ description: 'Tool from C exposed to parent',+ },+ options: { exposedTo: [self.origin] }+ }, '*');+ await c_reg_promise;++ // Check base case: getTools() with empty/omitted options should ONLY return parent_tool (same-origin)+ let tools = await document.modelContext.getTools();+ assert_equals(tools.length, 1, 'Should return 1 tool when getTools() is called with no arguments');+ assert_equals(tools[0].name, 'parent_tool');++ // Filter case 1: fromOrigins is empty/omitted in options (same as base case)+ tools = await document.modelContext.getTools({});+ assert_equals(tools.length, 1, 'Should return 1 tool when fromOrigins is empty');+ assert_equals(tools[0].name, 'parent_tool');++ // Filter case 2: fromOrigins = [origin_B] -> should return T_A (same-origin) and T_B (matches origin), but NOT T_C+ tools = await document.modelContext.getTools({ fromOrigins: [host_info.HTTPS_REMOTE_ORIGIN] });+ assert_equals(tools.length, 2, 'Should return 2 tools when filtered by B\'s origin');+ assert_equals(tools[0].name, 'iframe_tool_b');+ assert_equals(tools[1].name, 'parent_tool');++ // Filter case 3: fromOrigins = [origin_B, origin_C] -> should return T_A, T_B, T_C+ tools = await document.modelContext.getTools({ fromOrigins: [host_info.HTTPS_REMOTE_ORIGIN, host_info.HTTPS_OTHER_NOTSAMESITE_ORIGIN] });+ assert_equals(tools.length, 3, 'Should return all 3 tools when filtered by both B and C\'s origins');+ assert_equals(tools[0].name, 'iframe_tool_b');+ assert_equals(tools[1].name, 'iframe_tool_c');+ assert_equals(tools[2].name, 'parent_tool');++ // Clean up registered tools+ controller_a.abort();+}, 'getTools() correctly filters returned tools by fromOrigins origins while preserving same-origin tools');++promise_test(async t => {+ await promise_rejects_dom(t, 'SecurityError', document.modelContext.getTools({ fromOrigins: ['http://insecure.com'] }));+}, 'getTools() rejects with SecurityError if an insecure origin is supplied in fromOrigins');+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/getTools-imperative-annotations.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/getTools-imperative-annotations.https.htmlnew file mode 100644index 000000000..c9d4f2d11--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/getTools-imperative-annotations.https.html@@ -0,0 +1,107 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>WebMCP: getTools() retrieves imperative annotations at registration time</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<body>+<script>+promise_test(async t => {+ const tool = {+ name: "annotated_tool",+ description: "A tool with explicit annotations",+ annotations: {+ readOnlyHint: true,+ untrustedContentHint: true,+ consequentialHint: false,+ debugging: true,+ },+ execute: () => {},+ };++ const controller = new AbortController();+ t.add_cleanup(() => controller.abort());+ await document.modelContext.registerTool(tool, { signal: controller.signal });++ const tools = await document.modelContext.getTools();+ const registeredTool = tools.find(t => t.name === "annotated_tool");++ const expectedAnnotations = {+ readOnlyHint: true,+ untrustedContentHint: true,+ consequentialHint: false,+ debugging: true,+ };+ assert_object_equals(registeredTool.annotations, expectedAnnotations,+ "annotations object should match exactly the expected IDL properties and values");+}, "Test that getTools() returns explicit annotations for an imperative tool");++promise_test(async t => {+ const tool = {+ name: "partial_annotated_tool",+ description: "A tool with only readOnlyHint supplied",+ annotations: {+ readOnlyHint: true,+ },+ execute: () => {},+ };++ const controller = new AbortController();+ t.add_cleanup(() => controller.abort());+ await document.modelContext.registerTool(tool, { signal: controller.signal });++ const tools = await document.modelContext.getTools();+ const registeredTool = tools.find(t => t.name === "partial_annotated_tool");++ const expectedAnnotations = {+ readOnlyHint: true,+ untrustedContentHint: false,+ consequentialHint: false,+ debugging: false,+ };+ assert_object_equals(registeredTool.annotations, expectedAnnotations,+ "annotations object should contain default value for omitted untrustedContentHint property");+}, "Test that getTools() populates default values for omitted annotation properties");++promise_test(async t => {+ const tool = {+ name: "empty_annotated_tool",+ description: "A tool with empty annotations object",+ annotations: {},+ execute: () => {},+ };++ const controller = new AbortController();+ t.add_cleanup(() => controller.abort());+ await document.modelContext.registerTool(tool, { signal: controller.signal });++ const tools = await document.modelContext.getTools();+ const registeredTool = tools.find(t => t.name === "empty_annotated_tool");++ const expectedAnnotations = {+ readOnlyHint: false,+ untrustedContentHint: false,+ consequentialHint: false,+ debugging: false,+ };+ assert_object_equals(registeredTool.annotations, expectedAnnotations,+ "annotations object should match exactly the expected IDL default properties and values");+}, "Test that getTools() returns default values when annotations object is empty");++promise_test(async t => {+ const tool = {+ name: "unannotated_tool",+ description: "A tool without annotations property",+ execute: () => {},+ };++ const controller = new AbortController();+ t.add_cleanup(() => controller.abort());+ await document.modelContext.registerTool(tool, { signal: controller.signal });++ const tools = await document.modelContext.getTools();+ const registeredTool = tools.find(t => t.name === "unannotated_tool");+ assert_equals(registeredTool.annotations, undefined, "annotations property should be undefined when omitted at registration");+}, "Test that getTools() returns undefined annotations when omitted at registration");+</script>+</body>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/getTools-imperative-schema.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/getTools-imperative-schema.https.htmlnew file mode 100644index 000000000..37e4b5bc2--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/getTools-imperative-schema.https.html@@ -0,0 +1,63 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>WebMCP: getTools() retrieves imperative schema at registration time</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<body>+<script>+ promise_test(async t => {+ const tool = {+ name: "search_tool",+ description: "Search the web",+ inputSchema: {+ type: "object",+ properties: {+ query: {+ type: "string",+ description: "The search query",+ },+ limit: {+ type: "number",+ description: "Max results count",+ },+ safe_search: {+ type: "boolean",+ description: "Enable safe search filtering",+ },+ },+ required: ["query"],+ },+ execute: () => {},+ };++ await document.modelContext.registerTool(tool);++ const tools = await document.modelContext.getTools();+ assert_equals(tools.length, 1, "Exactly one tool should be registered");++ const registeredTool = tools[0];+ assert_equals(registeredTool.name, "search_tool", "Tool name matches registered tool");+ assert_equals(registeredTool.description, "Search the web", "Tool description matches registered tool");++ assert_true(!!registeredTool.inputSchema, "inputSchema should be non-empty");+ assert_equals(registeredTool.inputSchema.type, "object", "Schema should be an object");++ // 'query' property validation (required string)+ assert_true("query" in registeredTool.inputSchema.properties, "Schema should contain 'query' property");+ assert_equals(registeredTool.inputSchema.properties.query.type, "string", "Query property type should be string");+ assert_equals(registeredTool.inputSchema.properties.query.description, "The search query", "Query property description is correct");+ assert_array_equals(registeredTool.inputSchema.required, ["query"], "Query should be a required property");++ // 'limit' property validation (optional number)+ assert_true("limit" in registeredTool.inputSchema.properties, "Schema should contain 'limit' property");+ assert_equals(registeredTool.inputSchema.properties.limit.type, "number", "Limit property type should be number");+ assert_equals(registeredTool.inputSchema.properties.limit.description, "Max results count", "Limit property description is correct");++ // 'safe_search' property validation (optional boolean)+ assert_true("safe_search" in registeredTool.inputSchema.properties, "Schema should contain 'safe_search' property");+ assert_equals(registeredTool.inputSchema.properties.safe_search.type, "boolean", "safe_search property type should be boolean");+ assert_equals(registeredTool.inputSchema.properties.safe_search.description, "Enable safe search filtering", "safe_search property description is correct");+ }, "Test that getTools() returns the correct inputSchema for an imperative tool");+</script>+</body>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/getTools.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/getTools.https.htmlnew file mode 100644index 000000000..f16f2cccd--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/getTools.https.html@@ -0,0 +1,39 @@+<!DOCTYPE html>+<html>+<head>+<title>WebMCP getTools()</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+</head>+<body>+<script>+promise_test(async (t) => {+ const tool_c = { name: 'c', description: 'tool registered first', execute: () => {} };+ const tool_b = { name: 'b', description: 'tool registered second', execute: () => {} };+ const tool_a = { name: 'a', description: 'tool registered last', execute: () => {} };++ const controller_b = new AbortController();++ // Register tool_c, tool_b, and tool_a tools in this specific order.+ await document.modelContext.registerTool(tool_c);+ await document.modelContext.registerTool(tool_b, { signal: controller_b.signal });+ await document.modelContext.registerTool(tool_a);++ let tools = await document.modelContext.getTools();+ assert_equals(tools.length, 3, 'Should find exactly the 3 registered tools');+ assert_equals(tools[0].name, 'a', 'First tool should be "a"');+ assert_equals(tools[1].name, 'b', 'Second tool should be "b"');+ assert_equals(tools[2].name, 'c', 'Third tool should be "c"');++ // Unregistering tool_b should still preserve lexicographical order.+ controller_b.abort();++ tools = await document.modelContext.getTools();+ assert_equals(tools.length, 2, 'Should find exactly the 3 registered tools');+ assert_equals(tools[0].name, 'a', 'First tool should be "a"');+ assert_equals(tools[1].name, 'c', 'Second tool should be "c"');+}, 'getTools should return all tools sorted in lexicographical order');+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/initial-about-blank-shared-tool.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/initial-about-blank-shared-tool.https.htmlnew file mode 100644index 000000000..cc840b17c--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/initial-about-blank-shared-tool.https.html@@ -0,0 +1,35 @@+<!DOCTYPE html>+<meta charset="utf-8">+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<body>+<script>+promise_test(async t => {+ const iframe = document.createElement('iframe');+ iframe.src = '/';+ document.body.append(iframe);+ // Register a tool with the initial about:blank Document [1].+ //+ // [1]: https://html.spec.whatwg.org/#is-initial-about:blank.+ iframe.contentWindow.document.modelContext.registerTool({+ name: "default-tool",+ description: "default desc",+ execute: async () => "hello"+ });+ assert_equals(iframe.contentDocument.URL, "about:blank");++ let tools = await iframe.contentWindow.document.modelContext.getTools();+ assert_equals(tools.length, 1);+ assert_equals(tools[0].name, "default-tool");++ // Wait for the iframe navigation to complete.+ await new Promise(resolve => iframe.onload = resolve);+ assert_not_equals(iframe.contentDocument.URL, "about:blank");+ // Note that the tool still incorrectly persists, even though we've navigated+ // away from the initial about:blank Document.+ tools = await iframe.contentWindow.document.modelContext.getTools();+ assert_array_equals(tools, []);+}, "tools registered with the initial about:blank Document do not survive navigation");+</script>+</body>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/model_context.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/model_context.https.htmlnew file mode 100644index 000000000..023deba23--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/model_context.https.html@@ -0,0 +1,20 @@+<!DOCTYPE html>+<html>+<head>+<title>WebMCP modelContext interface</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+</head>+<body>+<script>+test(() => {+ assert_true(document.modelContext instanceof ModelContext);+}, 'document.modelContext instanceof ModelContext');++test(() => {+ assert_equals(document.modelContext, document.modelContext);+}, 'document.modelContext SameObject');+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/non-secure.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/non-secure.htmlnew file mode 100644index 000000000..632fef6ec--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/non-secure.html@@ -0,0 +1,16 @@+<!DOCTYPE html>+<html>+<head>+<title>WebMCP restricted to secure contexts</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+</head>+<body>+<script>+test(() => {+ assert_false(document.hasOwnProperty('modelContext'));+}, `document.modelContext is not supported in non-secure context.`);+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/object-arguments.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/object-arguments.https.htmlnew file mode 100644index 000000000..c4259ec2f--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/object-arguments.https.html@@ -0,0 +1,76 @@+<!DOCTYPE html>+<title>tool execution requires a JSON Object input argument; and Arrays are Objects</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script>+promise_test(async t => {+ let executeReceivedArgs = null;+ const tool = {+ name: "test-tool",+ description: "Tool for testing various JSON primitive inputs",+ execute: (args) => {+ executeReceivedArgs = args;+ return "Success";+ }+ };++ await document.modelContext.registerTool(tool);+ const [registeredTool] = await document.modelContext.getTools();++ // Pass an array. Since arrays are ECMAScript objects, this succeeds.+ const arrayArgs = [1, 2, 3];+ const result = await document.modelContext.executeTool(registeredTool, arrayArgs);+ assert_equals(result, "Success");+ assert_array_equals(executeReceivedArgs, [1, 2, 3]);++ // Now pass non-Object JSON primitives as the argument, and observe a failure.+ const stringArgs = "hello";+ await promise_rejects_js(t, TypeError,+ document.modelContext.executeTool(registeredTool, stringArgs),+ "Primitive string should be rejected");++ const numberArgs = 123;+ await promise_rejects_js(t, TypeError,+ document.modelContext.executeTool(registeredTool, numberArgs),+ "Primitive number should be rejected");++ const booleanArgs = true;+ await promise_rejects_js(t, TypeError,+ document.modelContext.executeTool(registeredTool, booleanArgs),+ "Primitive boolean should be rejected");++ const nullArgs = null;+ await promise_rejects_js(t, TypeError,+ document.modelContext.executeTool(registeredTool, nullArgs),+ "null should be rejected");++ // Pass an object whose toJSON() method returns undefined, and observe+ // a failure.+ const nullishObject = { toJSON: () => undefined };+ await promise_rejects_js(t, TypeError,+ document.modelContext.executeTool(registeredTool, nullishObject),+ "Object whose toJSON() returns undefined should be rejected");++ // Omitting input argument defaults to {}+ executeReceivedArgs = null;+ const defaultResult = await document.modelContext.executeTool(registeredTool);+ assert_equals(defaultResult, "Success");+ assert_object_equals(executeReceivedArgs, {});++ // Per Web IDL, explicitly passing undefined for an optional argument is the+ // same as omitting it, so it also defaults to {}.+ executeReceivedArgs = null;+ const undefinedResult =+ await document.modelContext.executeTool(registeredTool, undefined);+ assert_equals(undefinedResult, "Success");+ assert_object_equals(executeReceivedArgs, {});++ // Same as above, but with a subsequent argument present.+ executeReceivedArgs = null;+ const undefinedWithOptionsResult =+ await document.modelContext.executeTool(registeredTool, undefined, {});+ assert_equals(undefinedWithOptionsResult, "Success");+ assert_object_equals(executeReceivedArgs, {});+}, "tool execution requires a JSON Object input argument; and Arrays are Objects");+</script>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/opaque-origin-tools.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/opaque-origin-tools.https.htmlnew file mode 100644index 000000000..549c0cd1d--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/opaque-origin-tools.https.html@@ -0,0 +1,101 @@+<!DOCTYPE html>+<html>+<head>+<title>WebMCP Opaque Origin Tool</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+</head>+<body>+<script>+promise_test(async t => {+ // Assert that our CSP header took effect.+ assert_equals(self.origin, 'null');++ await document.modelContext.registerTool({+ name: 'opaque_tool',+ description: 'Opaque tool description',+ execute: async () => 'success'+ });++ // The tool should be available, but its execution is rejected because opaque+ // origins lose their same-origin identity during string serialization ("null").+ const tools = await document.modelContext.getTools();+ const tool = tools.find(t => t.name === 'opaque_tool');++ await promise_rejects_dom(+ t,+ 'NotSupportedError',+ document.modelContext.executeTool(tool),+ 'executeTool() must reject with NotSupportedError in opaque origin documents'+ );+}, 'An opaque origin document can register but not execute its own tools');++// The below three tests are almost the same, with the following distinctions:+// 1. The first test asserts that executing a tool whose origin as returned+// from `getTools()` is "null", synchronously rejects the execution+// Promise. "null" fails to parse as a URL, because we don't parse it+// relative to the document's URL as a base URL.+// 2. The second and third tests below, captured by+// `invalid_execution_origins`, don't reference legitimately-registered+// tools. Instead, they test when the passed-in tool origin is:+//+// a.) An invalid URL that's not a single "null" string value. Rather, it's+// an `https://` URL that fails to parse due to an invalid port.+// b.) A string that successfully parses as a URL, but whose origin is opaque.+promise_test(async t => {+ const tools = await document.modelContext.getTools();+ const tool = tools.find(t => t.name === 'opaque_tool');+ assert_equals(tool.origin, "null", "getTools() gives");++ let events = [];+ const p = document.modelContext.executeTool(tool);++ // Since `executeTool()` synchronously rejects the Promise for opaque origins,+ // the microtask to run the catch reaction is already queued before+ // `queueMicrotask()` is invoked below.+ p.catch(() => events.push('rejection'));++ // Queue another microtask immediately after.+ queueMicrotask(() => events.push('microtask'));++ await promise_rejects_dom(+ t,+ 'NotSupportedError',+ document.modelContext.executeTool(tool, {"param1":"value"}),+ 'executeTool() must reject with NotSupportedError in opaque origin documents'+ );++ assert_array_equals(events, ['rejection', 'microtask'],+ 'returned promise is rejected before custom microtask is queued');+}, 'executeTool() rejects synchronously for origin "null" that fails to parse as a URL');++const invalid_execution_origins = ["https://test.example:invalidport", "data:text/html,foo"];+for (const invalid_origin of invalid_execution_origins) {+ promise_test(async t => {+ const fake_tool = {+ name: 'data_opaque_tool',+ description: 'Data URL opaque tool description',+ window: window,+ origin: invalid_origin+ };++ let events = [];+ const p = document.modelContext.executeTool(fake_tool);+ p.catch(() => events.push('rejection'));++ // Queue another microtask immediately after.+ queueMicrotask(() => events.push('microtask'));++ await promise_rejects_dom(+ t,+ 'NotSupportedError',+ document.modelContext.executeTool(fake_tool, {"param1":"value"}));++ assert_array_equals(events, ['rejection', 'microtask'],+ 'returned promise is rejected before custom microtask is queued');+ }, `executeTool() rejects synchronously for invalid origin: ${invalid_origin}`);+}+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/opaque-origin-tools.https.html.headers b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/opaque-origin-tools.https.html.headersnew file mode 100644index 000000000..1efcf8c22--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/opaque-origin-tools.https.html.headers@@ -0,0 +1 @@+Content-Security-Policy: sandbox allow-scriptsdiff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/permissions-policy.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/permissions-policy.https.htmlnew file mode 100644index 000000000..7e635a2a7--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/permissions-policy.https.html@@ -0,0 +1,115 @@+<!DOCTYPE html>+<html>+<head>+<title>Permission policy enforcement</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script src="/common/get-host-info.sub.js"></script>+</head>+<body>+<script>+const host_info = get_host_info();++promise_test(async t => {+ const iframe = document.createElement('iframe');++ const origin_b = host_info.HTTPS_REMOTE_ORIGIN;+ const origin_c = host_info.HTTPS_OTHER_NOTSAMESITE_ORIGIN;++ iframe.src = origin_b + '/webmcp/imperative/resources/iframe-register-tool.html';+ iframe.allow = `tools ${origin_b}`;++ const load_promise = new Promise(resolve => iframe.onload = resolve);+ document.body.appendChild(iframe);+ t.add_cleanup(() => iframe.remove());+ await load_promise;++ const toolchange_promise = new Promise((resolve) => {+ document.modelContext.addEventListener('toolchange', resolve, {once: true});+ });++ iframe.contentWindow.postMessage({+ action: 'register',+ tool: { name: 'iframe_tool', description: 'Origin B tool' },+ options: { exposedTo: [host_info.HTTPS_ORIGIN] }+ }, '*');+ await toolchange_promise;++ const navigate_promise = new Promise(resolve => iframe.onload = resolve);+ iframe.src = origin_c + '/webmcp/imperative/resources/iframe-register-tool.html';+ await navigate_promise;++ const failure_promise = new Promise(resolve => {+ window.addEventListener('message', e => {+ if (e.data.startsWith('tool registration failed:')) {+ resolve(e.data);+ }+ }, {once: true});+ });++ iframe.contentWindow.postMessage({+ action: 'register',+ tool: { name: 'iframe_tool', description: 'Origin C tool' }+ }, '*');+ const failure_msg = await failure_promise;++ assert_true(failure_msg.includes('NotAllowedError'), `Expected NotAllowedError in navigated iframe, got: ${failure_msg}`);+}, 'registerTool() rejects in iframe, after navigation to an origin not covered by permissions policy');++promise_test(async t => {+ const iframe = document.createElement('iframe');+ const origin_b = host_info.HTTPS_REMOTE_ORIGIN;++ iframe.src = origin_b + '/webmcp/imperative/resources/iframe-register-tool.html';+ // No `allow` attribute.++ const load_promise = new Promise(resolve => iframe.onload = resolve);+ document.body.appendChild(iframe);+ t.add_cleanup(() => iframe.remove());+ await load_promise;++ const failure_promise = new Promise(resolve => {+ window.addEventListener('message', e => {+ if (typeof e.data === 'string' && e.data.startsWith('getTools promise rejected:')) {+ resolve(e.data);+ }+ }, {once: true});+ });++ iframe.contentWindow.postMessage('getTools', '*');+ const failure_msg = await failure_promise;++ assert_true(failure_msg.includes('NotAllowedError'), `Expected NotAllowedError in iframe, got: ${failure_msg}`);+}, 'getTools() throws NotAllowedError in iframe when permissions policy is disabled');++promise_test(async t => {+ const iframe = document.createElement('iframe');+ const origin_b = host_info.HTTPS_REMOTE_ORIGIN;++ iframe.src = origin_b + '/webmcp/imperative/resources/iframe-register-tool.html';+ // No `allow` attribute.++ const load_promise = new Promise(resolve => iframe.onload = resolve);+ document.body.appendChild(iframe);+ t.add_cleanup(() => iframe.remove());+ await load_promise;++ const failure_promise = new Promise(resolve => {+ window.addEventListener('message', e => {+ if (e.data.action === 'executeFakeToolResponse') {+ resolve(e.data);+ }+ }, {once: true});+ });++ // Direct the iframe to construct a conceivable `RegisteredTool` and call+ // `executeTool()` on it.+ iframe.contentWindow.postMessage({ action: 'execute_fake_tool', name: 'dummy_tool' }, '*');+ const response = await failure_promise;++ assert_equals(response.error_name, 'NotAllowedError', 'Should reject with NotAllowedError');+}, 'executeTool() throws NotAllowedError in iframe when permissions policy is disabled');+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/register-tool-title.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/register-tool-title.https.htmlnew file mode 100644index 000000000..cd29e2724--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/register-tool-title.https.html@@ -0,0 +1,60 @@+<!DOCTYPE html>+<html>+<head>+<title>Tool title is exposed correctly</title>+<meta name="timeout" content="long">+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script src="/common/get-host-info.sub.js"></script>+<script src="resources/helpers.js"></script>+</head>+<body>+<script>+promise_test(async () => {+ await document.modelContext.registerTool({+ name: 'with-title',+ title: 'My Custom Title',+ description: 'tool with title',+ execute: async () => 'empty'+ });++ const tools = await document.modelContext.getTools();+ const tool = tools.find(t => t.name === 'with-title');++ assert_equals(tool.title, 'My Custom Title', 'Title is preserved');+}, 'Tool title is preserved when provided');++promise_test(async () => {+ await document.modelContext.registerTool({+ name: 'without-title',+ description: 'tool without title',+ execute: async () => 'empty'+ });++ const tools = await document.modelContext.getTools();+ const tool = tools.find(t => t.name === 'without-title');++ // If not provided upon registration, `title` should be empty string in the+ // dictionary.+ assert_equals(tool.title, '', 'Title is empty string when not provided');+}, 'Missing tool title in registration is exposed as empty string');++promise_test(async () => {+ // \uD800 is an unpaired high surrogate.+ await document.modelContext.registerTool({+ name: 'with-unpaired-surrogate',+ title: 'Title with \uD800 unpaired surrogate',+ description: 'tool with unpaired surrogate in title',+ execute: async () => 'empty'+ });++ const tools = await document.modelContext.getTools();+ const tool = tools.find(t => t.name === 'with-unpaired-surrogate');++ // USVString replaces unpaired surrogates with U+FFFD.+ assert_equals(tool.title, 'Title with \uFFFD unpaired surrogate');+}, 'Tool title with unpaired surrogate is fixed up by USVString');+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/register_tool_invalid_json_schema.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/register_tool_invalid_json_schema.https.htmlnew file mode 100644index 000000000..3182f0283--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/register_tool_invalid_json_schema.https.html@@ -0,0 +1,74 @@+<!DOCTYPE html>+<html>+<head>+<title>WebMCP registerTool throws on invalid schema</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+</head>+<body>+<script>+function test_register_tool_schema_error(inputSchema, testName) {+ promise_test((t) => {+ return promise_rejects_js(+ t,+ TypeError,+ document.modelContext.registerTool({+ name: 'empty',+ description: 'empty',+ inputSchema,+ execute: () => {},+ }),+ 'Should throw TypeError for invalid schema',+ );+ }, testName);+}++test_register_tool_schema_error(+ { toJSON: () => undefined },+ 'registerTool rejects when inputSchema.toJSON() returns undefined',+);++test_register_tool_schema_error(+ (() => {+ const circular = {};+ circular.self = circular;+ return circular;+ })(),+ 'registerTool rejects when inputSchema contains a circular reference',+);++test_register_tool_schema_error(+ BigInt(42),+ 'registerTool rejects when inputSchema contains non-serializable types (BigInt)',+);++promise_test(t => {+ // Register with invalid schema AND aborted signal. This asserts that input+ // schema validation happens before checking the aborted signal.+ const circularSchema = {};+ circularSchema.self = circularSchema;++ return promise_rejects_js(+ t,+ TypeError,+ document.modelContext.registerTool(+ {+ name: 'aborted_invalid_schema',+ description: 'empty',+ inputSchema: {+ type: "object",+ properties: {+ prop1: circularSchema,+ }+ },+ execute: () => {},+ },+ { signal: AbortSignal.abort('aborted') }+ ),+ 'Should reject with TypeError for circular input schema, before checking if the signal is aborted'+ );+}, 'registerTool rejects on invalid schema even if an aborted signal was provided');+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/register_tool_name_validation.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/register_tool_name_validation.https.htmlnew file mode 100644index 000000000..1a3329963--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/register_tool_name_validation.https.html@@ -0,0 +1,82 @@+<!DOCTYPE html>+<html>+<head>+<title>WebMCP registerTool rejects on invalid name</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+</head>+<body>+<script>+promise_test(async () => {+ // Valid names+ const validNames = [+ 'a',+ 'A',+ '0',+ 'valid-name',+ 'valid_name',+ 'valid.name',+ 'valid-name.with_extras-123',+ 'a'.repeat(128)+ ];++ for (const name of validNames) {+ await document.modelContext.registerTool({+ name: name,+ description: 'valid name test',+ execute: async () => 'empty'+ });+ }+}, 'Valid tool names are accepted.');++promise_test(async t => {+ // Invalid names+ const invalidNames = [+ '', // Empty+ 'a'.repeat(129), // Too long+ 'name with space',+ 'name@special',+ 'name#special',+ 'name$special',+ 'name%',+ 'name^',+ 'name&',+ 'name*',+ 'name(',+ 'name)',+ 'name+',+ 'name=',+ 'name[',+ 'name]',+ 'name{',+ 'name}',+ 'name|',+ 'name\\',+ 'name:',+ 'name;',+ 'name"',+ 'name\'',+ 'name<',+ 'name>',+ 'name?',+ 'name/',+ 'name`',+ 'name~',+ ];++ for (const name of invalidNames) {+ await promise_rejects_dom(t,+ 'InvalidStateError',+ document.modelContext.registerTool({+ name: name,+ description: 'invalid name test',+ execute: async () => 'empty'+ }),+ `Tool name '${name}' is invalid.`+ );+ }+}, 'Invalid tool names throw InvalidStateError.');+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/register_tool_no_schema.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/register_tool_no_schema.https.htmlnew file mode 100644index 000000000..8f76a9022--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/register_tool_no_schema.https.html@@ -0,0 +1,24 @@+<!DOCTYPE html>+<html>+<head>+<title>WebMCP registerTool succeeds without schema</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+</head>+<body>+<script>+promise_test(async () => {+ const tool = {+ name: 'empty',+ description: 'echo empty',+ execute: () => {},+ };++ const controller = new AbortController();+ await document.modelContext.registerTool(tool, { signal: controller.signal });+ controller.abort();+}, 'register tool with only required params');+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/register_tool_signal.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/register_tool_signal.https.htmlnew file mode 100644index 000000000..12f98ee38--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/register_tool_signal.https.html@@ -0,0 +1,54 @@+<!DOCTYPE html>+<html>+<head>+<title>WebMCP registerTool signal</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+</head>+<body>+<script>+const tool = {+ name: 'empty',+ description: 'empty',+ execute: () => {},+};++promise_test((t) => {+ const controller = new AbortController();+ const p = document.modelContext.registerTool(tool, { signal: controller.signal });+ controller.abort();+ return promise_rejects_dom(t, 'AbortError', p);+}, 'register tool promise rejects with AbortError when signal gets aborted');++promise_test((t) => {+ const controller = new AbortController();+ const p = document.modelContext.registerTool(tool, { signal: controller.signal });+ const error = new Error('abort error');+ controller.abort(error);+ return promise_rejects_exactly(t, error, p);+}, 'register tool promise rejects with error when signal gets aborted');++promise_test((t) => {+ const signal = AbortSignal.abort('aborted');+ const p = document.modelContext.registerTool(tool, { signal });+ return promise_rejects_exactly(t, 'aborted', p);+}, 'register tool promise rejects when signal is already aborted');++promise_test(async (t) => {+ let tools = await document.modelContext.getTools();+ assert_equals(tools.length, 0);++ const controller = new AbortController();+ await document.modelContext.registerTool(tool, { signal: controller.signal });++ tools = await document.modelContext.getTools();+ assert_equals(tools.length, 1);++ controller.abort();+ tools = await document.modelContext.getTools();+ assert_equals(tools.length, 0);+}, 'aborting signal unregister tool');+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/register_tool_toolchange.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/register_tool_toolchange.https.htmlnew file mode 100644index 000000000..64dc8d868--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/register_tool_toolchange.https.html@@ -0,0 +1,41 @@+<!DOCTYPE html>+<html>+<head>+<title>WebMCP toolchange</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+</head>+<body>+<script>+const tool = {+ name: 'empty',+ description: 'empty',+ execute: () => {},+};++promise_test(async (t) => {+ const events = [];++ document.modelContext.addEventListener('toolchange', () => {+ events.push('toolchange');+ }, { once: true });++ const p = document.modelContext.registerTool(tool);++ p.then(() => {+ events.push('resolve');+ });++ await p;++ assert_array_equals(+ events,+ ['toolchange', 'resolve'],+ 'toolchange event must trigger before registerTool promise resolves'+ );+}, 'registerTool triggers toolchange before promise resolves');++</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/register_tool_with_empty_annotation.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/register_tool_with_empty_annotation.https.htmlnew file mode 100644index 000000000..6f38adfa0--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/register_tool_with_empty_annotation.https.html@@ -0,0 +1,27 @@+<!DOCTYPE html>+<html>+<head>+<title>WebMCP registerTool succeeds with empty annotations</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+</head>+<body>+<script>+promise_test(async() => {+ const tool = {+ name: 'echo',+ description: 'echo input',+ execute: (obj) => obj.text,+ annotations: {+ // No `readOnlyHint` member.+ },+ };++ const controller = new AbortController();+ await document.modelContext.registerTool(tool, { signal: controller.signal });+ controller.abort();+}, 'register tool with empty annotations');+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/register_tool_with_schema.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/register_tool_with_schema.https.htmlnew file mode 100644index 000000000..4a669cd58--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/register_tool_with_schema.https.html@@ -0,0 +1,50 @@+<!DOCTYPE html>+<html>+<head>+<title>WebMCP registerTool</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+</head>+<body>+<script>+promise_test(async () => {+ const tool = {+ name: 'echo',+ description: 'echo input',+ inputSchema: {+ type: 'object',+ properties: {+ text: {+ description: 'Value to echo',+ type: 'string',+ },+ },+ required: ['text'],+ },+ execute: (obj) => obj.text,+ annotations: {+ readOnlyHint: 'true',+ },+ };++ const controller = new AbortController();+ await document.modelContext.registerTool(tool, { signal: controller.signal });+ controller.abort();+}, 'register and unregister script tool');++promise_test(async () => {+ await document.modelContext.registerTool({+ name: 'empty',+ description: 'empty',+ inputSchema: {+ toJSON: () => {+ return 'undefined';+ },+ },+ execute: () => {},+ });+}, "registerTool succeeds when inputSchema.toJSON() returns 'undefined'");+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/resources/helpers.js b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/resources/helpers.jsnew file mode 100644index 000000000..27e106663--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/resources/helpers.js@@ -0,0 +1,47 @@+// Helper to wait for postMessage response from iframe+function waitForIframeMessage(action) {+ return new Promise(resolve => {+ const listener = e => {+ if (e.data && e.data.action === action) {+ window.removeEventListener('message', listener);+ resolve(e.data);+ }+ };+ window.addEventListener('message', listener);+ });+}++// Helper to compare tool objects that should conform to the `RegisteredTool`+// dictionary.+function toolsAreEqual(actual, expected) {+ if (actual.name !== expected.name) {+ return `names are unequal: ${actual.name} !== ${expected.name}`;+ }+ if (actual.description !== expected.description) {+ return `descriptions are unequal: ${actual.description} !== ${expected.description}`;+ }+ if (JSON.stringify(actual.inputSchema) !==+ JSON.stringify(expected.inputSchema)) {+ return `inputSchemas are unequal: ${+ JSON.stringify(+ actual.inputSchema)} !== ${JSON.stringify(expected.inputSchema)}`;+ }+ if (actual.origin !== expected.origin) {+ return `origins are unequal: ${actual.origin} !== ${expected.origin}`;+ }+ if (actual.annotations?.readOnlyHint !== expected.annotations?.readOnlyHint) {+ return `readOnlyHints are unequal: ${actual.annotations?.readOnlyHint} !== ${expected.annotations?.readOnlyHint}`;+ }+ if (actual.annotations?.untrustedContentHint !== expected.annotations?.untrustedContentHint) {+ return `untrustedContentHints are unequal: ${actual.annotations?.untrustedContentHint} !== ${expected.annotations?.untrustedContentHint}`;+ }+ if (actual.annotations?.consequentialHint !== expected.annotations?.consequentialHint) {+ return `consequentialHints are unequal: ${actual.annotations?.consequentialHint} !== ${expected.annotations?.consequentialHint}`;+ }+ if (actual.annotations?.debugging !== expected.annotations?.debugging) {+ return `debuggings are unequal: ${actual.annotations?.debugging} !== ${+ expected.annotations?.debugging}`;+ }++ return true;+}diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/resources/iframe-caller-and-target-crash.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/resources/iframe-caller-and-target-crash.htmlnew file mode 100644index 000000000..5ceaa1a9b--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/resources/iframe-caller-and-target-crash.html@@ -0,0 +1,17 @@+<!DOCTYPE html>+<script>+async function run() {+ await document.modelContext.registerTool({+ name: "test_tool",+ description: "Test tool",+ execute: async () => {+ parent.postMessage({action: "tool_started"}, "*");+ await new Promise(() => {}); // Hangs forever+ }+ });+ const tools = await document.modelContext.getTools();+ const tool = tools.find(t => t.name === "test_tool");+ document.modelContext.executeTool(tool);+}+run();+</script>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/resources/iframe-caller.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/resources/iframe-caller.htmlnew file mode 100644index 000000000..f44ebfe03--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/resources/iframe-caller.html@@ -0,0 +1,40 @@+<!DOCTYPE html>+<html>+<head>+<title>WebMCP Iframe Caller</title>+<script src="/resources/testharness.js"></script>+</head>+<body>+<script>+ window.onmessage = e => {+ if (e.data.action === 'invoke') {+ const options = e.data.options || {};+ document.modelContext.getTools(options).then(tools => {+ const tool = tools.find(t => t.name === e.data.name);+ document.modelContext.executeTool(tool).then(result => {+ parent.postMessage({action: 'executeResponse', result: result, success: true}, '*');+ }).catch(err => {+ parent.postMessage({action: 'executeResponse', result: String(err), success: false}, '*');+ });+ });+ } else if (e.data.action === 'invoke_with_abort') {+ const options = e.data.options || {};+ const controller = new AbortController();+ document.modelContext.getTools(options).then(tools => {+ const tool = tools.find(t => t.name === e.data.name);+ document.modelContext.executeTool(tool, {}, { signal: controller.signal }).then(result => {+ parent.postMessage({action: 'executeResponse', result: result, success: true}, '*');+ }).catch(err => {+ parent.postMessage({action: 'executeResponse', result: String(err), success: false}, '*');+ });+ step_timeout(() => {+ controller.abort(e.data.abortReason || 'iframe aborted');+ }, e.data.abortDelayMs || 50);+ });+ } else if (e.data.action === 'navigate') {+ window.location.href = 'about:blank';+ }+ };+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/resources/iframe-register-tool.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/resources/iframe-register-tool.htmlnew file mode 100644index 000000000..759712e1f--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/resources/iframe-register-tool.html@@ -0,0 +1,135 @@+<!DOCTYPE html>+<html>+<head>+<title>WebMCP Iframe Tool Registration</title>+<script src="/resources/testharness.js"></script>+</head>+<body>+<script>+ // This is a helper function to convert an array of `RegisteredTool`+ // dictionaries to objects that can be sent over `postMessage()`. This exists+ // because the `RegisteredTool#window` member is not cloneable, so we must+ // reduce the tool structure a bit before sending it.+ function convertToCloneableTools(tools) {+ return tools.map(tool => {+ // An array of all relevant key/value pairs EXCEPT `window`.+ const entries = Object.entries(tool).filter(([key, _]) => key !== "window")+ return Object.fromEntries(entries);+ });+ }+ // Map from tool_name => `AbortController`, so that this iframe document can+ // manage/unregister any tool that it registers.+ const controllers = new Map();++ window.onmessage = async e => {+ const action = typeof e.data === 'string' ? e.data : e.data.action;++ if (action === 'register') {+ try {+ const controller = new AbortController();+ const tool = e.data.tool;+ if (e.data.delayResolutionAndReportAbort) {+ tool.execute = (input, opts) => new Promise((resolve, reject) => {+ parent.postMessage({ action: 'tool_started' }, '*');+ if (!opts || !opts.signal) {+ parent.postMessage({ action: 'signal_aborted_result', error: 'no signal provided' }, '*');+ return;+ }+ opts.signal.addEventListener('abort', () => {+ parent.postMessage({ action: 'signal_aborted_result', reason: String(opts.signal.reason) }, '*');+ });+ const finishListener = e => {+ if (typeof e.data === 'string' && e.data === 'finish_tool') {+ window.removeEventListener('message', finishListener);+ resolve('delayed_result');+ }+ };+ window.addEventListener('message', finishListener);+ });+ } else if (e.data.hangsForeverAndReportsAbort) {+ tool.execute = (input, opts) => new Promise((resolve, reject) => {+ parent.postMessage({ action: 'tool_started' }, '*');+ if (!opts || !opts.signal) {+ parent.postMessage({ action: 'signal_aborted_result', error: 'no signal provided' }, '*');+ return;+ }+ opts.signal.addEventListener('abort', () => {+ parent.postMessage({ action: 'signal_aborted_result', reason: String(opts.signal.reason) }, '*');+ });+ });+ } else if (e.data.hangsForever) {+ tool.execute = () => new Promise(() => {});+ } else {+ tool.execute = async () => 'hello from iframe';+ }++ const givenOptions = e.data.options;+ const options = { signal: controller.signal, ...givenOptions};++ await document.modelContext.registerTool(tool, options);+ controllers.set(tool.name, controller);+ } catch (e) {+ parent.postMessage(`tool registration failed: ${e}`, '*');+ }+ } else if (action === 'unregister') {+ try {+ const name = e.data.name || 'default_iframe_tool';+ const controller = controllers.get(name);+ if (controller) {+ controller.abort();+ controllers.delete(name);+ }+ } catch (e) {+ parent.postMessage(`tool unregistration failed: ${e}`, '*');+ }+ } else if (action === 'getTools') {+ const options = e.data.options || {};+ document.modelContext.getTools(options).then(tools => {+ parent.postMessage({action: 'getToolsResponse', tools: convertToCloneableTools(tools)}, '*');+ }).catch(e => {+ parent.postMessage(`getTools promise rejected: ${e}`, '*');+ });+ } else if (action === 'execute') {+ const name = e.data.name;+ const args = e.data.args || {};+ const options = e.data.options || {};+ document.modelContext.getTools(options).then(tools => {+ const tool = tools.find(t => t.name === name);+ document.modelContext.executeTool(tool, args).then(result => {+ parent.postMessage({action: 'executeResponse', result: result, success: true}, '*');+ }).catch(err => {+ parent.postMessage({action: 'executeResponse', result: String(err), success: false}, '*');+ });+ });+ } else if (action === 'execute_fake_tool') {+ const fake_tool = {+ name: e.data.name || 'dummy',+ description: 'fake desc',+ window: window,+ origin: self.origin+ };+ document.modelContext.executeTool(fake_tool).then(result => {+ parent.postMessage({action: 'executeFakeToolResponse', result: result, success: true}, '*');+ }).catch(err => {+ parent.postMessage({action: 'executeFakeToolResponse', result: String(err), success: false, error_name: err.name}, '*');+ });+ } else if (action === 'listenForToolchange') {+ let timer_id;+ const listener = () => {+ clearTimeout(timer_id);+ parent.postMessage({ action: 'toolchange_result', result: 'fired' }, '*');+ };++ document.modelContext.addEventListener('toolchange', listener, { once: true });+ // Send ACK so the caller knows the listener is active.+ parent.postMessage({ action: 'toolchange_listening_ack' }, '*');++ timer_id = step_timeout(() => {+ document.modelContext.removeEventListener('toolchange', listener);+ parent.postMessage({ action: 'toolchange_result', result: 'timeout' }, '*');+ }, 4000);+ }+ };+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/same-origin-iframe-registerTool-regression.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/same-origin-iframe-registerTool-regression.https.htmlnew file mode 100644index 000000000..78b7cd16f--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/same-origin-iframe-registerTool-regression.https.html@@ -0,0 +1,29 @@+<!DOCTYPE html>+<html>+<head>+<title>same-origin registerTool() regression test</title>+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+</head>+<body>+<script>+promise_test(async t => {+ const iframe = document.createElement('iframe');+ iframe.src = '/common/blank.html';++ const load_promise = new Promise(resolve => iframe.onload = resolve);+ document.body.appendChild(iframe);+ await load_promise;++ const iframe_document = iframe.contentWindow.document;++ // Should not reject!+ await iframe_document.modelContext.registerTool({+ name: 'connected_tool',+ description: 'Tool registered in connected frame',+ execute: async () => 'hello'+ });+}, 'registerTool() does not reject in connected same-origin iframe navigated away of about:blank');+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/unregister-during-executeTool.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/unregister-during-executeTool.https.htmlnew file mode 100644index 000000000..5ee502ef6--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/imperative/unregister-during-executeTool.https.html@@ -0,0 +1,125 @@+<!DOCTYPE html>+<html>+<head>+<title>WebMCP executeTool with Unregistered Cross-Origin Tool</title>+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>+<script src="/common/get-host-info.sub.js"></script>+<script src="resources/helpers.js"></script>+</head>+<body>+<script>+const host_info = get_host_info();++promise_test(async t => {+ const iframe = document.createElement('iframe');+ iframe.src = `${host_info.HTTPS_REMOTE_ORIGIN}/webmcp/imperative/resources/iframe-register-tool.html`;+ iframe.allow = 'tools *';++ const load_promise = new Promise(resolve => iframe.onload = resolve);+ document.body.appendChild(iframe);+ t.add_cleanup(() => iframe.remove());+ await load_promise;++ const toolStartedPromise = new Promise(resolve => window.addEventListener('message', e => {+ if (e.data?.action === 'tool_started') {+ resolve();+ }+ }, { once: true }));++ const toolchange_promise = new Promise(resolve => {+ document.modelContext.addEventListener('toolchange', resolve, { once: true });+ });++ // 1. Tell the cross-origin iframe to register an endless tool,+ // exposing it to the parent origin.+ iframe.contentWindow.postMessage({+ action: 'register',+ tool: {+ name: 'endless_tool',+ description: 'Endless tool in iframe'+ },+ options: { exposedTo: [self.origin] },+ delayResolutionAndReportAbort: true+ }, '*');++ await toolchange_promise;++ const tools = await document.modelContext.getTools(+ {fromOrigins: [host_info.HTTPS_REMOTE_ORIGIN]});+ const tool = tools.find(t => t.name === 'endless_tool');+ assert_true(!!tool, 'Tool should be registered and visible to parent');++ // 2. Run the tool, and wait for the iframe to report back that execution has+ // begun.+ const executePromise = document.modelContext.executeTool(tool);+ await toolStartedPromise;++ // Before we tell the iframe to unregister the tool, set up a handler to+ // confirm that this does not abort the tool's signal.+ window.addEventListener('message', e => {+ if (e.data?.action === 'signal_aborted_result') {+ assert_unreached('options.signal on tool side should NOT be aborted when tool is unregistered');+ }+ }, { once: true });++ const nextToolChangePromise = new Promise(resolve =>+ document.modelContext.addEventListener('toolchange', resolve, { once: true }));++ // 3. Unregister the tool in the target iframe while execution is pending.+ iframe.contentWindow.postMessage({+ action: 'unregister',+ name: 'endless_tool'+ }, '*');+ await nextToolChangePromise;++ const currentTools = await document.modelContext.getTools(+ {fromOrigins: [host_info.HTTPS_REMOTE_ORIGIN]});+ assert_array_equals(currentTools, [], 'Unregistered tool should no longer be returned by getTools()');++ // 4. Tell iframe to finish tool execution.+ iframe.contentWindow.postMessage('finish_tool', '*');++ const result = await executePromise;+ assert_equals(result, 'delayed_result', 'Pending execution Promise should resolve to tool result even if tool was unregistered mid-execution');+}, 'Pending executeTool() Promise resolves successfully when the target cross-origin tool is unregistered mid-execution');++promise_test(async t => {+ const regController = new AbortController();+ t.add_cleanup(() => regController.abort());++ const { promise: toolStartedPromise, resolve: resolveToolStarted } = Promise.withResolvers();+ const { promise: finishToolPromise, resolve: resolveFinishTool } = Promise.withResolvers();++ await document.modelContext.registerTool({+ name: 'same_doc_unregister_tool',+ description: 'Test unregister during exec in same doc',+ execute: (input, options) => new Promise(resolve => {+ options.signal.onabort = t.unreached_func('tool options.signal should NOT be aborted when tool is unregistered');+ resolveToolStarted();+ finishToolPromise.then(() => resolve('same_doc_result'));+ })+ }, { signal: regController.signal });++ const [tool] = await document.modelContext.getTools();+ const executePromise = document.modelContext.executeTool(tool);++ await toolStartedPromise;++ const toolChangePromise = new Promise(resolve =>+ document.modelContext.addEventListener('toolchange', resolve, { once: true }));+ regController.abort();+ await toolChangePromise;++ const tools = await document.modelContext.getTools();+ assert_array_equals(tools, [], 'Unregistered tool should no longer be returned by getTools()');++ resolveFinishTool();++ const result = await executePromise;+ assert_equals(result, 'same_doc_result', 'Pending execution Promise should resolve to tool result even if target tool was unregistered mid-execution');+}, 'Pending executeTool() Promise resolves successfully when target same-document tool is unregistered mid-execution');+</script>+</body>+</html>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/resources/helpers.js b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/resources/helpers.jsnew file mode 100644index 000000000..d02d1facd--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/resources/helpers.js@@ -0,0 +1,43 @@+// Wait for a declarative WebMCP tool to register with the specified name.+async function waitForTool(name) {+ const tools = await document.modelContext.getTools();+ const tool = tools.find(t => t.name === name);+ if (tool) {+ return tool;+ }+ return new Promise(resolve => {+ const handler = async () => {+ const tools = await document.modelContext.getTools();+ const tool = tools.find(t => t.name === name);+ if (tool) {+ document.modelContext.removeEventListener('toolchange', handler);+ resolve(tool);+ }+ };+ document.modelContext.addEventListener('toolchange', handler);+ });+}++// Wait for the active WebMCP tool's input schema to match the expected schema.+async function waitForFormToolSchemaToMatch(expected_schema) {+ const isMatch = (tool) => {+ if (!tool)+ return false;+ return JSON.stringify(tool.inputSchema) === JSON.stringify(expected_schema);+ };++ const [tool] = await document.modelContext.getTools();+ if (isMatch(tool)) {+ return tool;+ }+ return new Promise(resolve => {+ const ac = new AbortController();+ document.modelContext.addEventListener('toolchange', async e => {+ const [tool] = await document.modelContext.getTools();+ if (isMatch(tool)) {+ resolve(tool);+ ac.abort();+ }+ }, {signal: ac.signal});+ });+}diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/tool-activated-event.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/tool-activated-event.https.htmlnew file mode 100644index 000000000..07814c83c--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/tool-activated-event.https.html@@ -0,0 +1,84 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>WebMCP: ToolActivatedEvent interface and ontoolactivated handler</title>+<link rel="help" href="https://webmachinelearning.github.io/webmcp/#tool-activated-event">+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>++<script>+test(() => {+ const event = new ToolActivatedEvent('toolactivated');+ assert_equals(event.type, 'toolactivated');+ assert_equals(event.toolName, '', 'toolName defaults to the empty string');+ assert_false(event.bubbles);+ assert_false(event.cancelable);+ assert_false(event.composed);+ assert_false(event.isTrusted);+}, 'ToolActivatedEvent constructor with default event init dictionary');++test(() => {+ const event = new ToolActivatedEvent('toolactivated', {+ toolName: 'my_tool',+ bubbles: true,+ cancelable: true,+ composed: true,+ });+ assert_equals(event.toolName, 'my_tool');+ assert_true(event.bubbles);+ assert_true(event.cancelable);+ assert_true(event.composed);+}, 'ToolActivatedEvent constructor with an event init dictionary');++test(t => {+ const events = [];+ const handler = e => events.push(e);+ document.modelContext.ontoolactivated = handler;+ t.add_cleanup(() => { document.modelContext.ontoolactivated = null; });++ const event = new ToolActivatedEvent('toolactivated', { toolName: 'my_tool' });+ document.modelContext.dispatchEvent(event);++ assert_array_equals(events, [event],+ 'synthetic toolactivated events must reach ontoolactivated');+ assert_equals(events[0].target, document.modelContext);+ assert_equals(events[0].toolName, 'my_tool');+}, 'ontoolactivated is invoked for synthetic toolactivated events dispatched ' ++ 'at ModelContext');++promise_test(async t => {+ assert_equals(document.modelContext.ontoolactivated, null,+ 'ontoolactivated must initially be null');++ const events = [];+ const handler = e => events.push(e);+ document.modelContext.ontoolactivated = handler;+ t.add_cleanup(() => { document.modelContext.ontoolactivated = null; });+ assert_equals(document.modelContext.ontoolactivated, handler,+ 'ontoolactivated must reflect the assigned handler');++ const regController = new AbortController();+ t.add_cleanup(() => regController.abort());+ await document.modelContext.registerTool({+ name: 'onevent_tool',+ description: 'Tool used to trigger ontoolactivated',+ execute: () => 'result',+ }, { signal: regController.signal });++ const tools = await document.modelContext.getTools();+ const tool = tools.find(tool => tool.name === 'onevent_tool');+ await document.modelContext.executeTool(tool, {});++ assert_equals(events.length, 1, 'ontoolactivated must be invoked once');+ assert_true(events[0] instanceof ToolActivatedEvent);+ assert_equals(events[0].toolName, 'onevent_tool');++ document.modelContext.ontoolactivated = null;+ assert_equals(document.modelContext.ontoolactivated, null,+ 'ontoolactivated must be nullable');++ await document.modelContext.executeTool(tool, {});+ assert_equals(events.length, 1,+ 'the removed handler must not be invoked again');+}, 'ontoolactivated is invoked when a tool is activated');+</script>diff --git a/moli-wpt-compat/fixtures/wpt/upstream/webmcp/tool-cancel-event.https.html b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/tool-cancel-event.https.htmlnew file mode 100644index 000000000..1acb8ebc8--- /dev/null+++ b/moli-wpt-compat/fixtures/wpt/upstream/webmcp/tool-cancel-event.https.html@@ -0,0 +1,105 @@+<!DOCTYPE html>+<meta charset="utf-8">+<title>WebMCP: ToolCancelEvent interface and ontoolcancel handler</title>+<link rel="help" href="https://webmachinelearning.github.io/webmcp/#tool-cancel-event">+<link rel="author" href="mailto:[email protected]">+<script src="/resources/testharness.js"></script>+<script src="/resources/testharnessreport.js"></script>++<script>+test(() => {+ const event = new ToolCancelEvent('toolcancel');+ assert_equals(event.type, 'toolcancel');+ assert_equals(event.toolName, '', 'toolName defaults to the empty string');+ assert_false(event.bubbles);+ assert_false(event.cancelable);+ assert_false(event.composed);+ assert_false(event.isTrusted);+}, 'ToolCancelEvent constructor with default event init dictionary');++test(() => {+ const event = new ToolCancelEvent('toolcancel', {+ toolName: 'my_tool',+ bubbles: true,+ cancelable: true,+ composed: true,+ });+ assert_equals(event.toolName, 'my_tool');+ assert_true(event.bubbles);+ assert_true(event.cancelable);+ assert_true(event.composed);+}, 'ToolCancelEvent constructor with an event init dictionary');++test(t => {+ const events = [];+ const handler = e => events.push(e);+ document.modelContext.ontoolcancel = handler;+ t.add_cleanup(() => { document.modelContext.ontoolcancel = null; });++ const event = new ToolCancelEvent('toolcancel', { toolName: 'my_tool' });+ document.modelContext.dispatchEvent(event);++ assert_array_equals(events, [event],+ 'synthetic toolcancel events must reach ontoolcancel');+ assert_equals(events[0].target, document.modelContext);+ assert_equals(events[0].toolName, 'my_tool');+}, 'ontoolcancel is invoked for synthetic toolcancel events dispatched ' ++ 'at ModelContext');++promise_test(async t => {+ assert_equals(document.modelContext.ontoolcancel, null,+ 'ontoolcancel must initially be null');++ const events = [];+ const handler = e => events.push(e);+ document.modelContext.ontoolcancel = handler;+ t.add_cleanup(() => { document.modelContext.ontoolcancel = null; });+ assert_equals(document.modelContext.ontoolcancel, handler,+ 'ontoolcancel must reflect the assigned handler');++ const regController = new AbortController();+ t.add_cleanup(() => regController.abort());+ await document.modelContext.registerTool({+ name: 'onevent_tool',+ description: 'Tool used to trigger ontoolcancel',+ execute: () => new Promise(() => {}),+ }, { signal: regController.signal });++ const tools = await document.modelContext.getTools();+ const tool = tools.find(tool => tool.name === 'onevent_tool');++ // Executes the tool, aborts it, and resolves once the `toolcancel` event has+ // been dispatched at the ModelContext. The signal's abort steps reject the+ // executeTool() promise first, and only then cancel the pending tool+ // execution in parallel, which queues the task that fires `toolcancel`.+ // Awaiting the rejection alone is therefore not enough to observe the event.+ // https://webmachinelearning.github.io/webmcp/#cancel-a-pending-tool-execution+ const executeAndCancelTool = async () => {+ const cancelPromise = new Promise(resolve => {+ document.modelContext.addEventListener('toolcancel', resolve, { once: true });+ });+ const controller = new AbortController();+ const execPromise =+ document.modelContext.executeTool(tool, {}, { signal: controller.signal });+ const rejectPromise = promise_rejects_dom(t, 'AbortError', execPromise);+ controller.abort();+ await rejectPromise;+ await cancelPromise;+ };++ await executeAndCancelTool();++ assert_equals(events.length, 1, 'ontoolcancel must be invoked once');+ assert_true(events[0] instanceof ToolCancelEvent);+ assert_equals(events[0].toolName, 'onevent_tool');++ document.modelContext.ontoolcancel = null;+ assert_equals(document.modelContext.ontoolcancel, null,+ 'ontoolcancel must be nullable');++ await executeAndCancelTool();++ assert_equals(events.length, 1,+ 'the removed handler must not be invoked again');+}, 'ontoolcancel is invoked when a tool invocation is canceled');+</script>diff --git a/moli-wpt-compat/src/server.rs b/moli-wpt-compat/src/server.rsindex 0c3a61dd1..4150c4393 100644--- a/moli-wpt-compat/src/server.rs+++ b/moli-wpt-compat/src/server.rs@@ -797,6 +797,7 @@ fn wpt_fixture_app(runtime_state: WptFixtureRuntimeState) -> Router {.route("/common/blank.html", get(wpt_common_blank_html)).route("/common/{*path}", get(wpt_root_common_asset)).route("/resources/{*path}", get(wpt_root_resources_asset))+ .route("/webmcp/{*path}", get(wpt_root_webmcp_asset)).route("/workers/{*path}", get(wpt_root_workers_asset)).route("/wpt/{*path}", get(wpt_fixture_asset)).with_state(runtime_state)@@ -895,6 +896,14 @@ async fn wpt_root_common_asset(wpt_fixture_asset_response(&format!("upstream/common/{path}"), query, &runtime_state).await}+async fn wpt_root_webmcp_asset(+ Path(path): Path<String>,+ Query(query): Query<HashMap<String, String>>,+ State(runtime_state): State<WptFixtureRuntimeState>,+) -> Response {+ wpt_fixture_asset_response(&format!("upstream/webmcp/{path}"), query, &runtime_state).await+}+async fn wpt_root_workers_asset(Path(path): Path<String>,Query(query): Query<HashMap<String, String>>,@@ -1486,6 +1495,8 @@ fn wpt_substitution_value(_ if token.starts_with("domains[") || token.starts_with("hosts[") => {if token.contains("nonexistent") {Some(format!("nonexistent.{WPT_BROWSER_HOST}"))+ } else if token.contains("alt") && token.contains("www2") {+ Some("localhost.".to_owned())} else if token.contains("www1") || token.contains("alt") {Some(WPT_REMOTE_HOST.to_owned())} else {