remove-src-attr-prepare-a-script.html (1223B)
1 <!doctype html> 2 <meta charset=utf-8> 3 <link rel=help href=https://github.com/whatwg/html/pull/10188/files#r1685905457> 4 <title>Remove src attribute does not "prepare the script"</title> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 8 <body> 9 <script> 10 test(() => { 11 // Flags that the script element in this test will change, if it incorrectly 12 // executes. 13 window.didExecute = false; 14 window.innerTextExecuted = false; 15 16 const script = document.createElement('script'); 17 // Invalid type, so the script won't execute upon insertion. 18 script.type = 'invalid'; 19 script.src = 'resources/flag-setter.js'; 20 script.innerText = 'window.innerTextExecuted = true'; 21 document.body.append(script); 22 assert_false(window.didExecute); 23 assert_false(window.innerTextExecuted); 24 25 // Make script valid, but don't immediately execute it. 26 script.type = ''; 27 28 // Removing the `src` content attribute does not trigger the "prepare a 29 // script" algorithm on the script. 30 script.removeAttribute('src'); 31 assert_false(window.didExecute); 32 assert_false(window.innerTextExecuted); 33 }, "Removing the `src` content attribute does not 'prepare' the script"); 34 </script> 35 </body>