tor-browser

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

language-model-from-detached-iframe.tentative.https.window.js (972B)


      1 // META: title=Language Model From Detached Iframe
      2 // META: script=/resources/testdriver.js
      3 // META: script=../resources/util.js
      4 // META: timeout=long
      5 
      6 'use strict';
      7 
      8 promise_test(async t => {
      9  assert_true(!!LanguageModel);
     10  // Create the iframe and append it to the document.
     11  let iframe = document.createElement("iframe");
     12  document.childNodes[document.childNodes.length - 1].appendChild(iframe);
     13  let iframeWindow = iframe.contentWindow;
     14  iframeWindow.languageModel = iframeWindow.LanguageModel;
     15  let iframeDOMException = iframeWindow.DOMException;
     16  // Detach the iframe.
     17  iframe.remove();
     18  // Calling `LanguageModel.availability()` from an invalid script state will trigger
     19  // the "The execution context is not valid." exception.
     20  await promise_rejects_dom(
     21    t, 'InvalidStateError', iframeDOMException, iframeWindow.languageModel.availability(),
     22    "The promise should be rejected with InvalidStateError if the execution context is invalid."
     23  );
     24 });