Diff
Modified: trunk/LayoutTests/ChangeLog (98884 => 98885)
--- trunk/LayoutTests/ChangeLog 2011-10-31 21:34:59 UTC (rev 98884)
+++ trunk/LayoutTests/ChangeLog 2011-10-31 22:03:22 UTC (rev 98885)
@@ -1,3 +1,21 @@
+2011-10-31 Yury Semikhatsky <[email protected]>
+
+ window.onerror doesn't work with inline (attribute) scripts
+ https://bugs.webkit.org/show_bug.cgi?id=70991
+
+ Added a couple of window.onerror tests for the cases when uncaught exception
+ occurs in inline event handler. Test for non-syntax errors passed before this change
+ as well and just extends test coverage for window.onerror functionality.
+
+ Reviewed by Geoffrey Garen.
+
+ * fast/events/window-onerror-exception-in-attr-expected.txt: Added.
+ * fast/events/window-onerror-exception-in-attr.html: Added.
+ * fast/events/window-onerror-syntax-error-in-attr-expected.txt: Added.
+ * fast/events/window-onerror-syntax-error-in-attr.html: Added.
+ * platform/chromium/fast/events/window-onerror-exception-in-attr-expected.txt: Added.
+ * platform/chromium/fast/events/window-onerror-syntax-error-in-attr-expected.txt: Added.
+
2011-10-31 John Gregg <[email protected]>
Unreviewed, more expectations changes for svg.
Added: trunk/LayoutTests/fast/events/window-onerror-exception-in-attr-expected.txt (0 => 98885)
--- trunk/LayoutTests/fast/events/window-onerror-exception-in-attr-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/events/window-onerror-exception-in-attr-expected.txt 2011-10-31 22:03:22 UTC (rev 98885)
@@ -0,0 +1,6 @@
+Test that window.onerror is called on window object when there is an exception(excluding syntax errors) in attribute handler. Bug 70991.
+
+Main frame window.onerror: TypeError: 'null' is not an object (evaluating 'null.m') at window-onerror-exception-in-attr.html:10
+Main frame window.onerror: TypeError: 'null' is not an object (evaluating 'null.m') at window-onerror-exception-in-attr.html:36
+Main frame window.onerror: TypeError: 'null' is not an object (evaluating 'null.m') at window-onerror-exception-in-attr.html:36
+Button 1 Button 2 Button 3
Added: trunk/LayoutTests/fast/events/window-onerror-exception-in-attr.html (0 => 98885)
--- trunk/LayoutTests/fast/events/window-onerror-exception-in-attr.html (rev 0)
+++ trunk/LayoutTests/fast/events/window-onerror-exception-in-attr.html 2011-10-31 22:03:22 UTC (rev 98885)
@@ -0,0 +1,38 @@
+<html>
+<head>
+<script src=""
+</script>
+</head>
+<body>
+<p>Test that window.onerror is called on window object when there is an exception(excluding syntax errors)
+in attribute handler. <a href="" 70991</a>.</p>
+<div id="console"></div>
+<button id="btn1" _onclick_="null.m()">Button 1</button>
+<script>
+if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+function log(msg) {
+ document.getElementById("console").innerHTML += msg + "<br>";
+}
+
+window._onerror_ = function(msg, url, line)
+{
+ url = "" ? url.match( /[^\/]+\/?$/ )[0] : url;
+ log("Main frame window.onerror: " + msg + " at " + url + ":" + line);
+ return true;
+}
+
+document.write('<button id="btn2" _onclick_="null.m()">Button 2</button>\n');
+
+var button3 = document.createElement("button");
+button3.textContent = "Button 3";
+button3.setAttribute("onclick", "null.m()");
+document.body.appendChild(button3);
+
+document.getElementById("btn1").click();
+document.getElementById("btn2").click();
+button3.click();
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/fast/events/window-onerror-syntax-error-in-attr-expected.txt (0 => 98885)
--- trunk/LayoutTests/fast/events/window-onerror-syntax-error-in-attr-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/events/window-onerror-syntax-error-in-attr-expected.txt 2011-10-31 22:03:22 UTC (rev 98885)
@@ -0,0 +1,6 @@
+Test that window.onerror is called on window object when there is a syntax error in attribute handler. Bug 70991.
+
+Main frame window.onerror: SyntaxError: Unexpected token '%' at window-onerror-syntax-error-in-attr.html:10
+Main frame window.onerror: SyntaxError: Unexpected token '%' at window-onerror-syntax-error-in-attr.html:36
+Main frame window.onerror: SyntaxError: Unexpected token '%' at window-onerror-syntax-error-in-attr.html:36
+Button 1 Button 2 Button 3
Added: trunk/LayoutTests/fast/events/window-onerror-syntax-error-in-attr.html (0 => 98885)
--- trunk/LayoutTests/fast/events/window-onerror-syntax-error-in-attr.html (rev 0)
+++ trunk/LayoutTests/fast/events/window-onerror-syntax-error-in-attr.html 2011-10-31 22:03:22 UTC (rev 98885)
@@ -0,0 +1,38 @@
+<html>
+<head>
+<script src=""
+</script>
+</head>
+<body>
+<p>Test that window.onerror is called on window object when there is a syntax error
+in attribute handler. <a href="" 70991</a>.</p>
+<div id="console"></div>
+<button id="btn1" _onclick_="%">Button 1</button>
+<script>
+if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+function log(msg) {
+ document.getElementById("console").innerHTML += msg + "<br>";
+}
+
+window._onerror_ = function(msg, url, line)
+{
+ url = "" ? url.match( /[^\/]+\/?$/ )[0] : url;
+ log("Main frame window.onerror: " + msg + " at " + url + ":" + line);
+ return true;
+}
+
+document.write('<button id="btn2" _onclick_="%">Button 2</button>\n');
+
+var button3 = document.createElement("button");
+button3.textContent = "Button 3";
+button3.setAttribute("onclick", "%");
+document.body.appendChild(button3);
+
+document.getElementById("btn1").click();
+document.getElementById("btn2").click();
+button3.click();
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/platform/chromium/fast/events/window-onerror-exception-in-attr-expected.txt (0 => 98885)
--- trunk/LayoutTests/platform/chromium/fast/events/window-onerror-exception-in-attr-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/chromium/fast/events/window-onerror-exception-in-attr-expected.txt 2011-10-31 22:03:22 UTC (rev 98885)
@@ -0,0 +1,6 @@
+Test that window.onerror is called on window object when there is an exception(excluding syntax errors) in attribute handler. Bug 70991.
+
+Main frame window.onerror: Uncaught TypeError: Cannot call method 'm' of null at window-onerror-exception-in-attr.html:10
+Main frame window.onerror: Uncaught TypeError: Cannot call method 'm' of null at window-onerror-exception-in-attr.html:36
+Main frame window.onerror: Uncaught TypeError: Cannot call method 'm' of null at window-onerror-exception-in-attr.html:36
+Button 1 Button 2 Button 3
Added: trunk/LayoutTests/platform/chromium/fast/events/window-onerror-syntax-error-in-attr-expected.txt (0 => 98885)
--- trunk/LayoutTests/platform/chromium/fast/events/window-onerror-syntax-error-in-attr-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/chromium/fast/events/window-onerror-syntax-error-in-attr-expected.txt 2011-10-31 22:03:22 UTC (rev 98885)
@@ -0,0 +1,6 @@
+Test that window.onerror is called on window object when there is a syntax error in attribute handler. Bug 70991.
+
+Main frame window.onerror: Uncaught SyntaxError: Unexpected token % at window-onerror-syntax-error-in-attr.html:10
+Main frame window.onerror: Uncaught SyntaxError: Unexpected token % at window-onerror-syntax-error-in-attr.html:36
+Main frame window.onerror: Uncaught SyntaxError: Unexpected token % at window-onerror-syntax-error-in-attr.html:36
+Button 1 Button 2 Button 3
Modified: trunk/Source/WebCore/ChangeLog (98884 => 98885)
--- trunk/Source/WebCore/ChangeLog 2011-10-31 21:34:59 UTC (rev 98884)
+++ trunk/Source/WebCore/ChangeLog 2011-10-31 22:03:22 UTC (rev 98885)
@@ -1,3 +1,20 @@
+2011-10-31 Yury Semikhatsky <[email protected]>
+
+ window.onerror doesn't work with inline (attribute) scripts
+ https://bugs.webkit.org/show_bug.cgi?id=70991
+
+ Uncaught syntax errors in inline event handlers are now reported to
+ window.onerror handler.
+
+ Reviewed by Geoffrey Garen.
+
+ Tests: fast/events/window-onerror-exception-in-attr.html
+ fast/events/window-onerror-syntax-error-in-attr.html
+
+ * bindings/js/JSLazyEventListener.cpp:
+ (WebCore::JSLazyEventListener::initializeJSFunction): report exception as usual
+ if it happens during event handler compilation.
+
2011-10-31 Emil A Eklund <[email protected]>
Overridden LayoutRect method still uses IntRects
Modified: trunk/Source/WebCore/bindings/js/JSLazyEventListener.cpp (98884 => 98885)
--- trunk/Source/WebCore/bindings/js/JSLazyEventListener.cpp 2011-10-31 21:34:59 UTC (rev 98884)
+++ trunk/Source/WebCore/bindings/js/JSLazyEventListener.cpp 2011-10-31 22:03:22 UTC (rev 98885)
@@ -98,6 +98,7 @@
JSObject* jsFunction = constructFunctionSkippingEvalEnabledCheck(exec, exec->lexicalGlobalObject(), args, Identifier(exec, stringToUString(m_functionName)), stringToUString(m_sourceURL), m_lineNumber); // FIXME: is globalExec ok?
if (exec->hadException()) {
+ reportCurrentException(exec);
exec->clearException();
return 0;
}