Diff
Modified: trunk/LayoutTests/ChangeLog (94642 => 94643)
--- trunk/LayoutTests/ChangeLog 2011-09-07 06:49:04 UTC (rev 94642)
+++ trunk/LayoutTests/ChangeLog 2011-09-07 06:53:14 UTC (rev 94643)
@@ -1,3 +1,22 @@
+2011-08-31 Yury Semikhatsky <[email protected]>
+
+ fast/workers/worker-script-error.html fails on Chromium after r94061
+ https://bugs.webkit.org/show_bug.cgi?id=67206
+
+ Add a couple more tests for window.onerror handler that check whether
+ error message is printed to the console pending on the handler return
+ value.
+
+ Reviewed by Dmitry Titov.
+
+ * fast/events/window-onerror14-expected.txt: Added.
+ * fast/events/window-onerror14.html: Added.
+ * fast/events/window-onerror15-expected.txt: Added.
+ * fast/events/window-onerror15.html: Added.
+ * fast/events/window-onerror16-expected.txt: Added.
+ * fast/events/window-onerror16.html: Added.
+ * platform/chromium/fast/events/window-onerror16-expected.txt: Added.
+
2011-09-05 Kent Tamura <[email protected]>
REGRESSION (Safari 5.1 - ToT): File input retains its file icon when the value is reset
Added: trunk/LayoutTests/fast/events/window-onerror14-expected.txt (0 => 94643)
--- trunk/LayoutTests/fast/events/window-onerror14-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/events/window-onerror14-expected.txt 2011-09-07 06:53:14 UTC (rev 94643)
@@ -0,0 +1,5 @@
+Test that error is treated as handled when window.onerror return value is 'true'. Bug 67119.
+
+Uncaught error should *not* be printed in console when window.onerror returns true.
+window.onerror invoked.
+
Property changes on: trunk/LayoutTests/fast/events/window-onerror14-expected.txt
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/fast/events/window-onerror14.html (0 => 94643)
--- trunk/LayoutTests/fast/events/window-onerror14.html (rev 0)
+++ trunk/LayoutTests/fast/events/window-onerror14.html 2011-09-07 06:53:14 UTC (rev 94643)
@@ -0,0 +1,28 @@
+<html>
+<head>
+<script src=""
+</script>
+</head>
+<body>
+<p>Test that error is treated as handled when window.onerror return
+value is 'true'. <a href="" 67119</a>.</p>
+<div id="console"></div>
+<script>
+if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+function log(msg) {
+ document.getElementById("console").innerHTML += msg + "<br>";
+}
+
+window._onerror_ = function(msg, url, line)
+{
+ log("Uncaught error should *not* be printed in console when window.onerror returns true.");
+ log("window.onerror invoked.");
+ return true;
+}
+
+throw "An Error";
+</script>
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/events/window-onerror14.html
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/fast/events/window-onerror15-expected.txt (0 => 94643)
--- trunk/LayoutTests/fast/events/window-onerror15-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/events/window-onerror15-expected.txt 2011-09-07 06:53:14 UTC (rev 94643)
@@ -0,0 +1,5 @@
+Test that error is treated as handled when preventDefault is called on the error event.Bug 67119.
+
+Error event listener invoked. Error should *not* be printed in console.
+DONE.
+
Property changes on: trunk/LayoutTests/fast/events/window-onerror15-expected.txt
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/fast/events/window-onerror15.html (0 => 94643)
--- trunk/LayoutTests/fast/events/window-onerror15.html (rev 0)
+++ trunk/LayoutTests/fast/events/window-onerror15.html 2011-09-07 06:53:14 UTC (rev 94643)
@@ -0,0 +1,27 @@
+<html>
+<head>
+<script src=""
+</script>
+</head>
+<body>
+<p>Test that error is treated as handled when preventDefault is called on the
+error event.<a href="" 67119</a>.</p>
+<div id="console"></div>
+<script>
+if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+function log(msg) {
+ document.getElementById("console").innerHTML += msg + "<br>";
+}
+
+window.addEventListener("error", function(e) {
+ log("Error event listener invoked. Error should *not* be printed in console.");
+ log("DONE.");
+ e.preventDefault();
+}, true);
+
+throw "An Error";
+</script>
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/events/window-onerror15.html
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/fast/events/window-onerror16-expected.txt (0 => 94643)
--- trunk/LayoutTests/fast/events/window-onerror16-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/events/window-onerror16-expected.txt 2011-09-07 06:53:14 UTC (rev 94643)
@@ -0,0 +1,6 @@
+CONSOLE MESSAGE: line 0: An Error
+Test that error is treated as not handled when window.onerror return value is 'false'. Bug 67119.
+
+window.onerror invoked. Uncaught error should be printed in console
+DONE.
+
Property changes on: trunk/LayoutTests/fast/events/window-onerror16-expected.txt
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/fast/events/window-onerror16.html (0 => 94643)
--- trunk/LayoutTests/fast/events/window-onerror16.html (rev 0)
+++ trunk/LayoutTests/fast/events/window-onerror16.html 2011-09-07 06:53:14 UTC (rev 94643)
@@ -0,0 +1,28 @@
+<html>
+<head>
+<script src=""
+</script>
+</head>
+<body>
+<p>Test that error is treated as not handled when window.onerror return
+value is 'false'. <a href="" 67119</a>.</p>
+<div id="console"></div>
+<script>
+if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+function log(msg) {
+ document.getElementById("console").innerHTML += msg + "<br>";
+}
+
+window._onerror_ = function(msg, url, line)
+{
+ log("window.onerror invoked. Uncaught error should be printed in console");
+ log("DONE.");
+ return false;
+}
+
+throw "An Error";
+</script>
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/events/window-onerror16.html
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/platform/chromium/fast/events/window-onerror16-expected.txt (0 => 94643)
--- trunk/LayoutTests/platform/chromium/fast/events/window-onerror16-expected.txt (rev 0)
+++ trunk/LayoutTests/platform/chromium/fast/events/window-onerror16-expected.txt 2011-09-07 06:53:14 UTC (rev 94643)
@@ -0,0 +1,6 @@
+CONSOLE MESSAGE: line 25: Uncaught An Error
+Test that error is treated as not handled when window.onerror return value is 'false'. Bug 67119.
+
+window.onerror invoked. Uncaught error should be printed in console
+DONE.
+
Property changes on: trunk/LayoutTests/platform/chromium/fast/events/window-onerror16-expected.txt
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/Source/WebCore/ChangeLog (94642 => 94643)
--- trunk/Source/WebCore/ChangeLog 2011-09-07 06:49:04 UTC (rev 94642)
+++ trunk/Source/WebCore/ChangeLog 2011-09-07 06:53:14 UTC (rev 94643)
@@ -1,3 +1,32 @@
+2011-08-31 Yury Semikhatsky <[email protected]>
+
+ fast/workers/worker-script-error.html fails on Chromium after r94061
+ https://bugs.webkit.org/show_bug.cgi?id=67206
+
+ Default action should be prevented if window.onerror returned true and stay
+ not prevented otherwise.
+
+ Reviewed by Dmitry Titov.
+
+ Tests: fast/events/window-onerror14.html
+ fast/events/window-onerror15.html
+ fast/events/window-onerror16.html
+
+ * bindings/v8/V8AbstractEventListener.cpp:
+ (WebCore::V8AbstractEventListener::invokeEventHandler):
+ (WebCore::V8AbstractEventListener::shouldPreventDefault): allow specific
+ event listeners to decide when to prevent default action based on the handler
+ return value.
+ * bindings/v8/V8AbstractEventListener.h:
+ * bindings/v8/V8WindowErrorHandler.cpp:
+ (WebCore::V8WindowErrorHandler::callListenerFunction):
+ (WebCore::V8WindowErrorHandler::shouldPreventDefault):
+ * bindings/v8/V8WindowErrorHandler.h:
+ * bindings/v8/V8WorkerContextErrorHandler.cpp:
+ (WebCore::V8WorkerContextErrorHandler::callListenerFunction):
+ (WebCore::V8WorkerContextErrorHandler::shouldPreventDefault):
+ * bindings/v8/V8WorkerContextErrorHandler.h:
+
2011-09-06 Xianzhu Wang <[email protected]>
Replace usages of Vector<UChar> with existing StringBuilder
Modified: trunk/Source/WebCore/bindings/v8/V8AbstractEventListener.cpp (94642 => 94643)
--- trunk/Source/WebCore/bindings/v8/V8AbstractEventListener.cpp 2011-09-07 06:49:04 UTC (rev 94642)
+++ trunk/Source/WebCore/bindings/v8/V8AbstractEventListener.cpp 2011-09-07 06:53:14 UTC (rev 94643)
@@ -181,12 +181,17 @@
if (!returnValue->IsNull() && !returnValue->IsUndefined() && event->storesResultAsString())
event->storeResult(toWebCoreString(returnValue));
- // Prevent default action if the return value is false;
- // FIXME: Add example, and reference to bug entry.
- if (m_isAttribute && returnValue->IsBoolean() && !returnValue->BooleanValue())
+ if (m_isAttribute && shouldPreventDefault(returnValue))
event->preventDefault();
}
+bool V8AbstractEventListener::shouldPreventDefault(v8::Local<v8::Value> returnValue)
+{
+ // Prevent default action if the return value is false in accord with the spec
+ // http://www.w3.org/TR/html5/webappapis.html#event-handler-attributes
+ return returnValue->IsBoolean() && !returnValue->BooleanValue();
+}
+
v8::Local<v8::Object> V8AbstractEventListener::getReceiverObject(Event* event)
{
if (!m_listener.IsEmpty() && !m_listener->IsFunction())
Modified: trunk/Source/WebCore/bindings/v8/V8AbstractEventListener.h (94642 => 94643)
--- trunk/Source/WebCore/bindings/v8/V8AbstractEventListener.h 2011-09-07 06:49:04 UTC (rev 94642)
+++ trunk/Source/WebCore/bindings/v8/V8AbstractEventListener.h 2011-09-07 06:53:14 UTC (rev 94643)
@@ -123,6 +123,8 @@
virtual v8::Local<v8::Value> callListenerFunction(ScriptExecutionContext*, v8::Handle<v8::Value> jsevent, Event*) = 0;
+ virtual bool shouldPreventDefault(v8::Local<v8::Value> returnValue);
+
v8::Persistent<v8::Object> m_listener;
// Indicates if this is an HTML type listener.
Modified: trunk/Source/WebCore/bindings/v8/V8WindowErrorHandler.cpp (94642 => 94643)
--- trunk/Source/WebCore/bindings/v8/V8WindowErrorHandler.cpp 2011-09-07 06:49:04 UTC (rev 94642)
+++ trunk/Source/WebCore/bindings/v8/V8WindowErrorHandler.cpp 2011-09-07 06:53:14 UTC (rev 94643)
@@ -57,10 +57,13 @@
v8::TryCatch tryCatch;
tryCatch.SetVerbose(true);
returnValue = callFunction->Call(thisValue, 3, parameters);
- if (!tryCatch.HasCaught() && !returnValue.IsEmpty() && returnValue->IsBoolean() && returnValue->BooleanValue())
- event->preventDefault();
}
return returnValue;
}
+bool V8WindowErrorHandler::shouldPreventDefault(v8::Local<v8::Value> returnValue)
+{
+ return returnValue->IsBoolean() && returnValue->BooleanValue();
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/bindings/v8/V8WindowErrorHandler.h (94642 => 94643)
--- trunk/Source/WebCore/bindings/v8/V8WindowErrorHandler.h 2011-09-07 06:49:04 UTC (rev 94642)
+++ trunk/Source/WebCore/bindings/v8/V8WindowErrorHandler.h 2011-09-07 06:53:14 UTC (rev 94643)
@@ -48,6 +48,7 @@
V8WindowErrorHandler(v8::Local<v8::Object> listener, bool isInline, const WorldContextHandle& worldContext);
virtual v8::Local<v8::Value> callListenerFunction(ScriptExecutionContext*, v8::Handle<v8::Value> jsEvent, Event*);
+ virtual bool shouldPreventDefault(v8::Local<v8::Value> returnValue);
};
} // namespace WebCore
Modified: trunk/Source/WebCore/bindings/v8/V8WorkerContextErrorHandler.cpp (94642 => 94643)
--- trunk/Source/WebCore/bindings/v8/V8WorkerContextErrorHandler.cpp 2011-09-07 06:49:04 UTC (rev 94642)
+++ trunk/Source/WebCore/bindings/v8/V8WorkerContextErrorHandler.cpp 2011-09-07 06:53:14 UTC (rev 94643)
@@ -55,12 +55,15 @@
v8::Local<v8::Object> thisValue = v8::Context::GetCurrent()->Global();
v8::Handle<v8::Value> parameters[3] = { v8String(errorEvent->message()), v8String(errorEvent->filename()), v8::Integer::New(errorEvent->lineno()) };
returnValue = callFunction->Call(thisValue, 3, parameters);
- if (!returnValue.IsEmpty() && returnValue->IsBoolean() && returnValue->BooleanValue())
- event->preventDefault();
}
return returnValue;
}
+bool V8WorkerContextErrorHandler::shouldPreventDefault(v8::Local<v8::Value> returnValue)
+{
+ return returnValue->IsBoolean() && returnValue->BooleanValue();
+}
+
} // namespace WebCore
#endif // WORKERS
Modified: trunk/Source/WebCore/bindings/v8/V8WorkerContextErrorHandler.h (94642 => 94643)
--- trunk/Source/WebCore/bindings/v8/V8WorkerContextErrorHandler.h 2011-09-07 06:49:04 UTC (rev 94642)
+++ trunk/Source/WebCore/bindings/v8/V8WorkerContextErrorHandler.h 2011-09-07 06:53:14 UTC (rev 94643)
@@ -50,6 +50,7 @@
V8WorkerContextErrorHandler(v8::Local<v8::Object> listener, bool isInline, const WorldContextHandle& worldContext);
virtual v8::Local<v8::Value> callListenerFunction(ScriptExecutionContext*, v8::Handle<v8::Value> jsEvent, Event*);
+ virtual bool shouldPreventDefault(v8::Local<v8::Value> returnValue);
};
} // namespace WebCore