Opal-Estate-Pro/node_modules/xmlhttprequest-ssl/tests/test-request-protocols.js

33 lines
677 B
JavaScript
Raw Normal View History

2019-09-13 06:27:52 +02:00
var sys = require("util")
, assert = require("assert")
, XMLHttpRequest = require("../lib/XMLHttpRequest").XMLHttpRequest
, xhr;
xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (this.readyState == 4) {
assert.equal("Hello World", this.responseText);
runSync();
}
};
// Async
var url = "file://" + __dirname + "/testdata.txt";
xhr.open("GET", url);
xhr.send();
// Sync
var runSync = function() {
xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (this.readyState == 4) {
assert.equal("Hello World", this.responseText);
sys.puts("done");
}
};
xhr.open("GET", url, false);
xhr.send();
}