summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/dom/script-element-remove-self.html
blob: a20e4ab4be3a69d093dfb88cabb11483622a6b9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<body>

<p>This test verifies that a &lt;script&gt; element that removes itself 
from the document doesn't crash upon insertion into the document.</p>
<p>PASS: You didn't crash.</p>

<script id="dummy"></script>

<script>
if (window.testRunner)
    testRunner.dumpAsText();

var scriptElement;
var scriptText = "var self = document.getElementById('script'); self.parentNode.removeChild(self);";

/* appendChild */
scriptElement = document.createElement("script");
scriptElement.setAttribute("id", "script");
scriptElement.appendChild(document.createTextNode(scriptText));
document.body.appendChild(scriptElement);

/* insertBefore */
scriptElement = document.createElement("script");
scriptElement.setAttribute("id", "script");
scriptElement.appendChild(document.createTextNode(scriptText));
document.body.insertBefore(scriptElement, document.getElementById("dummy"));

/* replaceChild */
scriptElement = document.createElement("script");
scriptElement.setAttribute("id", "script");
scriptElement.appendChild(document.createTextNode(scriptText));
document.body.replaceChild(scriptElement, document.getElementById("dummy"));
</script>

<script id="script">
/* parser insertion */
eval(scriptText);
</script>

</body>