Node-appendChild-script-and-button-from-div.tentative.html (925B)
1 <!doctype html> 2 <meta charset=utf-8> 3 <title>Node.appendChild: inserting script and button from a div</title> 4 <script src=/resources/testharness.js></script> 5 <script src=/resources/testharnessreport.js></script> 6 <form id="form"></form> 7 <script> 8 let button = null; 9 let buttonForm = null; 10 test(() => { 11 const form = document.getElementById("form"); 12 const script = document.createElement("script"); 13 script.textContent = ` 14 buttonForm = button.form; 15 `; 16 button = document.createElement("button"); 17 const div = document.createElement("div"); 18 div.appendChild(script); 19 div.appendChild(button); 20 assert_equals(buttonForm, null); 21 form.appendChild(div); 22 assert_equals(buttonForm, form); 23 }, "Script inserted before a form-associated button can observe the button's " + 24 "form, because by the time the script executes, the DOM insertion that " + 25 "associates the button with the form is already done"); 26 </script>