annotate node_modules/xmlhttprequest/tests/test-request-protocols.js @ 101:52e44ee1c791 tip master

enabled all scores in autostart script
author Rob Canning <rc@kiben.net>
date Tue, 21 Apr 2015 16:20:57 +0100
parents cd921abc8887
children
rev   line source
rob@77 1 var sys = require("util")
rob@77 2 , assert = require("assert")
rob@77 3 , XMLHttpRequest = require("../lib/XMLHttpRequest").XMLHttpRequest
rob@77 4 , xhr;
rob@77 5
rob@77 6 xhr = new XMLHttpRequest();
rob@77 7
rob@77 8 xhr.onreadystatechange = function() {
rob@77 9 if (this.readyState == 4) {
rob@77 10 assert.equal("Hello World", this.responseText);
rob@77 11 this.close();
rob@77 12 runSync();
rob@77 13 }
rob@77 14 };
rob@77 15
rob@77 16 // Async
rob@77 17 var url = "file://" + __dirname + "/testdata.txt";
rob@77 18 xhr.open("GET", url);
rob@77 19 xhr.send();
rob@77 20
rob@77 21 // Sync
rob@77 22 var runSync = function() {
rob@77 23 xhr = new XMLHttpRequest();
rob@77 24
rob@77 25 xhr.onreadystatechange = function() {
rob@77 26 if (this.readyState == 4) {
rob@77 27 assert.equal("Hello World", this.responseText);
rob@77 28 this.close();
rob@77 29 sys.puts("done");
rob@77 30 }
rob@77 31 };
rob@77 32 xhr.open("GET", url, false);
rob@77 33 xhr.send();
rob@77 34 }