test_worker_xhr_responseURL.html 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <!DOCTYPE HTML>
  2. <html>
  3. <!--
  4. https://bugzilla.mozilla.org/show_bug.cgi?id=998076
  5. -->
  6. <head>
  7. <meta charset="utf-8">
  8. <title>Test for Bug 998076</title>
  9. <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  10. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  11. <script type="application/javascript">
  12. /** Test for Bug 998076 **/
  13. "use strict";
  14. var worker = new Worker("../../../dom/xhr/tests/file_XHRResponseURL.js");
  15. var requestObserver = {
  16. observe: function (aSubject, aTopic, aData) {
  17. worker.postMessage("request");
  18. }
  19. };
  20. worker.addEventListener("message", function (aEvent) {
  21. var data = aEvent.data;
  22. if (data == "done") {
  23. SimpleTest.finish();
  24. return;
  25. }
  26. if (data == "start") {
  27. return;
  28. }
  29. if (data.type == "is") {
  30. SimpleTest.is(data.actual, data.expected, data.message);
  31. worker.postMessage("pong");
  32. return;
  33. }
  34. if (data.type == "ok") {
  35. SimpleTest.ok(data.bool, data.message);
  36. worker.postMessage("pong");
  37. return;
  38. }
  39. if (data.type == "info") {
  40. SimpleTest.info(data.message);
  41. worker.postMessage("pong");
  42. return;
  43. }
  44. if (data.type === "redirect_test") {
  45. if (data.status === "start") {
  46. SpecialPowers.addObserver(requestObserver, "specialpowers-http-notify-request", false);
  47. return;
  48. }
  49. if (data.status === "end") {
  50. SpecialPowers.removeObserver(requestObserver, "specialpowers-http-notify-request");
  51. return;
  52. }
  53. }
  54. });
  55. function runTests() {
  56. SimpleTest.waitForExplicitFinish();
  57. worker.postMessage("start");
  58. }
  59. </script>
  60. </head>
  61. <body onload="runTests()">
  62. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=998076">Mozilla Bug 998076</a>
  63. <p id="display"></p>
  64. <div id="content" style="display: none">
  65. </div>
  66. <pre id="test">
  67. </pre>
  68. </body>
  69. </html>