socketioMEANseed/server/node_modules/xmlhttprequest-ssl/tests/test-request-protocols.js
server/node_modules/xmlhttprequest-ssl/tests/test-request-protocols.jsRaw
1var sys = require("util")
2 , assert = require("assert")
3 , XMLHttpRequest = require("../lib/XMLHttpRequest").XMLHttpRequest
4 , xhr;
5
6xhr = new XMLHttpRequest();
7
8xhr.onreadystatechange = function() {
9 if (this.readyState == 4) {
10 assert.equal("Hello World", this.responseText);
11 runSync();
12 }
13};
14
15// Async
16var url = "file://" + __dirname + "/testdata.txt";
17xhr.open("GET", url);
18xhr.send();
19
20// Sync
21var runSync = function() {
22 xhr = new XMLHttpRequest();
23
24 xhr.onreadystatechange = function() {
25 if (this.readyState == 4) {
26 assert.equal("Hello World", this.responseText);
27 sys.puts("done");
28 }
29 };
30 xhr.open("GET", url, false);
31 xhr.send();
32}