1 var sys = require("util")
2 , assert = require("assert")
3 , XMLHttpRequest = require("../lib/XMLHttpRequest").XMLHttpRequest
4 , xhr = new XMLHttpRequest();
6 // Test request methods that aren't allowed
8 xhr.open("TRACK", "http://localhost:8000/");
9 console.log("ERROR: TRACK should have thrown exception");
12 xhr.open("TRACE", "http://localhost:8000/");
13 console.log("ERROR: TRACE should have thrown exception");
16 xhr.open("CONNECT", "http://localhost:8000/");
17 console.log("ERROR: CONNECT should have thrown exception");
19 // Test valid request method
21 xhr.open("GET", "http://localhost:8000/");
23 console.log("ERROR: Invalid exception for GET", e);
26 // Test forbidden headers
27 var forbiddenRequestHeaders = [
30 "access-control-request-headers",
31 "access-control-request-method",
34 "content-transfer-encoding",
51 for (var i in forbiddenRequestHeaders) {
53 xhr.setRequestHeader(forbiddenRequestHeaders[i], "Test");
54 console.log("ERROR: " + forbiddenRequestHeaders[i] + " should have thrown exception");
60 xhr.setRequestHeader("X-Foobar", "Test");