test_XHR_timeout.html 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=525816
  5. -->
  6. <head>
  7. <title>Test for Bug 525816</title>
  8. <script type="application/javascript"
  9. src="/MochiKit/MochiKit.js"></script>
  10. <script type="application/javascript"
  11. src="/tests/SimpleTest/SimpleTest.js"></script>
  12. <link rel="stylesheet"
  13. type="text/css"
  14. href="/tests/SimpleTest/test.css">
  15. </head>
  16. <body>
  17. <a target="_blank"
  18. href="https://bugzilla.mozilla.org/show_bug.cgi?id=525816"
  19. >Mozilla Bug 525816 (XMLHttpRequest timeout)</a>
  20. <p id="display"></p>
  21. <div id="content">
  22. This test takes over 1 minute to run, probably over 2 minutes.
  23. </div>
  24. <pre id="test">
  25. <script class="testbody"
  26. type="text/javascript"
  27. src="test_XHR_timeout.js"></script>
  28. <script type="text/javascript">
  29. window.addEventListener("message", function (event) {
  30. if (event.data == "done") {
  31. SimpleTest.finish();
  32. return;
  33. }
  34. if (event.data == "start") {
  35. return;
  36. }
  37. if (event.data.type == "is") {
  38. SimpleTest.is(event.data.got, event.data.expected, event.data.msg);
  39. return;
  40. }
  41. if (event.data.type == "ok") {
  42. SimpleTest.ok(event.data.bool, event.data.msg);
  43. return;
  44. }
  45. });
  46. // Final test harness setup and launch.
  47. (function() {
  48. SimpleTest.waitForExplicitFinish();
  49. SimpleTest.requestLongerTimeout(TestRequests.length);
  50. SimpleTest.requestFlakyTimeout("This is testing XHR timeouts.");
  51. var msg = "This test will take approximately " + (TestRequests.length * 10)
  52. msg += " seconds to complete, at most.";
  53. document.getElementById("content").firstChild.nodeValue = msg;
  54. window.postMessage("start", "*");
  55. })();
  56. </script>
  57. </pre>
  58. </body>
  59. </html>