| <html> |
| <body> |
| <iframe name="blank" src="about:blank"></iframe> |
| <iframe name="js" src="javascript:'<html><\/html>'"></iframe> |
| <iframe name="srcdoc" srcdoc="<script src='included_script.js'></script>"></iframe> |
| </body> |
| <script> |
| // Inject content into the blank frames. |
| let blankFrame = document.getElementsByName("blank")[0]; |
| let script = document.createElement("script"); |
| script.src = "included_script.js"; |
| blankFrame.contentDocument.body.appendChild(script); |
| |
| // Add a grandchild and add content to the grandchild frame. |
| let grandChild = document.createElement("iframe"); |
| grandChild.name = "grandChild"; |
| grandChild.src = "frame_with_included_script.html"; |
| blankFrame.contentDocument.body.appendChild(grandChild); |
| |
| let jsFrame = document.getElementsByName("js")[0]; |
| let script2 = document.createElement("script"); |
| script2.src = "included_script.js"; |
| jsFrame.contentDocument.body.appendChild(script2); |
| |
| // Add a frame with a data URL, making sure it loads a script pointing to |
| // the right host and port. |
| let dataFrame = document.createElement('iframe'); |
| dataFrame.name = "data"; |
| |
| let scriptPath = location.pathname.split("/"); |
| scriptPath[scriptPath.length - 1] = "included_script.js"; |
| scriptPath = scriptPath.join("/"); |
| |
| let url = new URL(location.href); |
| url.pathname = scriptPath; |
| dataFrame.src = "data:text/html,<script src='" + url + "'><\/script>"; |
| document.body.appendChild(dataFrame); |
| </script> |
| </html> |