Use testRunner instead of layoutTestController in fast/doctypes, dom, dynamic, encodi...
[WebKit-https.git] / LayoutTests / fast / dom / HTMLScriptElement / script-load-events.html
1 <html>
2 <head>
3 <title>&lt;SCRIPT&gt; load and error events</title>
4 <script type="text/javascript">
5 var status_ = new Array();
6
7 function loaded(i)
8 {
9     status_[i] = "L";
10 }
11
12 function erred(i)
13 {
14     status_[i] = "E";
15 }
16
17 function endTest()
18 {
19     var failures = "";
20     if (status_[0] != "E")
21         failures += "0 ";
22     if (status_[1] != "E")
23         failures += "1 ";
24
25     if (status_[2] != "L")
26         failures += "2 ";
27     if (status_[4] != "L")
28         failures += "4 ";
29     if (status_[5] != "L")
30         failures += "5 ";
31
32     var results = document.getElementById("results");
33     if (failures)
34         results.innerHTML = "FAIL: The following tests failed: " + failures;
35     else
36         results.innerHTML = "PASS";
37
38     if (window.testRunner)
39         testRunner.notifyDone();
40 }
41
42 function test()
43 {
44     if (window.testRunner) {
45         testRunner.dumpAsText();
46         testRunner.waitUntilDone();
47     }
48
49     var e = document.createElement("script");
50     e.type = "text/javascript";
51     e.src = 'resources/script-load.js';
52     e.onload = function() {
53         loaded(5);
54         endTest();
55     };
56     document.getElementsByTagName("head")[0].appendChild( e ); 
57 }
58 </script>
59 </head>
60 <body onload="test()">
61 <script type="text/javascript" onload="loaded(0)" onerror="erred(0)" src="resources/certainlydoesnotexist.js"></script>
62 <script type="text/javascript" onload="loaded(1)" onerror="erred(1)" src="resources/certainlydoesnotexist.js"></script>
63 <script type="text/javascript" onload="loaded(2)" onerror="erred(2)" src="resources/script-load.js"></script>
64 <!-- 3 was a self-closing script tag, however that is covered by fast/parser/script-tag-with-trailing-slash.html -->
65 <script type="text/javascript">
66     document.write('<script type="text/javascript" onload="loaded(4)" onerror="erred(4)" src="resources/script-load.js"></script'+'>');
67 </script>
68 This tests for regressions against <i><a href="https://bugs.webkit.org/show_bug.cgi?id=5812">https://bugs.webkit.org/show_bug.cgi?id=5812</a>
69 Generate load events for &lt;script&gt; elements</i>.
70 <hr>
71 <p id="results">FAIL: Test never finished.</p>
72 </body>
73 </html>