Automatic update from web-platform-tests [WebMCP] Expose annotations on RegisteredTool dictionary Expose a tool's annotations on the `RegisteredTool` dictionary, so that JavaScript invokers of WebMCP tools can ingest this important data before running a tool. It doesn't update tools returned from `listTools()`. Bug: 508265320 Change-Id: I4484a6d805a653c8811f7b42835c5a509e173c1d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7816976 Commit-Queue: Fr <beaufort.francois@gmail.com> Reviewed-by: Dominic Farolino <dom@chromium.org> Cr-Commit-Position: refs/heads/main@{#1628425} -- wpt-commits: 224a305f9380f2760f65e3cd5cd1567112278ddb wpt-pr: 59781
38 lines
1.5 KiB
JavaScript
38 lines
1.5 KiB
JavaScript
// 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 (actual.inputSchema !== expected.inputSchema) {
|
|
return `inputSchemas are unequal: ${actual.inputSchemas} !== ${expected.inputSchemas}`;
|
|
}
|
|
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}`;
|
|
}
|
|
|
|
return true;
|
|
}
|