tor-browser

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

rewriter-from-detached-iframe.tentative.https.window.js (2380B)


      1 // META: title=Rewriter 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('Rewriter create()', null, iframe.contentWindow);
     11  iframe.contentWindow.Rewriter.create();
     12  iframe.remove();
     13 }, 'Detaching iframe during Rewriter.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('Rewriter create()', null, iframe.contentWindow);
     18  const iframeWindow = iframe.contentWindow;
     19  const iframeDOMException = iframeWindow.DOMException;
     20  const iframeRewriter = iframeWindow.Rewriter;
     21  iframe.remove();
     22 
     23  await promise_rejects_dom(
     24      t, 'InvalidStateError', iframeDOMException, iframeRewriter.create());
     25 }, 'Rewriter.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('Rewriter create()', null, iframe.contentWindow);
     30  const iframeDOMException = iframe.contentWindow.DOMException;
     31  const rewriter = await iframe.contentWindow.Rewriter.create();
     32  iframe.remove();
     33 
     34  await promise_rejects_dom(
     35      t, 'InvalidStateError', iframeDOMException, rewriter.rewrite('hello'));
     36 }, 'Rewriter.rewrite() 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('Rewriter create()', null, iframe.contentWindow);
     41  const iframeWindow = iframe.contentWindow;
     42  const iframeDOMException = iframeWindow.DOMException;
     43  const rewriter = await iframeWindow.Rewriter.create();
     44  iframe.remove();
     45 
     46  assert_throws_dom(
     47    'InvalidStateError',
     48    iframeDOMException, () => rewriter.rewriteStreaming('hello'));
     49 }, 'Rewriter.rewriteStreaming() 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('Rewriter create()', null, iframe.contentWindow);
     54  const rewriter = await iframe.contentWindow.Rewriter.create();
     55  rewriter.rewrite('hello');
     56  iframe.remove();
     57 }, 'Detaching iframe during Rewriter.rewrite() should not leak memory');