tor-browser

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

postMessage-wasm-module.html (1069B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4    <meta charset="utf-8">
      5    <title>eval-in-iframe</title>
      6    <script src="/resources/testharness.js"></script>
      7    <script src="/resources/testharnessreport.js"></script>
      8    <script src="/common/utils.js"></script>
      9 </head>
     10 <body>
     11    <iframe src="/content-security-policy/wasm-unsafe-eval/support/iframe.html">
     12    </iframe>
     13 
     14    <script>
     15        async_test(t => {
     16          self.addEventListener('message', t.step_func_done(({data}) => {
     17            assert_equals(data.violatedDirective, "script-src");
     18            assert_equals(data.originalPolicy, "default-src 'unsafe-inline'")
     19            assert_equals(data.blockedURI, "wasm-eval")
     20          }));
     21        }, "Got the expected securitypolicyviolation in the iframe");
     22 
     23        const iframe = document.querySelector('iframe');
     24        iframe.addEventListener('load', () => {
     25            let m = new WebAssembly.Module(
     26                new Uint8Array([0, 0x61, 0x73, 0x6d, 0x1, 0, 0, 0]));
     27            iframe.contentWindow.postMessage(m);
     28        });
     29    </script>
     30 </body>
     31 </html>