tor-browser

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

nomodule-set-on-inline-classic-scripts.html (1557B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4 <title>Inline classic scripts with nomodule content attribute must not run</title>
      5 <link rel="author" title="Yusuke Suzuki" href="mailto:utatane.tea@gmail.com">
      6 <link rel="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org">
      7 <script src="/resources/testharness.js"></script>
      8 <script src="/resources/testharnessreport.js"></script>
      9 </head>
     10 <body>
     11 <script>
     12 window.executed = true;
     13 </script>
     14 <script>
     15 
     16 test(() => {
     17    assert_true(executed);
     18 }, 'An inline classic script without nomodule content attribute must run');
     19 
     20 
     21 window.executed = false;
     22 </script>
     23 <script nomodule>
     24 window.executed = true;
     25 </script>
     26 <script>
     27 
     28 test(() => {
     29    assert_false(executed);
     30 }, 'An inline classic script with nomodule content attribute must not run');
     31 
     32 </script>
     33 <script>
     34 
     35 test(() => {
     36    window.executed = false;
     37    const element = document.createElement("script");
     38    element.noModule = false;
     39    element.textContent = `window.executed = true`;
     40    document.body.appendChild(element);
     41    assert_true(window.executed);
     42 }, 'An inline classic script element dynamically inserted after noModule was set to false must run.');
     43 
     44 test(() => {
     45    window.executed = false;
     46    const element = document.createElement("script");
     47    element.noModule = true;
     48    element.textContent = `window.executed = true`;
     49    document.body.appendChild(element);
     50    assert_false(window.executed);
     51 }, 'An inline classic script element dynamically inserted after noModule was set to true must not run.');
     52 
     53 window.executed = false;
     54 </script>
     55 </body>
     56 </html>