script-does-not-run-on-child-removal.window.js (1296B)
1 // See: 2 // - https://github.com/whatwg/dom/issues/808 3 // - https://github.com/whatwg/dom/pull/1261 4 // - https://github.com/whatwg/html/pull/10188 5 // - https://source.chromium.org/chromium/chromium/src/+/604e798ec6ee30f44d57a5c4a44ce3dab3a871ed 6 // - https://github.com/whatwg/dom/pull/732#pullrequestreview-328249015 7 // - https://github.com/whatwg/html/pull/4354#issuecomment-476038918 8 test(() => { 9 window.script_did_run = false; 10 11 const script = document.createElement('script'); 12 // This prevents execution on insertion. 13 script.type = '0'; 14 script.textContent = `script_did_run = true;`; 15 document.body.append(script); 16 assert_false(script_did_run, 17 'Appending script with invalid type does not trigger execution'); 18 19 const div = document.createElement('div'); 20 script.append(div); 21 assert_false(script_did_run, 22 'Appending a child to an invalid-type script does not trigger execution'); 23 24 // This enables, but does not trigger, execution. 25 script.type = ''; 26 assert_false(script_did_run, 27 'Unsetting script type does not trigger execution'); 28 29 div.remove(); 30 assert_false(script_did_run, 31 'Removing child from valid script that has not already run, does not ' + 32 'trigger execution'); 33 }, "Script execution is never triggered on child removals");