1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/netwerk/test/mochitests/test_xhr_method_case.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,66 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +XHR uppercases certain method names, but not others 1.8 +--> 1.9 +<head> 1.10 + <title>Test for XHR Method casing</title> 1.11 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.13 + 1.14 +<script type="text/javascript"> 1.15 + 1.16 +const testMethods = [ 1.17 +// these methods should be normalized 1.18 + ["get", "GET"], 1.19 + ["GET", "GET"], 1.20 + ["GeT", "GET"], 1.21 + ["geT", "GET"], 1.22 + ["GEt", "GET"], 1.23 + ["post", "POST"], 1.24 + ["POST", "POST"], 1.25 + ["delete", "DELETE"], 1.26 + ["DELETE", "DELETE"], 1.27 + ["options", "OPTIONS"], 1.28 + ["OPTIONS", "OPTIONS"], 1.29 + ["put", "PUT"], 1.30 + ["PUT", "PUT"], 1.31 +// HEAD is not tested because we use the resposne body as part of the test 1.32 +// ["head", "HEAD"], 1.33 +// ["HEAD", "HEAD"], 1.34 + 1.35 +// other custom methods should not be normalized 1.36 + ["Foo", "Foo"], 1.37 + ["bAR", "bAR"], 1.38 + ["foobar", "foobar"], 1.39 + ["FOOBAR", "FOOBAR"] 1.40 +] 1.41 + 1.42 +function doIter(index) 1.43 +{ 1.44 + var xhr = new XMLHttpRequest(); 1.45 + xhr.open(testMethods[index][0], 'method.sjs', false); // sync request 1.46 + xhr.send(); 1.47 + is(xhr.status, 200, 'transaction failed'); 1.48 + is(xhr.response, testMethods[index][1], 'unexpected method'); 1.49 +} 1.50 + 1.51 +function dotest() 1.52 +{ 1.53 + SimpleTest.waitForExplicitFinish(); 1.54 + for (var i = 0; i < testMethods.length; i++) { 1.55 + doIter(i); 1.56 + } 1.57 + SimpleTest.finish(); 1.58 +} 1.59 + 1.60 +</script> 1.61 +</head> 1.62 +<body onload="dotest();"> 1.63 +<p id="display"></p> 1.64 +<div id="content" style="display: none"></div> 1.65 +<pre id="test"> 1.66 +</pre> 1.67 +</body> 1.68 +</html> 1.69 +