tor-browser

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

test_xhr_method_case.html (1427B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 XHR uppercases certain method names, but not others
      5 -->
      6 <head>
      7  <title>Test for XHR Method casing</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     10 
     11 <script type="text/javascript">
     12 
     13 const testMethods = [
     14 // these methods should be normalized
     15 ["get", "GET"],
     16 ["GET", "GET"],
     17 ["GeT", "GET"],
     18 ["geT", "GET"],
     19 ["GEt", "GET"],
     20 ["post", "POST"],
     21 ["POST", "POST"],
     22 ["delete", "DELETE"],
     23 ["DELETE", "DELETE"],
     24 ["options", "OPTIONS"],
     25 ["OPTIONS", "OPTIONS"],
     26 ["put", "PUT"],
     27 ["PUT", "PUT"],
     28 // HEAD is not tested because we use the resposne body as part of the test
     29 // ["head", "HEAD"],
     30 // ["HEAD", "HEAD"],
     31 
     32 // other custom methods should not be normalized
     33 ["Foo", "Foo"],
     34 ["bAR", "bAR"],
     35 ["foobar", "foobar"],
     36 ["FOOBAR", "FOOBAR"]
     37 ]
     38 
     39 function doIter(index)
     40 {
     41  var xhr = new XMLHttpRequest();
     42  xhr.open(testMethods[index][0], 'method.sjs', false); // sync request
     43  xhr.send();
     44  is(xhr.status, 200, 'transaction failed');
     45  is(xhr.response, testMethods[index][1], 'unexpected method');
     46 }
     47 
     48 function dotest()
     49 {
     50  SimpleTest.waitForExplicitFinish();
     51  for (var i = 0; i < testMethods.length; i++) {
     52    doIter(i);
     53  }
     54  SimpleTest.finish();
     55 }
     56 
     57 </script>
     58 </head>
     59 <body onload="dotest();">
     60 <p id="display"></p>
     61 <div id="content" style="display: none"></div>
     62 <pre id="test">
     63 </pre>
     64 </body>
     65 </html>