<!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>
