test_referrer.html 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <!--
  2. Any copyright is dedicated to the Public Domain.
  3. http://creativecommons.org/publicdomain/zero/1.0/
  4. -->
  5. <!DOCTYPE HTML>
  6. <html>
  7. <head>
  8. <title>Test the referrer of workers</title>
  9. <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  10. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
  11. </head>
  12. <body>
  13. <p id="display"></p>
  14. <div id="content" style="display: none"></div>
  15. <pre id="test"></pre>
  16. <script class="testbody" type="text/javascript">
  17. function test_mainScript() {
  18. var worker = new Worker("referrer.sjs?worker");
  19. worker.onmessage = function() {
  20. var xhr = new XMLHttpRequest();
  21. xhr.open('GET', 'referrer.sjs?result', true);
  22. xhr.onload = function() {
  23. is(xhr.responseText, location.href, "The referrer has been sent.");
  24. next();
  25. }
  26. xhr.send();
  27. }
  28. worker.postMessage(42);
  29. }
  30. function test_importScript() {
  31. var worker = new Worker("worker_referrer.js");
  32. worker.onmessage = function(e) {
  33. is(e.data, location.href.replace("test_referrer.html", "worker_referrer.js"), "The referrer has been sent.");
  34. next();
  35. }
  36. worker.postMessage(42);
  37. }
  38. var tests = [ test_mainScript, test_importScript ];
  39. function next() {
  40. if (!tests.length) {
  41. SimpleTest.finish();
  42. return;
  43. }
  44. var test = tests.shift();
  45. test();
  46. }
  47. SimpleTest.waitForExplicitFinish();
  48. next();
  49. </script>
  50. </pre>
  51. </body>
  52. </html>