tor-browser

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

file_bug1456721.html (2167B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <head>
      4  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
      5  <title>Test new CORS console messages</title>
      6 </head>
      7 <body onload="initTest()">
      8 <p id="display">
      9 <iframe id=loader></iframe>
     10 </p>
     11 <div id="content" style="display: none">
     12 </div>
     13 <pre id="test">
     14 <script class="testbody" type="application/javascript">
     15 
     16 let gen;
     17 let number_of_tests = 0;
     18 
     19 function initTest() {
     20  window.addEventListener("message", function(e) {
     21    gen.next(e.data);
     22    if (number_of_tests == 2) {
     23      document.location.href += "#finishedTestTwo";
     24    }
     25  });
     26 
     27  gen = runTest();
     28 
     29  gen.next();
     30 }
     31 
     32 function* runTest() {
     33  let loader = document.getElementById("loader");
     34  let loaderWindow = loader.contentWindow;
     35  loader.onload = function() { gen.next(); };
     36 
     37  loader.src = "http://example.org/browser/dom/security/test/cors/file_CrossSiteXHR_inner.html";
     38  origin = "http://example.org";
     39  yield undefined;
     40 
     41  let tests = [
     42               // Loading URLs other than http(s) should throw 'CORS request
     43               // not http' console message. (Even though we removed ftp support within Bug 1574475
     44               // we keep this test since it tests a scheme other than http(s))
     45               { baseURL: "ftp://mochi.test:8888/browser/dom/security/test/cors/file_CrossSiteXHR_server.sjs",
     46                 method: "GET",
     47               },
     48               // (https://www.w3.org/TR/cors/#cross-origin-request-with-preflight-0)
     49               // CORs preflight external redirect should throw 'CORS request
     50               // external redirect not allowed' error.
     51               // This will also throw 'CORS preflight channel did not succeed'
     52               // and 'CORS request did not succeed' console messages.
     53               {
     54                 baseURL: "http://mochi.test:8888/browser/dom/security/test/cors/bug1456721.sjs?redirect",
     55                 method: "OPTIONS",
     56               },
     57              ];
     58 
     59  for (let test of tests) {
     60    let req = {
     61      url: test.baseURL,
     62      method: test.method
     63    };
     64 
     65    loaderWindow.postMessage(JSON.stringify(req), origin);
     66    number_of_tests++;
     67    yield;
     68  }
     69 }
     70 
     71 </script>
     72 </pre>
     73 </body>
     74 </html>