tor-browser

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

frame-removal.html (2140B)


      1 <!doctype html>
      2 <script src="/resources/testharness.js"></script>
      3 <script src="/resources/testharnessreport.js"></script>
      4 
      5 <body>
      6 <script>
      7 promise_test(async (t) => {
      8  const i = await setupIframe();
      9  const watcher = new i.contentWindow.CloseWatcher();
     10  watcher.oncancel = () => i.remove();
     11  watcher.onclose = () => t.unreached_func("close event must not fire");
     12 
     13  watcher.requestClose();
     14 }, "detaching the iframe during the cancel event");
     15 
     16 promise_test(async (t) => {
     17  const i = await setupIframe();
     18  const watcher = new i.contentWindow.CloseWatcher();
     19  watcher.onclose = () => i.remove();
     20 
     21  watcher.requestClose();
     22 }, "detaching the iframe during the close event");
     23 
     24 promise_test(async (t) => {
     25  const i = await setupIframe();
     26  const watcher = new i.contentWindow.CloseWatcher();
     27  i.remove();
     28 
     29  watcher.destroy();
     30 }, "detaching the iframe then calling destroy()");
     31 
     32 promise_test(async (t) => {
     33  const i = await setupIframe();
     34  const watcher = new i.contentWindow.CloseWatcher();
     35  watcher.oncancel = () => t.unreached_func("cancel event must not fire");
     36  watcher.onclose = () => t.unreached_func("close event must not fire");
     37  i.remove();
     38 
     39  watcher.close();
     40 }, "detaching the iframe then calling close()");
     41 
     42 promise_test(async (t) => {
     43  const i = await setupIframe();
     44  const watcher = new i.contentWindow.CloseWatcher();
     45  watcher.oncancel = () => t.unreached_func("cancel event must not fire");
     46  watcher.onclose = () => t.unreached_func("close event must not fire");
     47  i.remove();
     48 
     49  watcher.requestClose();
     50 }, "detaching the iframe then calling requestClose()");
     51 
     52 promise_test(async (t) => {
     53  const i = await setupIframe();
     54  const iCloseWatcher = i.contentWindow.CloseWatcher;
     55  const iDOMException = i.contentWindow.DOMException;
     56  i.remove();
     57 
     58  assert_throws_dom("InvalidStateError", iDOMException, () => new iCloseWatcher());
     59 }, "detaching the iframe then constructing a CloseWatcher");
     60 
     61 function setupIframe() {
     62  return new Promise(resolve => {
     63    const i = document.createElement("iframe");
     64    i.onload = () => resolve(i);
     65    i.src = "/common/blank.html";
     66    document.body.append(i);
     67  });
     68 }
     69 </script>