Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /ai/language-model/language-model-from-detached-iframe.tentative.https.window.html - WPT Dashboard Interop Dashboard
// META: title=Language Model From Detached Iframe
// META: script=/resources/testdriver.js
// META: script=../resources/util.js
// META: timeout=long
'use strict';
promise_test(async t => {
assert_true(!!LanguageModel);
// Create the iframe and append it to the document.
let iframe = document.createElement("iframe");
document.childNodes[document.childNodes.length - 1].appendChild(iframe);
let iframeWindow = iframe.contentWindow;
iframeWindow.languageModel = iframeWindow.LanguageModel;
let iframeDOMException = iframeWindow.DOMException;
// Detach the iframe.
iframe.remove();
// Calling `LanguageModel.availability()` from an invalid script state will trigger
// the "The execution context is not valid." exception.
await promise_rejects_dom(
t, 'InvalidStateError', iframeDOMException, iframeWindow.languageModel.availability(),
"The promise should be rejected with InvalidStateError if the execution context is invalid."
);
});