tor-browser

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

separate-document-policies.html (2376B)


      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 a document policy, as well as a required document
     11 // policy (for subframes) which is stricter. This test should load (the required
     12 // policy should not block this page,) but the requirements should be applied to
     13 // nested content.
     14 
     15 callbacks = {};
     16 
     17 window.addEventListener('message', ev => {
     18  var id = ev.data.id;
     19  if (id && callbacks[id]) {
     20    callbacks[id](ev.data.requiredPolicy || null);
     21  }
     22 });
     23 
     24 async_test(t => {
     25  var iframe = document.createElement('iframe');
     26  iframe.src = "/document-policy/echo-policy.py?id=1";
     27  callbacks["1"] = t.step_func_done(result => {
     28    assert_equals(result, "lossless-images-max-bpp=1.0");
     29  });
     30  document.body.appendChild(iframe);
     31 }, "Child frame with no explicit policy should have the same required policy as its parent.");
     32 
     33 async_test(t => {
     34  var iframe = document.createElement('iframe');
     35  iframe.src = "/document-policy/echo-policy.py?id=2";
     36  iframe.policy = "lossless-images-max-bpp=4";
     37  callbacks["2"] = t.step_func_done(result => {
     38    assert_equals(result, "lossless-images-max-bpp=1.0");
     39  });
     40  document.body.appendChild(iframe);
     41 }, "Child frame with a less strict required policy should have the stricter value from the parent's policy applied.");
     42 
     43 async_test(t => {
     44  var iframe = document.createElement('iframe');
     45  iframe.src = "/document-policy/echo-policy.py?id=3";
     46  iframe.policy = "lossless-images-max-bpp=0.9";
     47  callbacks["3"] = t.step_func_done(result => {
     48    assert_equals(result, "lossless-images-max-bpp=0.9");
     49  });
     50  document.body.appendChild(iframe);
     51 }, "Child frame may have a stricter policy than the parent.");
     52 
     53 async_test(t => {
     54  var iframe = document.createElement('iframe');
     55  iframe.src = "/document-policy/echo-policy.py?id=4";
     56  iframe.policy = "no-font-display-late-swap";
     57  callbacks["4"] = t.step_func_done(result => {
     58    assert_equals(result, "no-font-display-late-swap, lossless-images-max-bpp=1.0");
     59  });
     60  document.body.appendChild(iframe);
     61 }, "Any unrelated policy directives should combine with the parent's required policy.");
     62    </script>
     63  </body>
     64 </html>