tor-browser

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

document-without-browsing-context.html (1249B)


      1 <!doctype html>
      2 <meta charset="utf-8">
      3 <title>Documents without browsing contexts should not load stylesheets</title>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <script src="/common/utils.js"></script>
      7 <body>
      8 <script>
      9  function count(id, t) {
     10    var xhr = new XMLHttpRequest();
     11    xhr.open('GET', 'stylesheet.py?count=1&id=' + id);
     12    xhr.onload = t.step_func_done(function() {
     13      assert_equals(xhr.responseText, "1");
     14    });
     15    xhr.onerror = t.unreached_func();
     16    xhr.send();
     17  }
     18 
     19  async_test(function(t) {
     20    var id = token();
     21    var doc = (new DOMParser()).parseFromString('<link rel="stylesheet" href="stylesheet.py?id=' + id + '"></link>', 'text/html');
     22    var link = doc.querySelector('link');
     23    document.head.appendChild(link);
     24    t.step_timeout(function() { count(id, t) }, 500);
     25  }, 'Create a document, adopt the node');
     26 
     27  async_test(function(t) {
     28    var id = token();
     29    var d = document.createElement('div');
     30    document.body.appendChild(d);
     31    d.innerHTML = '<link rel="stylesheet" href="stylesheet.py?id=' + id + '"></link>';
     32    t.step_timeout(function() { count(id, t) }, 500);
     33  }, 'Create a stylesheet in innerHTML document');
     34 </script>
     35 </body>