blob: 2463869fe39b0f411851ac66718a62f1a1fbf1a7 [file] [log] [blame]
<html>
<body>
<p>XMLHttpRequest.open() should be correctly overloaded</p>
<script>
var console_messages = document.createElement("ol");
document.body.appendChild(console_messages);
function log(message)
{
var item = document.createElement("li");
item.appendChild(document.createTextNode(message));
console_messages.appendChild(item);
}
function shouldSendBehaveAs(req, async, description)
{
var expectedState = async ? 1 : 4;
req.send();
if (req.readyState == expectedState)
log("PASS: " + description);
else
log("FAIL: " + description + " (expected:" + expectedState + ", actual:" + req.readyState +")");
}
if (window.testRunner)
testRunner.dumpAsText();
req = new XMLHttpRequest();
req.open("GET", "methods.cgi?1", true);
shouldSendBehaveAs(req, true, "if async argument is true, send() should behave asynchronously");
req = new XMLHttpRequest();
req.open("GET", "methods.cgi?2", false);
shouldSendBehaveAs(req, false, "if async argument is false, send() should behave synchronously");
req = new XMLHttpRequest();
req.open("GET", "methods.cgi?3");
shouldSendBehaveAs(req, true, "if async argument is not given, send() should behave like as async=true");
req = new XMLHttpRequest();
req.open("GET", "methods.cgi?4", undefined);
shouldSendBehaveAs(req, false, "if async argument is undefined, send() should behave like as async=false");
req = new XMLHttpRequest();
req.open("GET", "methods.cgi?5", "OK");
shouldSendBehaveAs(req, true, "if async argument is a non-empty string, send() should behave like as async=true");
</script>
</body>
</html>