tor-browser

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

summarizer-from-detached-iframe.tentative.https.window.js (2447B)


      1 // META: title=Summarizer 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  const iframe = document.body.appendChild(document.createElement('iframe'));
     10  await test_driver.bless('Summarizer create()', null, iframe.contentWindow);
     11  iframe.contentWindow.Summarizer.create();
     12  iframe.remove();
     13 }, 'Detaching iframe during Summarizer.create() should not leak memory');
     14 
     15 promise_test(async (t) => {
     16  const iframe = document.body.appendChild(document.createElement('iframe'));
     17  await test_driver.bless('Summarizer create()', null, iframe.contentWindow);
     18  const iframeWindow = iframe.contentWindow;
     19  const iframeDOMException = iframeWindow.DOMException;
     20  const iframeSummarizer = iframeWindow.Summarizer;
     21  iframe.remove();
     22 
     23  await promise_rejects_dom(
     24      t, 'InvalidStateError', iframeDOMException, iframeSummarizer.create());
     25 }, 'Summarizer.create() fails on a detached iframe');
     26 
     27 promise_test(async (t) => {
     28  const iframe = document.body.appendChild(document.createElement('iframe'));
     29  await test_driver.bless('Summarizer create()', null, iframe.contentWindow);
     30  const iframeDOMException = iframe.contentWindow.DOMException;
     31  const summarizer = await iframe.contentWindow.Summarizer.create();
     32  iframe.remove();
     33 
     34  await promise_rejects_dom(
     35    t, 'InvalidStateError', iframeDOMException, summarizer.summarize(kTestPrompt));
     36 }, 'Summarizer.summarize() fails on a detached iframe');
     37 
     38 promise_test(async (t) => {
     39  const iframe = document.body.appendChild(document.createElement('iframe'));
     40  await test_driver.bless('Summarizer create()', null, iframe.contentWindow);
     41  const iframeWindow = iframe.contentWindow;
     42  const iframeDOMException = iframeWindow.DOMException;
     43  const summarizer = await iframeWindow.Summarizer.create();
     44  iframe.remove();
     45 
     46  assert_throws_dom(
     47    'InvalidStateError',
     48    iframeDOMException, () => summarizer.summarizeStreaming(kTestPrompt));
     49 }, 'Summarizer.summarizeStreaming() fails on a detached iframe');
     50 
     51 promise_test(async (t) => {
     52  const iframe = document.body.appendChild(document.createElement('iframe'));
     53  await test_driver.bless('Summarizer create()', null, iframe.contentWindow);
     54  const summarizer = await iframe.contentWindow.Summarizer.create();
     55  summarizer.summarize(kTestPrompt);
     56  iframe.remove();
     57 }, 'Detaching iframe during Summarizer.summarize() should not leak memory');