dom/workers/test/test_jsversion.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/workers/test/test_jsversion.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,68 @@
     1.4 +<!--
     1.5 +  Any copyright is dedicated to the Public Domain.
     1.6 +  http://creativecommons.org/publicdomain/zero/1.0/
     1.7 +-->
     1.8 +<!DOCTYPE HTML>
     1.9 +<html>
    1.10 +<head>
    1.11 +  <title>Test for JSVersion in workers - Bug 487070</title>
    1.12 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.13 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.14 +</head>
    1.15 +<body>
    1.16 +<p id="display"></p>
    1.17 +<div id="content" style="display: none">
    1.18 +
    1.19 +</div>
    1.20 +<pre id="test">
    1.21 +<script class="testbody" language="javascript">
    1.22 +
    1.23 +  var gExpectedError = false;
    1.24 +
    1.25 +  onerror = function(evt) {
    1.26 +    ok(gExpectedError, "Error expected!");
    1.27 +    runTest();
    1.28 +  }
    1.29 +
    1.30 +  function doMagic() {
    1.31 +    var worker = new Worker('jsversion_worker.js');
    1.32 +    worker.onmessage = function(evt) {
    1.33 +      ok(evt.data, 'All the tests passed');
    1.34 +      runTest();
    1.35 +    }
    1.36 +    worker.postMessage(1);
    1.37 +  }
    1.38 +
    1.39 +  var tests = [
    1.40 +    // No custom version
    1.41 +    function() {
    1.42 +      gExpectedError = true;
    1.43 +      SpecialPowers.pushPrefEnv({"set":[['dom.workers.latestJSVersion', false]]},
    1.44 +                                function() { doMagic(true); });
    1.45 +    },
    1.46 +
    1.47 +    // Enable latest JS Version
    1.48 +    function() {
    1.49 +      gExpectedError = false;
    1.50 +      SpecialPowers.pushPrefEnv({"set":[['dom.workers.latestJSVersion', true]]},
    1.51 +                                function() { doMagic(false); });
    1.52 +    }
    1.53 +  ];
    1.54 +
    1.55 +  function runTest() {
    1.56 +    if (!tests.length) {
    1.57 +      SimpleTest.finish();
    1.58 +      return;
    1.59 +    }
    1.60 +
    1.61 +    var test = tests.shift();
    1.62 +    test();
    1.63 +  }
    1.64 +
    1.65 +  SimpleTest.waitForExplicitFinish();
    1.66 +  runTest();
    1.67 +
    1.68 +</script>
    1.69 +</pre>
    1.70 +</body>
    1.71 +</html>

mercurial