Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /webmcp/imperative/register_tool_invalid_json_schema.https.window.html - WPT Dashboard Interop Dashboard
'use strict';
function test_register_tool_schema_error(inputSchema, expectedError, testName) {
test(() => {
assert_throws_js(
expectedError,
() => {
navigator.modelContext.registerTool({
name: 'empty',
description: 'empty',
inputSchema,
execute: () => {},
});
},
`Should throw ${expectedError.name} for invalid schema`,
);
}, testName);
}
test_register_tool_schema_error(
{ toJSON: () => undefined },
TypeError,
'registerTool throws when inputSchema.toJSON() returns undefined',
);
test_register_tool_schema_error(
(() => {
const circular = {};
circular.self = circular;
return circular;
})(),
TypeError,
'registerTool throws when inputSchema contains a circular reference',
);
test_register_tool_schema_error(
BigInt(42),
TypeError,
'registerTool throws when inputSchema contains non-serializable types (BigInt)',
);