Files
sousa-gecko/testing/web-platform/tests/webmcp/imperative/executeTool-across-trees.https.html
T
François Beaufort fde9dc0f7f Bug 2051409 [wpt PR 60974] - [WebMCP] Make registerTool() return a promise, a=testonly
Automatic update from web-platform-tests
[WebMCP] Make registerTool() return a promise

Spec issue: https://github.com/webmachinelearning/webmcp/issues/175

Bug: 489045948
Change-Id: I254250d12ad78b95626939e0f7e22fd6fe56f70f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7916507
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Reviewed-by: Dominic Farolino <dom@chromium.org>
Reviewed-by: Khushal Sagar <khushalsagar@chromium.org>
Commit-Queue: Fr <beaufort.francois@gmail.com>
Cr-Commit-Position: refs/heads/main@{#1654308}

--

wpt-commits: 925e2819ce321d53de6069f93dcf1e37171381b9
wpt-pr: 60974
2026-07-10 09:21:26 +00:00

39 lines
1.1 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>WebMCP executeTool across trees</title>
<link rel="author" href="mailto:dom@chromium.org">
<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>