summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/dom/script-clone-rerun-self.html
blob: 802edf128c7865139474e48f7a85eb782220b943 (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
<!DOCTYPE>
<html>
<head>
<script>
var i = 0;
</script>
</head>
<body>
<p>This test runs a script that clones and inserts its script element. The script should run exactly once and print PASS:</p>
<div><script>
i++;

var script = document.getElementsByTagName('script')[1];
var div = script.parentNode;
div.removeChild(script);
div.appendChild(script.cloneNode(true));

</script></div>
<script>

if (window.testRunner)
    testRunner.dumpAsText();

result = 'PASS';
if (i == 2)
  result = 'FAIL: script ran twice';
else if (i > 2)
  result = 'FAIL: script ran ' + i + ' times';
document.body.appendChild(document.createTextNode(result));

</script>
</body>
</html>