[wpt-sync] Sync PR 61457 - WebMCP: Document and test Object arguments
Categories
(Testing :: web-platform-tests, task, P4)
Tracking
(firefox155 fixed)
| Tracking | Status | |
|---|---|---|
| firefox155 | --- | fixed |
People
(Reporter: wpt-sync, Unassigned)
References
()
Details
(Whiteboard: [wptsync downstream])
Sync web-platform-tests PR 61457 into mozilla-central (this bug is closed when the sync is complete).
PR: https://github.com/web-platform-tests/wpt/pull/61457
Details from upstream follow.
Dominic Farolino <dom@chromium.org> wrote:
WebMCP: Document and test Object arguments
WebMCP has a helper
JSONStringToScriptObject()to convert a string
into a JSON Object passed into the WebMCP tool execution callback, to
give the callback its arguments from the tool caller.Before this CL,
JSONStringToScriptObject()had an error branch for
handlingv8::String::NewFromUtf8()failures. At first I thought this
was to handle two cases:
- Invalid UTF-8 strings
- Whatever else might fail, which to my knowledge is only OOMs (and
we're generally comfortable crashing the renderer process for those)Upon further investigation, I found that (1) above was not possible,
because mojo strings are deserialized intoblink::Stringobjects via
blink::String::FromUTF8(), which is not a lenient conversion
mechanism, and returns a null string, which translates to a plain old
emptystd::stringwhen we calljson_string.Utf8()later.So I originally replaced this error branch with:
v8::Local\<v8::String> v8_json_string = v8::String::NewFromUtf8(script_state->GetIsolate(), json_string.Utf8().c_str()) .ToLocalChecked();But this still seemed wasteful:
- At mojo deserialization time, we perform full UTF-8 validation on a
std::string, and assign its contents to a blink::String.- Later, we call
blink::String::UTF8(), re-running UTF-8 validation
and producing a std::string.- Finally calling
v8::String::NewFromUtf8(), which allocates a whole
new string (and performs UTF-8 validation again, as I understand).So I found that there was a
V8String()helper in the Blink bindings
layer specifically for convertingblink::Stringvalues to JavaScript
strings. This helper avoids all of the UTF-8 re-validation, and handles
OOM renderer crashing.
Separately, this CL also adds more tests for another condition in that
same helper, which confirms that arrays are treated like Objects by
v8 and ECMAScript. Whether this is the exact behavior we want is a
matter of discussion in
https://github.com/webmachinelearning/webmcp/issues/92. But this CL just
aims to more-rigorously test and document the current behavior.Bug: 489045948
Change-Id: I8ea2bfdc9bb81402afbe9d1fa5f5c45a7ed79ad1
Reviewed-on: https://chromium-review.googlesource.com/8123202
WPT-Export-Revision: 559094c69d9431db7a04ad8afb9990934bc3147a
| Assignee | ||
Comment 1•4 months ago
|
||
Pushed to try (stability) https://treeherder.mozilla.org/#/jobs?repo=try&revision=66000d7317a36981384d103c669650aaba6c0d05
| Assignee | ||
Comment 2•4 months ago
|
||
CI Results
Ran 9 Firefox configurations based on mozilla-central, and Firefox, Chrome, and Safari on GitHub CI
Total 39 tests and 1 subtests
Status Summary
Firefox
OK : 1[GitHub] 35[Gecko-android-em-14-x86_64-debug-geckoview, Gecko-android-em-14-x86_64-lite-opt-geckoview, Gecko-android-em-14-x86_64-opt-geckoview, Gecko-linux2404-64-debug, Gecko-linux2404-64-opt, Gecko-windows11-32-25h2-debug, Gecko-windows11-32-25h2-opt, Gecko-windows11-64-25h2-debug, Gecko-windows11-64-25h2-opt]
PASS : 2
FAIL : 1[GitHub] 71[Gecko-android-em-14-x86_64-debug-geckoview, Gecko-android-em-14-x86_64-lite-opt-geckoview, Gecko-android-em-14-x86_64-opt-geckoview, Gecko-linux2404-64-debug, Gecko-linux2404-64-opt, Gecko-windows11-32-25h2-debug, Gecko-windows11-32-25h2-opt, Gecko-windows11-64-25h2-debug, Gecko-windows11-64-25h2-opt]
ERROR: 1
Chrome
OK : 1
PASS : 1
Safari
OK : 1
FAIL : 1
Links
Gecko CI (Treeherder)
GitHub PR Head
GitHub PR Base
Details
New Tests That Don't Pass
- /webmcp/imperative/exposedTo-cross-origin-child.https.html [wpt.fyi]:
SKIP - /webmcp/imperative/exposedTo-multiple-children.https.html [wpt.fyi]:
SKIP - /webmcp/imperative/permissions-policy.https.html [wpt.fyi]:
SKIP - /webmcp/imperative/detached-frame-executeTool.https.html [wpt.fyi]:
ERROR- executeTool() throws
InvalidStateErrorin detached frame:FAIL
- executeTool() throws
- /webmcp/imperative/detached-frame-getTools.https.html [wpt.fyi]
- getTools() throws
InvalidStateErrorin detached frame:FAIL
- getTools() throws
- /webmcp/imperative/detached-frame-registerTool.https.html [wpt.fyi]
- registerTool() rejects
InvalidStateErrorin detached frame:FAIL
- registerTool() rejects
- /webmcp/imperative/document-domain-enabled.https.html [wpt.fyi]
- modelContext.registerTool rejects with SecurityError when document.domain is enabled:
FAIL - modelContext.getTools rejects with SecurityError when document.domain is enabled:
FAIL - modelContext.executeTool rejects with SecurityError when document.domain is enabled:
FAIL
- modelContext.registerTool rejects with SecurityError when document.domain is enabled:
- /webmcp/imperative/duplicate_tool_registration.https.html [wpt.fyi]
- duplicate tool registration is invalid.:
FAIL
- duplicate tool registration is invalid.:
- /webmcp/imperative/executeTool-abort.https.html [wpt.fyi]
- executeTool() rejects with AbortError when signal is aborted:
FAIL
- executeTool() rejects with AbortError when signal is aborted:
- /webmcp/imperative/executeTool-across-trees.https.html [wpt.fyi]
- executeTool() rejects when the tool is hosted in another frame tree:
FAIL
- executeTool() rejects when the tool is hosted in another frame tree:
- /webmcp/imperative/executeTool-caller-navigate-abort.https.html [wpt.fyi]
- executeTool() aborts target signal when the invoker document (same-origin) navigates away:
FAIL - executeTool() aborts target signal when the invoker document (cross-origin) navigates away:
FAIL
- executeTool() aborts target signal when the invoker document (same-origin) navigates away:
- /webmcp/imperative/executeTool-error-window-onerror.https.html [wpt.fyi]
- Failed tool execution does not trigger window.onerror:
FAIL
- Failed tool execution does not trigger window.onerror:
- /webmcp/imperative/executeTool-invalid-dictionary.https.html [wpt.fyi]
- executeTool() rejects with TypeError when the required 'origin' dictionary member is omitted:
FAIL - executeTool() rejects with UnknownError for invalid JSON arguments:
FAIL - executeTool() rejects with UnknownError when a non-existent tool object is supplied:
FAIL
- executeTool() rejects with TypeError when the required 'origin' dictionary member is omitted:
- /webmcp/imperative/executeTool-target-detachment.https.html [wpt.fyi]
- executeTool() rejects when target frame is detached before execution:
FAIL - executeTool() rejects when target frame is detached mid-execution:
FAIL
- executeTool() rejects when target frame is detached before execution:
- /webmcp/imperative/executeTool-target-navigation.https.html [wpt.fyi]
- executeTool() rejects when target document navigates away:
FAIL
- executeTool() rejects when target document navigates away:
- /webmcp/imperative/executeTool-unauthorized-origin.https.html [wpt.fyi]
- executeTool() rejects when parent frame attempts unauthorized execution of cross-origin iframe tool:
FAIL
- executeTool() rejects when parent frame attempts unauthorized execution of cross-origin iframe tool:
- /webmcp/imperative/exposedTo-defaults-cross-origin.https.html [wpt.fyi]
- Parent tool with no exposedTo array is not visible to cross-origin iframe:
FAIL - Parent tool with empty exposedTo array is not visible to cross-origin iframe:
FAIL - Cross-origin iframe tool with default exposure is not visible to parent:
FAIL - Cross-origin iframe tool with empty exposedTo array is not visible to parent:
FAIL
- Parent tool with no exposedTo array is not visible to cross-origin iframe:
- /webmcp/imperative/exposedTo-defaults-same-origin.https.html [wpt.fyi]
- Parent tool with missing
exposedToarray is visible to same-origin iframe:FAIL - Parent tool with empty
exposedToarray is visible to same-origin iframe:FAIL - Same-origin iframe tool with default exposure is visible to parent:
FAIL - Same-origin iframe tool with empty exposedTo array is visible to parent:
FAIL
- Parent tool with missing
- /webmcp/imperative/exposedTo-invalid-origins.https.html [wpt.fyi]
- registerTool() throws SecurityError for invalid or non-potentially-trustworthy origins like / in exposedTo:
FAIL - registerTool() throws SecurityError for invalid or non-potentially-trustworthy origins like * in exposedTo:
FAIL - registerTool() throws SecurityError for invalid or non-potentially-trustworthy origins like https://example:bogus in exposedTo:
FAIL - registerTool() throws SecurityError for invalid or non-potentially-trustworthy origins like https://U+d800.com in exposedTo:
FAIL - registerTool() throws SecurityError for invalid or non-potentially-trustworthy origins like http://example.com in exposedTo:
FAIL - registerTool() throws SecurityError for invalid or non-potentially-trustworthy origins like ftp://example.com in exposedTo:
FAIL - registerTool() throws SecurityError for invalid or non-potentially-trustworthy origins like about:blank in exposedTo:
FAIL - registerTool() throws SecurityError for invalid or non-potentially-trustworthy origins like about:srcdoc in exposedTo:
FAIL - registerTool() throws SecurityError for invalid or non-potentially-trustworthy origins like https://example.com in exposedTo:
FAIL - registerTool() throws SecurityError for invalid or non-potentially-trustworthy origins like http://localhost:3000 in exposedTo:
FAIL - registerTool() with abort signal reason because signal is processed before
exposedTo:FAIL
- registerTool() throws SecurityError for invalid or non-potentially-trustworthy origins like / in exposedTo:
- /webmcp/imperative/exposedTo-window-open.https.html [wpt.fyi]
- Tools are scoped to a frame tree, and are not exposed across opener boundaries.:
FAIL
- Tools are scoped to a frame tree, and are not exposed across opener boundaries.:
- /webmcp/imperative/getTools-filtering.https.html [wpt.fyi]
- getTools() correctly filters returned tools by fromOrigins origins while preserving same-origin tools:
FAIL - getTools() rejects with SecurityError if an insecure origin is supplied in fromOrigins:
FAIL
- getTools() correctly filters returned tools by fromOrigins origins while preserving same-origin tools:
- /webmcp/imperative/getTools-imperative-annotations.https.html [wpt.fyi]
- Test that getTools() returns explicit annotations for an imperative tool:
FAIL - Test that getTools() populates default values for omitted annotation properties:
FAIL - Test that getTools() returns default values when annotations object is empty:
FAIL - Test that getTools() returns undefined annotations when omitted at registration:
FAIL
- Test that getTools() returns explicit annotations for an imperative tool:
- /webmcp/imperative/getTools-imperative-schema.https.html [wpt.fyi]
- Test that getTools() returns the correct inputSchema for an imperative tool:
FAIL
- Test that getTools() returns the correct inputSchema for an imperative tool:
- /webmcp/imperative/getTools.https.html [wpt.fyi]
- getTools should return all tools sorted in lexicographical order:
FAIL
- getTools should return all tools sorted in lexicographical order:
- /webmcp/imperative/initial-about-blank-shared-tool.https.html [wpt.fyi]
- tools registered with the initial about:blank Document do not survive navigation:
FAIL
- tools registered with the initial about:blank Document do not survive navigation:
- /webmcp/imperative/model_context.https.html [wpt.fyi]
- document.modelContext instanceof ModelContext:
FAIL
- document.modelContext instanceof ModelContext:
- /webmcp/imperative/object-arguments.https.html [wpt.fyi]
- tool execution requires a JSON Object input argument; and Arrays are Objects:
FAIL(Chrome:PASS, Safari:FAIL)
- tool execution requires a JSON Object input argument; and Arrays are Objects:
- /webmcp/imperative/opaque-origin-tools.https.html [wpt.fyi]
- An opaque origin document can register but not execute its own tools:
FAIL
- An opaque origin document can register but not execute its own tools:
- /webmcp/imperative/register-tool-title.https.html [wpt.fyi]
- Tool title is preserved when provided:
FAIL - Missing tool title in registration is exposed as empty string:
FAIL - Tool title with unpaired surrogate is fixed up by USVString:
FAIL
- Tool title is preserved when provided:
- /webmcp/imperative/register_tool_invalid_json_schema.https.html [wpt.fyi]
- WebMCP registerTool throws on invalid schema:
FAIL - WebMCP registerTool throws on invalid schema 1:
FAIL - WebMCP registerTool throws on invalid schema 2:
FAIL - registerTool rejects on invalid schema even if an aborted signal was provided:
FAIL
- WebMCP registerTool throws on invalid schema:
- /webmcp/imperative/register_tool_name_validation.https.html [wpt.fyi]
- Valid tool names are accepted.:
FAIL - Invalid tool names throw InvalidStateError.:
FAIL
- Valid tool names are accepted.:
- /webmcp/imperative/register_tool_no_schema.https.html [wpt.fyi]
- register tool with only required params:
FAIL
- register tool with only required params:
- /webmcp/imperative/register_tool_signal.https.html [wpt.fyi]
- register tool promise rejects with AbortError when signal gets aborted:
FAIL - register tool promise rejects with error when signal gets aborted:
FAIL - register tool promise rejects when signal is already aborted:
FAIL - aborting signal unregister tool:
FAIL
- register tool promise rejects with AbortError when signal gets aborted:
- /webmcp/imperative/register_tool_toolchange.https.html [wpt.fyi]
- registerTool triggers toolchange before promise resolves:
FAIL
- registerTool triggers toolchange before promise resolves:
- /webmcp/imperative/register_tool_with_empty_annotation.https.html [wpt.fyi]
- register tool with empty annotations:
FAIL
- register tool with empty annotations:
- /webmcp/imperative/register_tool_with_schema.https.html [wpt.fyi]
- register and unregister script tool:
FAIL - registerTool succeeds when inputSchema.toJSON() returns 'undefined':
FAIL
- register and unregister script tool:
- /webmcp/imperative/same-origin-iframe-registerTool-regression.https.html [wpt.fyi]
- registerTool() does not reject in connected same-origin iframe navigated away of about:blank:
FAIL
- registerTool() does not reject in connected same-origin iframe navigated away of about:blank:
- /webmcp/imperative/unregister-during-executeTool.https.html [wpt.fyi]
- Pending executeTool() Promise is rejected when the target cross-origin tool is unregistered:
FAIL
- Pending executeTool() Promise is rejected when the target cross-origin tool is unregistered:
Tests Disabled in Gecko Infrastructure
Comment 4•4 months ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/a89022afbe47
https://hg.mozilla.org/mozilla-central/rev/1e9e3e7c3e1d
Comment 5•4 months ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/a89022afbe47
https://hg.mozilla.org/mozilla-central/rev/1e9e3e7c3e1d
Comment 6•4 months ago
|
||
| bugherder | ||
Comment 7•4 months ago
|
||
| bugherder | ||
Description
•