tor-browser

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

test_anonymousContent_api.html (1332B)


      1 <!DOCTYPE HTML>
      2 <!--
      3 https://bugzilla.mozilla.org/show_bug.cgi?id=1020244
      4 -->
      5 <meta charset="utf-8">
      6 <title>Test for Bug 1020244 - Test the chrome-only AnonymousContent API</title>
      7 <script src="/tests/SimpleTest/SimpleTest.js"></script>
      8 <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
      9 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1020244">Mozilla Bug 1020244</a>
     10 <script>
     11  // Testing the presence of the chrome-only API
     12  ok(!document.insertAnonymousContent,
     13    "Content document shouldn't have access to insertAnonymousContent");
     14  ok(!document.removeAnonymousContent,
     15    "Content document shouldn't have access to removeAnonymousContent");
     16 
     17  let chromeDocument = SpecialPowers.wrap(document);
     18  ok(chromeDocument.insertAnonymousContent,
     19    "Chrome document should have access to insertAnonymousContent");
     20  ok(chromeDocument.removeAnonymousContent,
     21    "Chrome document should have access to removeAnonymousContent");
     22 
     23  // Testing the API of the returned object
     24  let anonymousContent = chromeDocument.insertAnonymousContent();
     25  ok(anonymousContent, "AnonymousContent object returned");
     26  let div = document.createElement("div");
     27  div.textContent = "this is a test element";
     28  anonymousContent.root.appendChild(div);
     29  chromeDocument.removeAnonymousContent(anonymousContent);
     30 </script>