levin@chromium.org | a1f891d | 2010-03-23 22:27:17 +0000 | [diff] [blame] | 1 | <html> |
| 2 | <body> |
| 3 | Tests that sending undefined or null results in an empty request body. |
| 4 | <script> |
rniwa@webkit.org | 14a295a | 2012-06-13 07:49:51 +0000 | [diff] [blame] | 5 | if (window.testRunner) |
| 6 | testRunner.dumpAsText(); |
levin@chromium.org | a1f891d | 2010-03-23 22:27:17 +0000 | [diff] [blame] | 7 | |
| 8 | var console_messages = document.createElement("ul"); |
| 9 | document.body.appendChild(console_messages); |
| 10 | |
| 11 | function log(message) |
| 12 | { |
| 13 | var item = document.createElement("li"); |
| 14 | item.appendChild(document.createTextNode(message)); |
| 15 | console_messages.appendChild(item); |
| 16 | } |
| 17 | |
| 18 | xhr = new XMLHttpRequest; |
| 19 | xhr.open("POST", "resources/post-echo.cgi", false); |
| 20 | xhr.send(undefined); |
| 21 | if (!xhr.responseText.length) |
| 22 | log("PASS for undefined"); |
| 23 | else |
| 24 | log("FAILED: The posted content when sending 'undefined' is '" + xhr.responseText +"'. It should have been ''."); |
| 25 | |
| 26 | xhr = new XMLHttpRequest; |
| 27 | xhr.open("POST", "resources/post-echo.cgi", false); |
| 28 | xhr.send(null); |
| 29 | if (!xhr.responseText.length) |
| 30 | log("PASS for null"); |
| 31 | else |
| 32 | log("FAILED: The posted content when sending 'null' is '" + xhr.responseText +"'. It should have been ''."); |
| 33 | </script> |
| 34 | </body> |
| 35 | </html> |