tor-browser

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

required-document-policy-nested.html (1932B)


      1 <!DOCTYPE html>
      2 <html>
      3  <head>
      4    <title>Test advertised required document policy</title>
      5    <script src="/resources/testharness.js"></script>
      6    <script src="/resources/testharnessreport.js"></script>  </head>
      7  <body>
      8    <h1>Test advertised required document policy</h1>
      9 <script>
     10 // The top-level document has no required document policy. Its child frames may,
     11 // though, and those policies should be set for any subframes.
     12 
     13 callbacks = {};
     14 
     15 window.addEventListener('message', ev => {
     16  var id = ev.data.id;
     17  if (id && callbacks[id]) {
     18    callbacks[id](ev.data.requiredPolicy || null);
     19  }
     20 });
     21 
     22 // Frame tree should be:
     23 // Top:
     24 //  <iframe>
     25 //    <iframe>
     26 async_test(t => {
     27  var iframe = document.createElement('iframe');
     28  iframe.src = "/document-policy/echo-policy-nested.html?id=1";
     29  callbacks["1"] = t.step_func_done(result => {
     30    assert_equals(result, null);
     31  });
     32  document.body.appendChild(iframe);
     33 }, "test nested required document policy");
     34 
     35 // Frame tree should be:
     36 // Top:
     37 //  <iframe policy="sync-xhr=?0">
     38 //    <iframe>
     39 async_test(t => {
     40  var iframe = document.createElement('iframe');
     41  iframe.src = "/document-policy/echo-policy-nested.html?id=2";
     42  iframe.policy = "sync-xhr=?0";
     43  callbacks["2"] = t.step_func_done(result => {
     44    assert_equals(result, "sync-xhr=?0");
     45  });
     46  document.body.appendChild(iframe);
     47 }, "test nested required document policy when set by nested frame");
     48 
     49 // Frame tree should be:
     50 // Top:
     51 //  <iframe policy="sync-xhr=?0">
     52 //    <iframe>
     53 //      <iframe>
     54 async_test(t => {
     55  var iframe = document.createElement('iframe');
     56  iframe.src = "/document-policy/echo-policy-nested.html?id=3&level=1";
     57  iframe.policy = "sync-xhr=?0";
     58  callbacks["3"] = t.step_func_done(result => {
     59    assert_equals(result, "sync-xhr=?0");
     60  });
     61  document.body.appendChild(iframe);
     62 }, "test nested required document policy when set by intermediate nested frame");
     63    </script>
     64  </body>
     65 </html>