| <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", true); |
| shouldSendBehaveAs(req, true, "if async argument is true, send() should behave asynchronously"); |
| |
| req = new XMLHttpRequest(); |
| req.open("GET", "methods.cgi", false); |
| shouldSendBehaveAs(req, false, "if async argument is false, send() should behave synchronously"); |
| |
| req = new XMLHttpRequest(); |
| req.open("GET", "methods.cgi"); |
| shouldSendBehaveAs(req, true, "if async argument is not given, send() should behave like as async=true"); |
| |
| req = new XMLHttpRequest(); |
| req.open("GET", "methods.cgi", undefined); |
| shouldSendBehaveAs(req, false, "if async argument is undefined, send() should behave like as async=false"); |
| |
| req = new XMLHttpRequest(); |
| req.open("GET", "methods.cgi", "OK"); |
| shouldSendBehaveAs(req, true, "if async argument is a non-empty string, send() should behave like as async=true"); |
| |
| </script> |
| </body> |
| </html> |