tor-browser

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

initial-content-replacement.html (3233B)


      1 <!DOCTYPE html>
      2 <meta charset="UTF-8">
      3 <title>
      4  Content synchronously added to iframe/opened window's document after creation
      5  won't get replaced asynchronously when staying on the initial empty document
      6 </title>
      7 <script src="/resources/testharness.js"></script>
      8 <script src="/resources/testharnessreport.js"></script>
      9 <script src="resources/helpers.js"></script>
     10 <body></body>
     11 <script>
     12 "use strict";
     13 
     14 // Asserts the document on |w| stays the same after waiting 100ms.
     15 function assertDocumentStaysTheSame(t, w) {
     16  const initialDocument = w.document;
     17  initialDocument.body.innerHTML = "foo";
     18  return new Promise((resolve) => {
     19    t.step_timeout(() => {
     20      assert_equals(w.document.body.innerHTML, "foo");
     21      assert_equals(w.document, initialDocument);
     22      resolve();
     23    }, 100);
     24  });
     25 }
     26 
     27 promise_test(async t => {
     28  const iframe = document.createElement("iframe");
     29  document.body.appendChild(iframe);
     30  await assertDocumentStaysTheSame(t, iframe.contentWindow);
     31 }, "Content synchronously added to <iframe> with no src won't get replaced");
     32 
     33 promise_test(async t => {
     34  const iframe = document.createElement("iframe");
     35  iframe.src = "";
     36  document.body.appendChild(iframe);
     37  await assertDocumentStaysTheSame(t, iframe.contentWindow);
     38 }, "Content synchronously added to <iframe> with src='' won't get replaced");
     39 
     40 promise_test(async t => {
     41  const iframe = document.createElement("iframe");
     42  iframe.src = "about:blank";
     43  document.body.appendChild(iframe);
     44  await assertDocumentStaysTheSame(t, iframe.contentWindow);
     45 }, "Content synchronously added to <iframe> with src='about:blank' won't get replaced");
     46 
     47 promise_test(async t => {
     48  const iframe = document.createElement("iframe");
     49  iframe.src = "about:blank#foo";
     50  document.body.appendChild(iframe);
     51  await assertDocumentStaysTheSame(t, iframe.contentWindow);
     52 }, "Content synchronously added to <iframe> with src='about:blank#foo' won't get replaced");
     53 
     54 promise_test(async t => {
     55  const iframe = document.createElement("iframe");
     56  iframe.src = "about:blank?foo";
     57  document.body.appendChild(iframe);
     58  await assertDocumentStaysTheSame(t, iframe.contentWindow);
     59 }, "Content synchronously added to <iframe> with src='about:blank?foo' won't get replaced");
     60 
     61 promise_test(async t => {
     62  const w = window.open();
     63  await assertDocumentStaysTheSame(t, w);
     64 }, "Content synchronously added to window.open()-ed document won't get replaced");
     65 
     66 promise_test(async t => {
     67  const w = window.open("");
     68  await assertDocumentStaysTheSame(t, w);
     69 }, "Content synchronously added to window.open('')-ed document won't get replaced");
     70 
     71 promise_test(async t => {
     72  const w = window.open("about:blank");
     73  await assertDocumentStaysTheSame(t, w);
     74 }, "Content synchronously added to window.open('about:blank')-ed document won't get replaced");
     75 
     76 promise_test(async t => {
     77  const w = window.open("about:blank#foo");
     78  await assertDocumentStaysTheSame(t, w);
     79 }, "Content synchronously added to window.open('about:blank#foo')-ed document won't get replaced");
     80 
     81 promise_test(async t => {
     82  const w = window.open("about:blank?foo");
     83  await assertDocumentStaysTheSame(t, w);
     84 }, "Content synchronously added to window.open('about:blank?foo')-ed document won't get replaced");
     85 
     86 </script>