OLD | NEW |
1 <html> | 1 <html> |
2 <body onload="setTimeout(delayedThrowException, 0); throw 'Exception in onload';
"> | 2 <body onload="setTimeout(delayedThrowException, 0); throw 'Exception in onload';
"> |
3 <p>Test that uncaught exceptions will be reported to the window.onerror handler.
<a href="https://bugs.webkit.org/show_bug.cgi?id=8519">Bug 8519</a>.</p> | 3 <p>Test that uncaught exceptions will be reported to the window.onerror handler.
<a href="https://bugs.webkit.org/show_bug.cgi?id=8519">Bug 8519</a>.</p> |
4 <div id="result"></div> | 4 <div id="result"></div> |
5 <script> | 5 <script> |
6 if (window.testRunner) { | 6 if (window.testRunner) { |
7 testRunner.dumpAsText(); | 7 testRunner.dumpAsText(); |
8 testRunner.waitUntilDone(); | 8 testRunner.waitUntilDone(); |
9 } | 9 } |
10 | 10 |
11 function log(msg) { | 11 function log(msg) { |
12 document.getElementById("result").innerHTML += msg + "<br>"; | 12 document.getElementById("result").innerHTML += msg + "<br>"; |
13 } | 13 } |
14 | 14 |
15 var unhandledErrorCount = 0; | 15 var unhandledErrorCount = 0; |
16 window.onerror = function(msg, url, line) | 16 window.onerror = function(msg, url, line, column) |
17 { | 17 { |
18 url = url ? url.match( /[^\/]+\/?$/ )[0] : url; | 18 url = url ? url.match( /[^\/]+\/?$/ )[0] : url; |
19 log("Main frame window.onerror: " + msg + " at " + url + ":" + line); | 19 log("Main frame window.onerror: " + msg + " at " + url + ", line: " + line +
", column: " + column); |
20 | 20 |
21 if (++unhandledErrorCount === 3 && window.testRunner) | 21 if (++unhandledErrorCount === 3 && window.testRunner) |
22 testRunner.notifyDone(); | 22 testRunner.notifyDone(); |
23 | 23 |
24 return true; | 24 return true; |
25 } | 25 } |
26 | 26 |
27 function delayedThrowException() | 27 function delayedThrowException() |
28 { | 28 { |
29 throw new Error("Exception in setTimeout"); | 29 throw new Error("Exception in setTimeout"); |
30 } | 30 } |
31 | 31 |
32 function throwException() | 32 function throwException() |
33 { | 33 { |
34 throw new Error("Inline script exception"); | 34 throw new Error("Inline script exception"); |
35 } | 35 } |
36 throwException(); | 36 throwException(); |
37 | 37 |
38 </script> | 38 </script> |
39 </body> | 39 </body> |
40 </html> | 40 </html> |
OLD | NEW |