tor-browser

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

test_image_document.html (1003B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <meta charset="utf-8">
      5  <title>Bug 1627235: Test CSP for images loaded as iframe</title>
      6  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      7  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
      8 </head>
      9 <body>
     10 
     11 <iframe id="testframe"></iframe>
     12 
     13 <script class="testbody" type="text/javascript">
     14 
     15 SimpleTest.waitForExplicitFinish();
     16 
     17 let testframe = document.getElementById("testframe");
     18 
     19 testframe.onload = function() {
     20  ok(true, "sanity: should fire onload for image document");
     21  
     22  let contentDoc = SpecialPowers.wrap(testframe.contentDocument);
     23  let cspJSON = contentDoc.cspJSON;
     24  ok(cspJSON.includes("default-src"), "found default-src directive");
     25  ok(cspJSON.includes("https://bug1627235.test.com"), "found default-src value");
     26  SimpleTest.finish();
     27 }
     28 testframe.onerror = function() {
     29  ok(false, "sanity: should not fire onerror for image document");
     30 }
     31 testframe.src = "file_image_document_pixel.png";
     32 
     33 </script>
     34 </body>
     35 </html>