Files
sousa-gecko/testing/web-platform/tests/webmcp/imperative/opaque-origin-tools.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

36 lines
1.1 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>WebMCP Opaque Origin Tool</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 => {
// 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,
'UnknownError',
document.modelContext.executeTool(tool, '{}'),
'executeTool() must reject with UnknownError in opaque origin documents'
);
}, 'An opaque origin document can register but not execute its own tools');
</script>
</body>
</html>