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