Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 3 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /webmcp/imperative/document-domain-enabled.https.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<title>document.modelContext gated by document.domain being disabled</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(() => {
const tool = {
name: 'test_tool',
description: 'a test tool',
execute: () => 'success',
};
assert_throws_dom('SecurityError', () => {
document.modelContext.registerTool(tool);
});
}, 'modelContext.registerTool throws SecurityError when document.domain is enabled');
promise_test(t => {
return promise_rejects_dom(t, 'SecurityError', document.modelContext.getTools());
}, 'modelContext.getTools rejects with SecurityError when document.domain is enabled');
promise_test(t => {
const dummyTool = {
name: 'dummy',
description: 'dummy',
window: window,
origin: window.location.origin,
};
return promise_rejects_dom(t, 'SecurityError', document.modelContext.executeTool(dummyTool, ''));
}, 'modelContext.executeTool rejects with SecurityError when document.domain is enabled');
</script>