tor-browser

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

cookie-enabled-noncookie-frame.html (1083B)


      1 <!DOCTYPE html>
      2 <head>
      3  <script src="/resources/testharness.js"></script>
      4  <script src="/resources/testharnessreport.js"></script>
      5 </head>
      6 <body>
      7  <script>
      8    var t = async_test("navigator.cookieEnabled behavior on frames without cookie access");
      9    window.onmessage = t.step_func_done(ev => {
     10      // Surprisingly, the legacy behavior here is to return true; this actually
     11      // does match the spec definition since false is supposed to be returned
     12      // when a document.cookie write is ignored --- and here it would throw
     13      // a security exception, not be ignored.
     14      assert_true(ev.data);
     15    });
     16 
     17    t.step(() => {
     18      var iframe = document.createElement("iframe");
     19      iframe.sandbox = "allow-scripts";
     20      iframe.srcdoc = "<scr" + "ipt>" +
     21            "window.onmessage = function() {" +
     22            "  parent.postMessage(navigator.cookieEnabled, '*'); " +
     23            "}</scr" + "ipt>";
     24      iframe.onload = function() {
     25        iframe.contentWindow.postMessage({}, "*");
     26      }
     27      document.body.appendChild(iframe);
     28    });
     29  </script>
     30 </body>