tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_eval_allowed.html (1387B)


      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>Bug 1160458 - CSP activated by default in Service Workers</title>
      9  <script 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 register() {
     18    return navigator.serviceWorker.register("eval_worker.js");
     19  }
     20 
     21  function runTest() {
     22    try {
     23      // eslint-disable-next-line no-eval
     24      eval("1");
     25      ok(false, "should throw");
     26    }
     27    catch (ex) {
     28      ok(true, "did throw");
     29    }
     30    register()
     31      .then(function(swr) {
     32        ok(true, "eval restriction didn't get inherited");
     33        swr.unregister()
     34          .then(function() {
     35            SimpleTest.finish();
     36          });
     37      }).catch(function(e) {
     38        ok(false, "Some test failed with error " + e);
     39        SimpleTest.finish();
     40      });
     41  }
     42 
     43  SimpleTest.waitForExplicitFinish();
     44  SpecialPowers.pushPrefEnv({"set": [
     45    ["dom.serviceWorkers.exemptFromPerDomainMax", true],
     46    ["dom.serviceWorkers.enabled", true],
     47    ["dom.serviceWorkers.testing.enabled", true],
     48  ]}, runTest);
     49 </script>
     50 </pre>
     51 </body>
     52 </html>