tor-browser

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

index.html (5475B)


      1 <!--
      2  Any copyright is dedicated to the Public Domain.
      3  http://creativecommons.org/publicdomain/zero/1.0/
      4 -->
      5 <!DOCTYPE HTML>
      6 <html>
      7 <head>
      8  <title>Bug 94048 - test install event.</title>
      9  <script src="/tests/SimpleTest/SimpleTest.js"></script>
     10  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     11 </head>
     12 <body>
     13 <p id="display"></p>
     14 <div id="content" style="display: none"></div>
     15 <div id="style-test" style="background-color: white"></div>
     16 <pre id="test"></pre>
     17 <script class="testbody" type="text/javascript">
     18  function my_ok(result, msg) {
     19    window.opener.postMessage({status: "ok", result, message: msg}, "*");
     20  }
     21 
     22  function check_intercepted_script() {
     23    document.getElementById('intercepted-script').test_result =
     24      document.currentScript == document.getElementById('intercepted-script');
     25  }
     26 
     27  function fetchXHR(name, onload, onerror, headers) {
     28    gExpected++;
     29 
     30    onload = onload || function() {
     31      my_ok(false, "load should not complete successfully");
     32      finish();
     33    };
     34    onerror = onerror || function() {
     35      my_ok(false, "load should be intercepted successfully");
     36      finish();
     37    };
     38 
     39    var x = new XMLHttpRequest();
     40    x.open('GET', name, true);
     41    x.onload = function() { onload(x) };
     42    x.onerror = function() { onerror(x) };
     43    headers = headers || [];
     44    headers.forEach(function(header) {
     45      x.setRequestHeader(header[0], header[1]);
     46    });
     47    x.send();
     48  }
     49 
     50  var gExpected = 0;
     51  var gEncountered = 0;
     52  function finish() {
     53    gEncountered++;
     54    if (gEncountered == gExpected) {
     55      window.opener.postMessage({status: "done"}, "*");
     56    }
     57  }
     58 
     59  function test_onload(creator, complete) {
     60    gExpected++;
     61    var elem = creator();
     62    elem.onload = function() {
     63      complete.call(elem);
     64      finish();
     65    };
     66    elem.onerror = function() {
     67      my_ok(false, elem.tagName + " load should complete successfully");
     68      finish();
     69    };
     70    document.body.appendChild(elem);
     71  }
     72 
     73  function expectAsyncResult() {
     74    gExpected++;
     75  }
     76 
     77  my_ok(navigator.serviceWorker.controller != null, "should be controlled");
     78 </script>
     79 <script src="fetch_tests.js"></script>
     80 <script>
     81  test_onload(function() {
     82    var elem = document.createElement('img');
     83    elem.src = "nonexistent_image.gifs";
     84    elem.id = 'intercepted-img';
     85    return elem;
     86  }, function() {
     87    my_ok(this.complete, "image should be complete");
     88    my_ok(this.naturalWidth == 1 && this.naturalHeight == 1, "image should be 1x1 gif");
     89  });
     90 
     91  test_onload(function() {
     92    var elem = document.createElement('script');
     93    elem.id = 'intercepted-script';
     94    elem.src = "nonexistent_script.js";
     95    return elem;
     96  }, function() {
     97    my_ok(this.test_result, "script load should be intercepted");
     98  });
     99 
    100  test_onload(function() {
    101    var elem = document.createElement('link');
    102    elem.href = "nonexistent_stylesheet.css";
    103    elem.rel = "stylesheet";
    104    return elem;
    105  }, function() {
    106    var styled = document.getElementById('style-test');
    107    my_ok(window.getComputedStyle(styled).backgroundColor == 'rgb(0, 0, 0)',
    108          "stylesheet load should be intercepted");
    109  });
    110 
    111  test_onload(function() {
    112    var elem = document.createElement('iframe');
    113    elem.id = 'intercepted-iframe';
    114    elem.src = "nonexistent_page.html";
    115    return elem;
    116  }, function() {
    117    my_ok(this.test_result, "iframe load should be intercepted");
    118  });
    119 
    120  test_onload(function() {
    121    var elem = document.createElement('iframe');
    122    elem.id = 'intercepted-iframe-2';
    123    elem.src = "navigate.html";
    124    return elem;
    125  }, function() {
    126    my_ok(this.test_result, "iframe should successfully load");
    127  });
    128 
    129  gExpected++;
    130  var xhr = new XMLHttpRequest();
    131  xhr.addEventListener("load", function(evt) {
    132    my_ok(evt.target.responseXML === null, "Load synthetic cross origin XML Document should be allowed");
    133    finish();
    134  });
    135  xhr.responseType = "document";
    136  xhr.open("GET", "load_cross_origin_xml_document_synthetic.xml");
    137  xhr.send();
    138 
    139  gExpected++;
    140  fetch(
    141    "load_cross_origin_xml_document_cors.xml",
    142    {mode: "same-origin"}
    143  ).then(function(response) {
    144    // issue: https://github.com/whatwg/fetch/issues/629
    145    my_ok(false, "Load CORS cross origin XML Document should not be allowed");
    146    finish();
    147  }, function(error) {
    148    my_ok(true, "Load CORS cross origin XML Document should not be allowed");
    149    finish();
    150  });
    151 
    152  gExpected++;
    153  fetch(
    154    "load_cross_origin_xml_document_opaque.xml",
    155    {mode: "same-origin"}
    156  ).then(function(response) {
    157    my_ok(false, "Load opaque cross origin XML Document should not be allowed");
    158    finish();
    159  }, function(error) {
    160    my_ok(true, "Load opaque cross origin XML Document should not be allowed");
    161    finish();
    162  });
    163 
    164  gExpected++;
    165  var worker = new Worker('nonexistent_worker_script.js');
    166  worker.onmessage = function(e) {
    167    my_ok(e.data == "worker-intercept-success", "worker load intercepted");
    168    finish();
    169  };
    170  worker.onerror = function() {
    171    my_ok(false, "worker load should be intercepted");
    172  };
    173 
    174  gExpected++;
    175  var worker = new Worker('fetch_worker_script.js');
    176  worker.onmessage = function(e) {
    177    if (e.data == "finish") {
    178      finish();
    179    } else if (e.data == "expect") {
    180      gExpected++;
    181    } else if (e.data.type == "ok") {
    182      my_ok(e.data.value, "Fetch test on worker: " + e.data.msg);
    183    }
    184  };
    185  worker.onerror = function() {
    186    my_ok(false, "worker should not cause any errors");
    187  };
    188 </script>
    189 </pre>
    190 </body>
    191 </html>