Automatic update from web-platform-tests [WebMCP] Fix WPTs for WebMCP after getTools() change. - Updates all cross-origin WebMCP Web Platform Tests (WPT) to utilize the new API with explicit `fromOrigins` parameters, ensuring they now pass cleanly. - Removes the temporary failure expectations for these WPT tests from TestExpectations. Bug: 485810761 Change-Id: Ia278140565a3c2f1aa6896685a3fcba3ef9500f0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7913488 Reviewed-by: Dominic Farolino <dom@chromium.org> Commit-Queue: Dominic Farolino <dom@chromium.org> Cr-Commit-Position: refs/heads/main@{#1644383} -- wpt-commits: 8894a59b3a729aebd3427ea8572a0f14b37792df wpt-pr: 60514
57 lines
1.8 KiB
HTML
57 lines
1.8 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>WebMCP Exposure Across window.open()</title>
|
|
<meta name="timeout" content="long">
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<script src="/common/get-host-info.sub.js"></script>
|
|
<script src="resources/helpers.js"></script>
|
|
</head>
|
|
<body>
|
|
<script>
|
|
const host_info = get_host_info();
|
|
|
|
promise_test(async t => {
|
|
const origin_a = host_info.HTTPS_ORIGIN;
|
|
const origin_b = host_info.HTTPS_REMOTE_ORIGIN;
|
|
|
|
// Frame B exposes to A. Parent A can view, but opened window cannot.
|
|
const iframe_b = document.createElement('iframe');
|
|
iframe_b.src = origin_b + '/webmcp/imperative/resources/iframe-register-tool.html';
|
|
iframe_b.allow = 'tools *';
|
|
|
|
const load_promise = new Promise(resolve => iframe_b.onload = resolve);
|
|
document.body.appendChild(iframe_b);
|
|
t.add_cleanup(() => iframe_b.remove());
|
|
await load_promise;
|
|
|
|
iframe_b.contentWindow.postMessage({
|
|
action: 'register',
|
|
tool: {
|
|
name: 'tool_b_to_a',
|
|
description: 'Tool B exposed to A',
|
|
},
|
|
options: { exposedTo: [origin_a] }
|
|
}, '*');
|
|
|
|
await new Promise(resolve => {
|
|
document.modelContext.addEventListener('toolchange', resolve, { once: true });
|
|
});
|
|
|
|
// Parent A can view it.
|
|
const tools = await document.modelContext.getTools({ fromOrigins: [origin_b] });
|
|
assert_true(tools.some(t => t.name === 'tool_b_to_a'), 'Parent A should see tool_b_to_a');
|
|
|
|
// Open new window.
|
|
const opened_window = window.open('about:blank');
|
|
t.add_cleanup(() => opened_window.close());
|
|
|
|
// Newly opened window does not see the tool.
|
|
const opened_tools = await opened_window.document.modelContext.getTools();
|
|
assert_array_equals(opened_tools, [], "window.open()'d sees no tools");
|
|
}, 'Tools are scoped to a frame tree, and are not exposed across opener boundaries.');
|
|
</script>
|
|
</body>
|
|
</html>
|