tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

SpeechRecognition-detached-iframe.window.js (1121B)


      1 // META: title=SpeechRecognition in a detached iframe test
      2 
      3 test(() => {
      4  // Create the iframe and append it to the document.
      5  const iframe = document.createElement("iframe");
      6  document.body.appendChild(iframe);
      7  const frameWindow = iframe.contentWindow;
      8 
      9  // Detach the iframe.
     10  iframe.remove();
     11 
     12  assert_equals(
     13    undefined,
     14    frameWindow.SpeechRecognition || frameWindow.webkitSpeechRecognition,
     15  );
     16 }, "SpeechRecognition constructor does not exist in detached iframes");
     17 
     18 test((t) => {
     19  // Create the iframe and append it to the document.
     20  const iframe = document.createElement("iframe");
     21  document.body.appendChild(iframe);
     22  const frameWindow = iframe.contentWindow;
     23  const frameDOMException = frameWindow.DOMException;
     24 
     25  frameWindow.SpeechRecognition =
     26    frameWindow.SpeechRecognition || frameWindow.webkitSpeechRecognition;
     27  const speechRecognition = new frameWindow.SpeechRecognition();
     28 
     29  // Detach the iframe.
     30  iframe.remove();
     31 
     32  assert_throws_dom("InvalidStateError", frameDOMException, () =>
     33    speechRecognition.start(),
     34  );
     35 }, "SpeechRecognition.start() on detached frame throws");