test_jsversion.html 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 for JSVersion in workers - Bug 487070</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">
  15. </div>
  16. <pre id="test">
  17. <script class="testbody" language="javascript">
  18. var gExpectedError = false;
  19. onerror = function(evt) {
  20. ok(gExpectedError, "Error expected!");
  21. runTest();
  22. }
  23. function doMagic() {
  24. var worker = new Worker('jsversion_worker.js');
  25. worker.onmessage = function(evt) {
  26. ok(evt.data, 'All the tests passed');
  27. runTest();
  28. }
  29. worker.postMessage(1);
  30. }
  31. var tests = [
  32. // No custom version
  33. function() {
  34. gExpectedError = true;
  35. SpecialPowers.pushPrefEnv({"set":[['dom.workers.latestJSVersion', false]]},
  36. function() { doMagic(true); });
  37. },
  38. // Enable latest JS Version
  39. function() {
  40. gExpectedError = false;
  41. SpecialPowers.pushPrefEnv({"set":[['dom.workers.latestJSVersion', true]]},
  42. function() { doMagic(false); });
  43. }
  44. ];
  45. function runTest() {
  46. if (!tests.length) {
  47. SimpleTest.finish();
  48. return;
  49. }
  50. var test = tests.shift();
  51. test();
  52. }
  53. SimpleTest.waitForExplicitFinish();
  54. runTest();
  55. </script>
  56. </pre>
  57. </body>
  58. </html>