1
0
Fork 0
firefox/testing/web-platform/tests/speech-api/SpeechRecognition-detached-iframe.window.js
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

35 lines
1.1 KiB
JavaScript

// META: title=SpeechRecognition in a detached iframe test
test(() => {
// Create the iframe and append it to the document.
const iframe = document.createElement("iframe");
document.body.appendChild(iframe);
const frameWindow = iframe.contentWindow;
// Detach the iframe.
iframe.remove();
assert_equals(
undefined,
frameWindow.SpeechRecognition || frameWindow.webkitSpeechRecognition,
);
}, "SpeechRecognition constructor does not exist in detached iframes");
test((t) => {
// Create the iframe and append it to the document.
const iframe = document.createElement("iframe");
document.body.appendChild(iframe);
const frameWindow = iframe.contentWindow;
const frameDOMException = frameWindow.DOMException;
frameWindow.SpeechRecognition =
frameWindow.SpeechRecognition || frameWindow.webkitSpeechRecognition;
const speechRecognition = new frameWindow.SpeechRecognition();
// Detach the iframe.
iframe.remove();
assert_throws_dom("InvalidStateError", frameDOMException, () =>
speechRecognition.start(),
);
}, "SpeechRecognition.start() on detached frame throws");