summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/dom/script-clone-rerun-src.xhtml
blob: 92a6d1def0252f8bf7f299bf40c870cf7646d3f0 (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
41
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
<script>

var i = 0;

if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}
</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 src="resources/script-clone-rerun-src.js"></script></div>
<script>

var script = document.getElementsByTagName('script')[1];
var div = script.parentNode;
div.removeChild(script);
var clone = script.cloneNode(true);
clone.addEventListener("load", function() { document.body.appendChild(document.createTextNode("FAIL: load event fired on clone")); }, false);
div.appendChild(clone);

setTimeout(function() {
    result = 'FAIL: script never ran';
    if (i == 1)
      result = 'PASS';
    else if (i > 1)
      result = 'FAIL: script ran ' + i + ' times';
    document.body.appendChild(document.createTextNode(result));
    if (window.testRunner)
        testRunner.notifyDone();
    }, 0);

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