You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
715 B

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