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