yurys@chromium.org | 94a4aed | 2011-10-31 22:03:22 +0000 | [diff] [blame] | 1 | <html> |
| 2 | <head> |
| 3 | <script src="resources/window-onerror.js"> |
| 4 | </script> |
| 5 | </head> |
| 6 | <body> |
| 7 | <p>Test that window.onerror is called on window object when there is a syntax error |
| 8 | in attribute handler. <a href="https://bugs.webkit.org/show_bug.cgi?id=70991">Bug 70991</a>.</p> |
| 9 | <div id="console"></div> |
| 10 | <button id="btn1" onclick="%">Button 1</button> |
| 11 | <script> |
rniwa@webkit.org | ada3c20 | 2012-06-20 03:28:42 +0000 | [diff] [blame] | 12 | if (window.testRunner) |
| 13 | testRunner.dumpAsText(); |
yurys@chromium.org | 94a4aed | 2011-10-31 22:03:22 +0000 | [diff] [blame] | 14 | |
| 15 | function log(msg) { |
| 16 | document.getElementById("console").innerHTML += msg + "<br>"; |
| 17 | } |
| 18 | |
| 19 | window.onerror = function(msg, url, line) |
| 20 | { |
| 21 | url = url ? url.match( /[^\/]+\/?$/ )[0] : url; |
| 22 | log("Main frame window.onerror: " + msg + " at " + url + ":" + line); |
| 23 | return true; |
| 24 | } |
| 25 | |
| 26 | document.write('<button id="btn2" onclick="%">Button 2</button>\n'); |
| 27 | |
| 28 | var button3 = document.createElement("button"); |
| 29 | button3.textContent = "Button 3"; |
| 30 | button3.setAttribute("onclick", "%"); |
| 31 | document.body.appendChild(button3); |
| 32 | |
| 33 | document.getElementById("btn1").click(); |
| 34 | document.getElementById("btn2").click(); |
| 35 | button3.click(); |
| 36 | </script> |
| 37 | </body> |
| 38 | </html> |