2010-12-27 yury semikhatsky <yurys@chromium.org>
authoryurys@chromium.org <yurys@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Jan 2011 09:28:54 +0000 (09:28 +0000)
committeryurys@chromium.org <yurys@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Jan 2011 09:28:54 +0000 (09:28 +0000)
        reviewed by pavel feldman.

        webcore doesn't fire window.onerror event when uncaught javascript exceptions are thrown
        https://bugs.webkit.org/show_bug.cgi?id=8519

        uncaught exceptions are propagated to window.onerror hander if one is present.
        the handler is expected to be a function accepting three arguments: error message,
        resource url and line number where the exception occured.

        it was decided to dispatch errorevent to all listeners/handlers no matter if they
        were created in the same isolated world where the exception occured or not.

        tests: fast/events/window-onerror1.html
               fast/events/window-onerror10.html
               fast/events/window-onerror11.html
               fast/events/window-onerror12.html
               fast/events/window-onerror2.html
               fast/events/window-onerror3.html
               fast/events/window-onerror4.html
               fast/events/window-onerror5.html
               fast/events/window-onerror6.html
               fast/events/window-onerror7.html
               fast/events/window-onerror8.html
               fast/events/window-onerror9.html
               http/tests/security/window-onerror-exception-in-iframe.html
               userscripts/window-onerror-for-isolated-world-1.html
               userscripts/window-onerror-for-isolated-world-2.html

        * android.jscbindings.mk:
        * cmakelists.txt:
        * gnumakefile.am:
        * webcore.gypi:
        * webcore.order:
        * webcore.pro:
        * webcore.vcproj/webcore.vcproj:
        * webcore.xcodeproj/project.pbxproj:
        * bindings/js/jsbindingsallinone.cpp:
        * bindings/js/jsdombinding.cpp:
        (webcore::reportexception):
        * bindings/js/jserrorhandler.cpp: renamed from webcore/bindings/js/jsworkercontexterrorhandler.cpp.
        (webcore::jserrorhandler::jserrorhandler):
        (webcore::jserrorhandler::~jserrorhandler):
        (webcore::jserrorhandler::handleevent):
        * bindings/js/jserrorhandler.h: copied from webcore/bindings/js/jsworkercontexterrorhandler.h.
        (webcore::jserrorhandler::create):
        (webcore::createjserrorhandler):
        * bindings/js/jseventlistener.h:
        * bindings/scripts/codegeneratorjs.pm:
        * bindings/scripts/codegeneratorv8.pm:
        * bindings/v8/v8consolemessage.cpp:
        (webcore::v8consolemessage::dispatchnow):
        (webcore::v8consolemessage::handler): the method was changed to use generic webcore exception
        reporting mechanism which is also used by jsc bindings.
        * bindings/v8/v8consolemessage.h:
        * bindings/v8/v8eventlistener.h:
        * bindings/v8/v8windowerrorhandler.cpp: renamed from webcore/bindings/js/jsworkercontexterrorhandler.h.
        (webcore::v8windowerrorhandler::v8windowerrorhandler):
        (webcore::v8windowerrorhandler::calllistenerfunction):
        * bindings/v8/v8windowerrorhandler.h: copied from webcore/dom/errorevent.cpp.
        (webcore::v8windowerrorhandler::create):
        * bindings/v8/workercontextexecutionproxy.cpp:
        (webcore::v8messagehandler):
        * bindings/v8/workerscriptcontroller.cpp:
        (webcore::workerscriptcontroller::evaluate):
        * dom/document.cpp:
        (webcore::document::erroreventtarget):
        (webcore::document::logexceptiontoconsole):
        (webcore::document::addmessage):
        * dom/document.h:
        * dom/errorevent.cpp:
        * dom/errorevent.h:
        * dom/event.cpp:
        (webcore::event::iserrorevent):
        * dom/event.h:
        * dom/scriptexecutioncontext.cpp:
        (webcore::scriptexecutioncontext::pendingexception::pendingexception):
        (webcore::scriptexecutioncontext::scriptexecutioncontext):
        (webcore::scriptexecutioncontext::reportexception): this method is not virtual anymore to
        ensure that error event dispatching algorithm is the same in workercontext and in document.
        (webcore::scriptexecutioncontext::dispatcherrorevent):
        * dom/scriptexecutioncontext.h:
        * websockets/websocket.cpp:
        (webcore::websocket::connect):
        * websockets/websocketchannel.cpp:
        (webcore::websocketchannel::didopen):
        (webcore::websocketchannel::didfail):
        (webcore::websocketchannel::appendtobuffer):
        * websockets/websockethandshake.cpp:
        (webcore::websockethandshake::readserverhandshake):
        (webcore::websockethandshake::readstatusline):
        (webcore::websockethandshake::readhttpheaders):
        (webcore::websockethandshake::checkresponseheaders):
        * workers/defaultsharedworkerrepository.cpp:
        (webcore::postexceptiontask):
        (webcore::postconsolemessagetask):
        * workers/workercontext.cpp:
        (webcore::workercontext::workercontext):
        (webcore::workercontext::erroreventtarget):
        (webcore::workercontext::logexceptiontoconsole):
        (webcore::workercontext::addmessage):
        * workers/workercontext.h:
        * workers/workermessagingproxy.cpp:
        (webcore::workerexceptiontask::performtask):
        (webcore::postconsolemessagetask):
        * xml/xmlhttprequest.cpp:
        (webcore::reportunsafeusage):

2010-12-27  Yury Semikhatsky  <yurys@chromium.org>

        Reviewed by Pavel Feldman.

        WebCore doesn't fire window.onerror event when uncaught JavaScript exceptions are thrown
        https://bugs.webkit.org/show_bug.cgi?id=8519

        Uncaught exceptions are propagated to window.onerror hander if one is present.
        The handler is expected to be a function accepting three arguments: error message,
        resource url and line number where the exception occured.

        * fast/events/resources/window-onerror.js: Added.
        (throwException):
        * fast/events/window-onerror1-expected.txt: Added.
        * fast/events/window-onerror1.html: Added.
        * fast/events/window-onerror10-expected.txt: Added.
        * fast/events/window-onerror10.html: Added.
        * fast/events/window-onerror11-expected.txt: Added.
        * fast/events/window-onerror11.html: Added.
        * fast/events/window-onerror12-expected.txt: Added.
        * fast/events/window-onerror12.html: Added.
        * fast/events/window-onerror2-expected.txt: Added.
        * fast/events/window-onerror2.html: Added.
        * fast/events/window-onerror3-expected.txt: Added.
        * fast/events/window-onerror3.html: Added.
        * fast/events/window-onerror4-expected.txt: Added.
        * fast/events/window-onerror4.html: Added.
        * fast/events/window-onerror5-expected.txt: Added.
        * fast/events/window-onerror5.html: Added.
        * fast/events/window-onerror6-expected.txt: Added.
        * fast/events/window-onerror6.html: Added.
        * fast/events/window-onerror7-expected.txt: Added.
        * fast/events/window-onerror7.html: Added.
        * fast/events/window-onerror8-expected.txt: Added.
        * fast/events/window-onerror8.html: Added.
        * fast/events/window-onerror9-expected.txt: Added.
        * fast/events/window-onerror9.html: Added.
        * fast/workers/worker-script-error-expected.txt:
        * http/tests/security/resources/onerror-iframe.html: Added.
        * http/tests/security/window-onerror-exception-in-iframe-expected.txt: Added.
        * http/tests/security/window-onerror-exception-in-iframe.html: Added.
        * platform/chromium-win/fast/workers/worker-script-error-expected.txt:
        * platform/chromium/fast/events/window-onerror1-expected.txt: Added.
        * platform/chromium/fast/events/window-onerror10-expected.txt: Added.
        * platform/chromium/fast/events/window-onerror11-expected.txt: Added.
        * platform/chromium/fast/events/window-onerror2-expected.txt: Added.
        * platform/chromium/fast/events/window-onerror3-expected.txt: Added.
        * platform/chromium/fast/events/window-onerror4-expected.txt: Added.
        * platform/chromium/fast/events/window-onerror5-expected.txt: Added.
        * platform/chromium/fast/events/window-onerror6-expected.txt: Added.
        * platform/chromium/fast/events/window-onerror7-expected.txt: Added.
        * platform/chromium/fast/events/window-onerror8-expected.txt: Added.
        * platform/chromium/fast/events/window-onerror9-expected.txt: Added.
        * platform/chromium/http/tests/security/window-onerror-exception-in-iframe-expected.txt: Added.
        * platform/chromium/userscripts/window-onerror-for-isolated-world-1-expected.txt: Added.
        * platform/chromium/userscripts/window-onerror-for-isolated-world-2-expected.txt: Added.
        * platform/gtk/Skipped:
        * userscripts/window-onerror-for-isolated-world-1-expected.txt: Added.
        * userscripts/window-onerror-for-isolated-world-1.html: Added.
        * userscripts/window-onerror-for-isolated-world-2-expected.txt: Added.
        * userscripts/window-onerror-for-isolated-world-2.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@76216 268f45cc-cd09-0410-ab3c-d52691b4dbfc

92 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/events/resources/window-onerror.js [new file with mode: 0644]
LayoutTests/fast/events/window-onerror1-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/window-onerror1.html [new file with mode: 0644]
LayoutTests/fast/events/window-onerror10-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/window-onerror10.html [new file with mode: 0644]
LayoutTests/fast/events/window-onerror11-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/window-onerror11.html [new file with mode: 0644]
LayoutTests/fast/events/window-onerror12-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/window-onerror12.html [new file with mode: 0644]
LayoutTests/fast/events/window-onerror2-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/window-onerror2.html [new file with mode: 0644]
LayoutTests/fast/events/window-onerror3-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/window-onerror3.html [new file with mode: 0644]
LayoutTests/fast/events/window-onerror4-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/window-onerror4.html [new file with mode: 0644]
LayoutTests/fast/events/window-onerror5-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/window-onerror5.html [new file with mode: 0644]
LayoutTests/fast/events/window-onerror6-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/window-onerror6.html [new file with mode: 0644]
LayoutTests/fast/events/window-onerror7-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/window-onerror7.html [new file with mode: 0644]
LayoutTests/fast/events/window-onerror8-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/window-onerror8.html [new file with mode: 0644]
LayoutTests/fast/events/window-onerror9-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/window-onerror9.html [new file with mode: 0644]
LayoutTests/fast/workers/worker-script-error-expected.txt
LayoutTests/http/tests/security/resources/onerror-iframe.html [new file with mode: 0644]
LayoutTests/http/tests/security/window-onerror-exception-in-iframe-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/security/window-onerror-exception-in-iframe.html [new file with mode: 0644]
LayoutTests/platform/chromium-win/fast/workers/worker-script-error-expected.txt
LayoutTests/platform/chromium/fast/events/window-onerror1-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium/fast/events/window-onerror10-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium/fast/events/window-onerror11-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium/fast/events/window-onerror2-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium/fast/events/window-onerror3-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium/fast/events/window-onerror4-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium/fast/events/window-onerror5-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium/fast/events/window-onerror6-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium/fast/events/window-onerror7-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium/fast/events/window-onerror8-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium/fast/events/window-onerror9-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium/http/tests/security/window-onerror-exception-in-iframe-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium/userscripts/window-onerror-for-isolated-world-1-expected.txt [new file with mode: 0644]
LayoutTests/platform/chromium/userscripts/window-onerror-for-isolated-world-2-expected.txt [new file with mode: 0644]
LayoutTests/platform/gtk/Skipped
LayoutTests/platform/gtk/fast/events/window-onerror2-expected.txt [new file with mode: 0755]
LayoutTests/userscripts/window-onerror-for-isolated-world-1-expected.txt [new file with mode: 0644]
LayoutTests/userscripts/window-onerror-for-isolated-world-1.html [new file with mode: 0644]
LayoutTests/userscripts/window-onerror-for-isolated-world-2-expected.txt [new file with mode: 0644]
LayoutTests/userscripts/window-onerror-for-isolated-world-2.html [new file with mode: 0644]
Source/WebCore/Android.jscbindings.mk
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.am
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.order
Source/WebCore/WebCore.pro
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSBindingsAllInOne.cpp
Source/WebCore/bindings/js/JSDOMBinding.cpp
Source/WebCore/bindings/js/JSErrorHandler.cpp [moved from Source/WebCore/bindings/js/JSWorkerContextErrorHandler.cpp with 86% similarity]
Source/WebCore/bindings/js/JSErrorHandler.h [moved from Source/WebCore/bindings/js/JSWorkerContextErrorHandler.h with 69% similarity]
Source/WebCore/bindings/js/JSEventListener.h
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/CodeGeneratorV8.pm
Source/WebCore/bindings/v8/V8ConsoleMessage.cpp
Source/WebCore/bindings/v8/V8ConsoleMessage.h
Source/WebCore/bindings/v8/V8EventListener.h
Source/WebCore/bindings/v8/V8WindowErrorHandler.cpp [new file with mode: 0644]
Source/WebCore/bindings/v8/V8WindowErrorHandler.h [new file with mode: 0644]
Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp
Source/WebCore/bindings/v8/WorkerScriptController.cpp
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/dom/ErrorEvent.cpp
Source/WebCore/dom/ErrorEvent.h
Source/WebCore/dom/Event.cpp
Source/WebCore/dom/Event.h
Source/WebCore/dom/ScriptExecutionContext.cpp
Source/WebCore/dom/ScriptExecutionContext.h
Source/WebCore/websockets/WebSocket.cpp
Source/WebCore/websockets/WebSocketChannel.cpp
Source/WebCore/websockets/WebSocketHandshake.cpp
Source/WebCore/workers/DefaultSharedWorkerRepository.cpp
Source/WebCore/workers/WorkerContext.cpp
Source/WebCore/workers/WorkerContext.h
Source/WebCore/workers/WorkerMessagingProxy.cpp
Source/WebCore/xml/XMLHttpRequest.cpp
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/WebWorkerClientImpl.cpp

index f8a469c38adc335458860e694df3784ff05301f7..263c9dafcf7c4985dfba2fc2f938c3545d4a3099 100644 (file)
@@ -1,3 +1,65 @@
+2010-12-27  Yury Semikhatsky  <yurys@chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        WebCore doesn't fire window.onerror event when uncaught JavaScript exceptions are thrown
+        https://bugs.webkit.org/show_bug.cgi?id=8519
+
+        Uncaught exceptions are propagated to window.onerror hander if one is present.
+        The handler is expected to be a function accepting three arguments: error message,
+        resource url and line number where the exception occured.
+
+        * fast/events/resources/window-onerror.js: Added.
+        (throwException):
+        * fast/events/window-onerror1-expected.txt: Added.
+        * fast/events/window-onerror1.html: Added.
+        * fast/events/window-onerror10-expected.txt: Added.
+        * fast/events/window-onerror10.html: Added.
+        * fast/events/window-onerror11-expected.txt: Added.
+        * fast/events/window-onerror11.html: Added.
+        * fast/events/window-onerror12-expected.txt: Added.
+        * fast/events/window-onerror12.html: Added.
+        * fast/events/window-onerror2-expected.txt: Added.
+        * fast/events/window-onerror2.html: Added.
+        * fast/events/window-onerror3-expected.txt: Added.
+        * fast/events/window-onerror3.html: Added.
+        * fast/events/window-onerror4-expected.txt: Added.
+        * fast/events/window-onerror4.html: Added.
+        * fast/events/window-onerror5-expected.txt: Added.
+        * fast/events/window-onerror5.html: Added.
+        * fast/events/window-onerror6-expected.txt: Added.
+        * fast/events/window-onerror6.html: Added.
+        * fast/events/window-onerror7-expected.txt: Added.
+        * fast/events/window-onerror7.html: Added.
+        * fast/events/window-onerror8-expected.txt: Added.
+        * fast/events/window-onerror8.html: Added.
+        * fast/events/window-onerror9-expected.txt: Added.
+        * fast/events/window-onerror9.html: Added.
+        * fast/workers/worker-script-error-expected.txt:
+        * http/tests/security/resources/onerror-iframe.html: Added.
+        * http/tests/security/window-onerror-exception-in-iframe-expected.txt: Added.
+        * http/tests/security/window-onerror-exception-in-iframe.html: Added.
+        * platform/chromium-win/fast/workers/worker-script-error-expected.txt:
+        * platform/chromium/fast/events/window-onerror1-expected.txt: Added.
+        * platform/chromium/fast/events/window-onerror10-expected.txt: Added.
+        * platform/chromium/fast/events/window-onerror11-expected.txt: Added.
+        * platform/chromium/fast/events/window-onerror2-expected.txt: Added.
+        * platform/chromium/fast/events/window-onerror3-expected.txt: Added.
+        * platform/chromium/fast/events/window-onerror4-expected.txt: Added.
+        * platform/chromium/fast/events/window-onerror5-expected.txt: Added.
+        * platform/chromium/fast/events/window-onerror6-expected.txt: Added.
+        * platform/chromium/fast/events/window-onerror7-expected.txt: Added.
+        * platform/chromium/fast/events/window-onerror8-expected.txt: Added.
+        * platform/chromium/fast/events/window-onerror9-expected.txt: Added.
+        * platform/chromium/http/tests/security/window-onerror-exception-in-iframe-expected.txt: Added.
+        * platform/chromium/userscripts/window-onerror-for-isolated-world-1-expected.txt: Added.
+        * platform/chromium/userscripts/window-onerror-for-isolated-world-2-expected.txt: Added.
+        * platform/gtk/Skipped:
+        * userscripts/window-onerror-for-isolated-world-1-expected.txt: Added.
+        * userscripts/window-onerror-for-isolated-world-1.html: Added.
+        * userscripts/window-onerror-for-isolated-world-2-expected.txt: Added.
+        * userscripts/window-onerror-for-isolated-world-2.html: Added.
+
 2011-01-19  MORITA Hajime  <morrita@google.com>
 
         Reviewed by Ryosuke Niwa.
diff --git a/LayoutTests/fast/events/resources/window-onerror.js b/LayoutTests/fast/events/resources/window-onerror.js
new file mode 100644 (file)
index 0000000..344574b
--- /dev/null
@@ -0,0 +1,3 @@
+function throwException() {
+    throw new Error("An exception");
+}
diff --git a/LayoutTests/fast/events/window-onerror1-expected.txt b/LayoutTests/fast/events/window-onerror1-expected.txt
new file mode 100644 (file)
index 0000000..fe51b72
--- /dev/null
@@ -0,0 +1,3 @@
+This page tests setting onerror handlers through the DOM. If it passes, you will see "PASS" messages below.Bug 8519.
+
+PASS: caught global error: ReferenceError: Can't find variable: hahaha_good_luck_finding_me at window-onerror1.html:25
diff --git a/LayoutTests/fast/events/window-onerror1.html b/LayoutTests/fast/events/window-onerror1.html
new file mode 100644 (file)
index 0000000..59d2495
--- /dev/null
@@ -0,0 +1,35 @@
+<html>
+<head>
+<script>
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+
+function print(message, color)
+{
+    var paragraph = document.createElement("div");
+    paragraph.appendChild(document.createTextNode(message));
+    paragraph.style.fontFamily = "monospace";
+    if (color)
+        paragraph.style.color = color;
+    document.getElementById("console").appendChild(paragraph);
+}
+
+function test()
+{
+    // must be last because the exception ends JavaScript execution
+    window.onerror = function (error, url, line) {
+        url = url ? url.match( /[^\/]+\/?$/ )[0] : url;
+        print("PASS: caught global error: " + error + " at " + url + ":" + line, "green");
+        return false;
+    };
+    hahaha_good_luck_finding_me(); // caught by window.onerror
+}
+</script>
+</head>
+<body onload="test();">
+<p>This page tests setting onerror handlers through the DOM. If it passes, you will
+   see "PASS" messages below.<a href="https://bugs.webkit.org/show_bug.cgi?id=8519">Bug 8519</a>.</p>
+<hr>
+<div id='console'></div>
+</body>
+</html>
diff --git a/LayoutTests/fast/events/window-onerror10-expected.txt b/LayoutTests/fast/events/window-onerror10-expected.txt
new file mode 100644 (file)
index 0000000..bff5636
--- /dev/null
@@ -0,0 +1,11 @@
+Test that "error" event listener added with window.addEventListener is invoked for uncaucht exceptions. Bug 8519.
+
+event passed to the listener is the same as window.event: true
+Event details:
+type: error
+phase: 2
+currentTarget is the global object: true
+message: Error: My fault.
+filename: window-onerror10.html
+lineno: 29
+
diff --git a/LayoutTests/fast/events/window-onerror10.html b/LayoutTests/fast/events/window-onerror10.html
new file mode 100644 (file)
index 0000000..26ed018
--- /dev/null
@@ -0,0 +1,33 @@
+<html>
+<body>
+<p>Test that "error" event listener added with window.addEventListener is invoked for uncaucht exceptions. <a href="https://bugs.webkit.org/show_bug.cgi?id=8519">Bug 8519</a>.</p>
+<div id="console"></div>
+<script>
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+
+function log(msg) {
+    document.getElementById("console").innerHTML += msg + "<br>";
+}
+
+function lastPathComponent(url) {
+    return url ? url.match( /[^\/]+\/?$/ )[0] : url;
+}
+
+window.addEventListener("error", function(e) {
+    log("event passed to the listener is the same as window.event: " + (window.event === e));
+    log("Event details:");
+    log("type: " + e.type);
+    log("phase: " + e.eventPhase)
+    log("currentTarget is the global object: " + (e.currentTarget === window));
+    log("message: " + e.message);
+    log("filename: " + lastPathComponent(e.filename));
+    log("lineno: " + e.lineno);
+    e.preventDefault();
+}, false);
+
+throw new Error("My fault.");
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/fast/events/window-onerror11-expected.txt b/LayoutTests/fast/events/window-onerror11-expected.txt
new file mode 100644 (file)
index 0000000..96e20cc
--- /dev/null
@@ -0,0 +1,4 @@
+Test that window.onerror is called on window object. Bug 8519.
+
+Main frame window.onerror: Error: An exception at window-onerror.js:2
+
diff --git a/LayoutTests/fast/events/window-onerror11.html b/LayoutTests/fast/events/window-onerror11.html
new file mode 100644 (file)
index 0000000..7655fa7
--- /dev/null
@@ -0,0 +1,28 @@
+<html>
+<head>
+<script src="resources/window-onerror.js">
+</script>
+</head>
+<body>
+<p>Test that window.onerror is called on window object. <a href="https://bugs.webkit.org/show_bug.cgi?id=8519">Bug 8519</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)
+{
+    url = url ? url.match( /[^\/]+\/?$/ )[0] : url;
+    log("Main frame window.onerror: " + msg + " at " + url + ":" + line);
+    return false;
+}
+
+throwException();
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/fast/events/window-onerror12-expected.txt b/LayoutTests/fast/events/window-onerror12-expected.txt
new file mode 100644 (file)
index 0000000..e16fe97
--- /dev/null
@@ -0,0 +1,8 @@
+Test that window.onerror is called on window object for events created using document.createEvent("error"). Bug 8519.
+
+Main frame window.onerror: 
+msg: [object Event]
+url: undefined
+line: undefined
+DONE.
+
diff --git a/LayoutTests/fast/events/window-onerror12.html b/LayoutTests/fast/events/window-onerror12.html
new file mode 100644 (file)
index 0000000..dede975
--- /dev/null
@@ -0,0 +1,33 @@
+<html>
+<head>
+<script src="resources/window-onerror.js">
+</script>
+</head>
+<body>
+<p>Test that window.onerror is called on window object for events created using document.createEvent("error"). <a href="https://bugs.webkit.org/show_bug.cgi?id=8519">Bug 8519</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("Main frame window.onerror: ");
+    log("msg: " + msg);
+    log("url: " + url);
+    log("line: " + line);
+    return false;
+}
+
+var evt = document.createEvent("Event");
+evt.initEvent("error", true, true);
+window.dispatchEvent(evt);
+log("DONE.");
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/fast/events/window-onerror2-expected.txt b/LayoutTests/fast/events/window-onerror2-expected.txt
new file mode 100644 (file)
index 0000000..93a2d3f
--- /dev/null
@@ -0,0 +1,6 @@
+Test that uncaught exceptions will be reported to the window.onerror handler. Bug 8519.
+
+Main frame window.onerror: Error: Inline script exception at window-onerror2.html:35
+Main frame window.onerror: Exception in onload at undefined:0
+Main frame window.onerror: Error: Exception in setTimeout at window-onerror2.html:29
+
diff --git a/LayoutTests/fast/events/window-onerror2.html b/LayoutTests/fast/events/window-onerror2.html
new file mode 100644 (file)
index 0000000..db9fb75
--- /dev/null
@@ -0,0 +1,41 @@
+<html>
+<body onload="throw 'Exception in onload';">
+<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>
+<div id="result"></div>
+<script>
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntilDone();
+}
+
+function log(msg) {
+    document.getElementById("result").innerHTML += msg + "<br>";
+}
+
+var unhandledErrorCount = 0;
+window.onerror = function(msg, url, line)
+{
+    url = url ? url.match( /[^\/]+\/?$/ )[0] : url;
+    log("Main frame window.onerror: " + msg + " at " + url + ":" + line);
+    
+    if (++unhandledErrorCount === 3 && window.layoutTestController)
+        layoutTestController.notifyDone();
+
+    return false;
+}
+
+function delayedThrowException()
+{
+    throw new Error("Exception in setTimeout");
+}
+setTimeout(delayedThrowException, 0);
+
+function throwException()
+{
+    throw new Error("Inline script exception");
+}
+throwException();
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/fast/events/window-onerror3-expected.txt b/LayoutTests/fast/events/window-onerror3-expected.txt
new file mode 100644 (file)
index 0000000..7025dbb
--- /dev/null
@@ -0,0 +1,4 @@
+You should see a message if window.onerror is working properly for this test.Bug 8519.
+
+Error caught successfully: ReferenceError: Can't find variable: unknownObject File: window-onerror3.html Line: 16
+
diff --git a/LayoutTests/fast/events/window-onerror3.html b/LayoutTests/fast/events/window-onerror3.html
new file mode 100644 (file)
index 0000000..ee2893f
--- /dev/null
@@ -0,0 +1,23 @@
+<script>
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+
+function log(msg) {
+    document.getElementById("console").innerHTML += msg + "<br>";
+}
+
+function test1()
+{
+    window.onerror = function (error, url, line) {
+        url = url ? url.match( /[^\/]+\/?$/ )[0] : url;
+        log("Error caught successfully: " + error + "\nFile: " + url + "\nLine: " + line)
+        return false;
+    };
+    unknownObject.unknownProperty++;
+}
+</script>
+<body onload="test1();">
+<p>You should see a message if window.onerror is working properly for this test.<a href="https://bugs.webkit.org/show_bug.cgi?id=8519">Bug 8519</a>.</p>
+<hr>
+<div id='console'></div>
+</body>
diff --git a/LayoutTests/fast/events/window-onerror4-expected.txt b/LayoutTests/fast/events/window-onerror4-expected.txt
new file mode 100644 (file)
index 0000000..26af8a1
--- /dev/null
@@ -0,0 +1,4 @@
+You should see a log record if window.onerror is working properly for this test.Bug 8519.
+
+Error caught successfully: ReferenceError: Left side of assignment is not a reference. File: undefined Line: 1
+
diff --git a/LayoutTests/fast/events/window-onerror4.html b/LayoutTests/fast/events/window-onerror4.html
new file mode 100644 (file)
index 0000000..c51887d
--- /dev/null
@@ -0,0 +1,23 @@
+<script>
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+
+function log(msg) {
+    document.getElementById("console").innerHTML += msg + "<br>";
+}
+
+function test1()
+{
+    window.onerror = function (error, url, line) {
+        url = url ? url.match( /[^\/]+\/?$/ )[0] : url;
+        log("Error caught successfully: " + error + "\nFile: " + url + "\nLine: " + line)
+        return false;
+    };
+    eval("1=2");
+}
+</script>
+<body onload="test1();">
+<p>You should see a log record if window.onerror is working properly for this test.<a href="https://bugs.webkit.org/show_bug.cgi?id=8519">Bug 8519</a>.</p>
+<hr>
+<div id='console'></div>
+</body>
diff --git a/LayoutTests/fast/events/window-onerror5-expected.txt b/LayoutTests/fast/events/window-onerror5-expected.txt
new file mode 100644 (file)
index 0000000..3ec7f5e
--- /dev/null
@@ -0,0 +1,4 @@
+Test that window.onerror is invoked for syntax error in eval. You should see a log record if window.onerror is working properly for this test.Bug 8519.
+
+Error caught successfully: SyntaxError: Parse error File: undefined Line: 1
+
diff --git a/LayoutTests/fast/events/window-onerror5.html b/LayoutTests/fast/events/window-onerror5.html
new file mode 100644 (file)
index 0000000..932d438
--- /dev/null
@@ -0,0 +1,23 @@
+<script>
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+
+function log(msg) {
+    document.getElementById("console").innerHTML += msg + "<br>";
+}
+
+function test1()
+{
+    window.onerror = function (error, url, line) {
+        url = url ? url.match( /[^\/]+\/?$/ )[0] : url;
+        log("Error caught successfully: " + error + "\nFile: " + url + "\nLine: " + line)
+        return false;
+    };
+    eval("a(");
+}
+</script>
+<body onload="test1();">
+<p>Test that window.onerror is invoked for syntax error in eval. You should see a log record if window.onerror is working properly for this test.<a href="https://bugs.webkit.org/show_bug.cgi?id=8519">Bug 8519</a>.</p>
+<hr>
+<div id='console'></div>
+</body>
diff --git a/LayoutTests/fast/events/window-onerror6-expected.txt b/LayoutTests/fast/events/window-onerror6-expected.txt
new file mode 100644 (file)
index 0000000..e7c27bb
--- /dev/null
@@ -0,0 +1,4 @@
+Test that syntax error will be reported to the window.onerror handler. Bug 8519.
+
+Main frame window.onerror: SyntaxError: Parse error at window-onerror6.html:22
+
diff --git a/LayoutTests/fast/events/window-onerror6.html b/LayoutTests/fast/events/window-onerror6.html
new file mode 100644 (file)
index 0000000..1978436
--- /dev/null
@@ -0,0 +1,26 @@
+<html>
+<body>
+<p>Test that syntax error will be reported to the window.onerror handler. <a href="https://bugs.webkit.org/show_bug.cgi?id=8519">Bug 8519</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)
+{
+    url = url ? url.match( /[^\/]+\/?$/ )[0] : url;
+    log("Main frame window.onerror: " + msg + " at " + url + ":" + line);
+    return false;
+}
+</script>
+<script>
+
+a) // syntax error
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/fast/events/window-onerror7-expected.txt b/LayoutTests/fast/events/window-onerror7-expected.txt
new file mode 100644 (file)
index 0000000..5d22e7e
--- /dev/null
@@ -0,0 +1,6 @@
+CONSOLE MESSAGE: line 20: Error: Original error
+CONSOLE MESSAGE: line 17: Error: Nested error
+Test that exception in window.onerror won't lead to recursive window.onerror call. Bug 8519.
+
+Main frame window.onerror: Error: Original error at window-onerror7.html:20
+
diff --git a/LayoutTests/fast/events/window-onerror7.html b/LayoutTests/fast/events/window-onerror7.html
new file mode 100644 (file)
index 0000000..f665686
--- /dev/null
@@ -0,0 +1,24 @@
+<html>
+<body>
+<p>Test that exception in window.onerror won't lead to recursive window.onerror call. <a href="https://bugs.webkit.org/show_bug.cgi?id=8519">Bug 8519</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)
+{
+    url = url ? url.match( /[^\/]+\/?$/ )[0] : url;
+    log("Main frame window.onerror: " + msg + " at " + url + ":" + line);
+    throw new Error("Nested error");
+}
+
+throw new Error("Original error");
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/fast/events/window-onerror8-expected.txt b/LayoutTests/fast/events/window-onerror8-expected.txt
new file mode 100644 (file)
index 0000000..efc6308
--- /dev/null
@@ -0,0 +1,5 @@
+Test that window.onerror is called on window object. Bug 8519.
+
+Main frame window.onerror: 2010 at undefined:0
+PASSED: this === window
+
diff --git a/LayoutTests/fast/events/window-onerror8.html b/LayoutTests/fast/events/window-onerror8.html
new file mode 100644 (file)
index 0000000..bade538
--- /dev/null
@@ -0,0 +1,28 @@
+<html>
+<body>
+<p>Test that window.onerror is called on window object. <a href="https://bugs.webkit.org/show_bug.cgi?id=8519">Bug 8519</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)
+{
+    url = url ? url.match( /[^\/]+\/?$/ )[0] : url;
+    log("Main frame window.onerror: " + msg + " at " + url + ":" + line);
+    if (this === window) 
+        log("PASSED: this === window");
+    else
+        log("FAILED: this === window");
+    return false;
+}
+
+throw 2010;
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/fast/events/window-onerror9-expected.txt b/LayoutTests/fast/events/window-onerror9-expected.txt
new file mode 100644 (file)
index 0000000..94316d3
--- /dev/null
@@ -0,0 +1,8 @@
+Test that when window.onerror handler is called, window.event is the corresponding ErrorEvent object. Bug 8519.
+
+Main frame window.onerror: Error: 2010 at window-onerror9.html:31
+window.event.type = error
+window.event.message = Error: 2010
+window.event.filename = window-onerror9.html
+window.event.lineno = 31
+
diff --git a/LayoutTests/fast/events/window-onerror9.html b/LayoutTests/fast/events/window-onerror9.html
new file mode 100644 (file)
index 0000000..1086ace
--- /dev/null
@@ -0,0 +1,35 @@
+<html>
+<body>
+<p>Test that when window.onerror handler is called, window.event is the corresponding ErrorEvent object. <a href="https://bugs.webkit.org/show_bug.cgi?id=8519">Bug 8519</a>.</p>
+<div id="console"></div>
+<script>
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntilDone();
+}
+
+function log(msg) {
+    document.getElementById("console").innerHTML += msg + "<br>";
+}
+
+function lastPathComponent(url) {
+    return url ? url.match( /[^\/]+\/?$/ )[0] : url;
+}
+
+window.onerror = function(msg, url, line)
+{
+    log("Main frame window.onerror: " + msg + " at " + lastPathComponent(url) + ":" + line);
+    log("window.event.type = " + window.event.type);
+    log("window.event.message = " + window.event.message);
+    log("window.event.filename = " + lastPathComponent(window.event.filename));
+    log("window.event.lineno = " + window.event.lineno);
+    if (window.layoutTestController)
+        layoutTestController.notifyDone();
+    return false;
+}
+
+throw new Error(2010);
+
+</script>
+</body>
+</html>
index 10ab0493ab47a242ca6d73fcf04baf386e4f45f7..404164089e824a90e40de92c7e1249501b788719 100644 (file)
@@ -4,8 +4,8 @@ Test Worker script error handling functionality. Should print a series of PASS m
 PASS: onerror invoked for a script that has invalid syntax.
 PASS: onerror invoked for a script that has script error 'ReferenceError: Can't find variable: foo' at line 1.
 PASS: event listener invoked for a script that has script error 'ReferenceError: Can't find variable: foo' at line 1.
-PASS: onerror invoked for a script that has script error 'ReferenceError: Can't find variable: bar' at line 3.
 PASS: onerror invoked for a script that has script error 'ReferenceError: Can't find variable: foo' at line 7.
+PASS: onerror invoked for a script that has script error 'ReferenceError: Can't find variable: bar' at line 3.
 PASS: onerror invoked for a script that has script error 'ReferenceError: Can't find variable: foo' at line 7.
 PASS: onerror invoked for a script that has script error 'ReferenceError: Can't find variable: foo' at line 7.
 PASS: message received from WorkerGlobalScope.onerror: onerror invoked for a script that has script error 'ReferenceError: Can't find variable: foo' at line 7.
diff --git a/LayoutTests/http/tests/security/resources/onerror-iframe.html b/LayoutTests/http/tests/security/resources/onerror-iframe.html
new file mode 100644 (file)
index 0000000..312fd12
--- /dev/null
@@ -0,0 +1,11 @@
+<script>
+function handleLoad()
+{
+    window.parent.postMessage("IFrameLoaded", "*");
+}
+
+throw "IframeException";
+
+</script>
+<body onload="handleLoad()">
+</body>
diff --git a/LayoutTests/http/tests/security/window-onerror-exception-in-iframe-expected.txt b/LayoutTests/http/tests/security/window-onerror-exception-in-iframe-expected.txt
new file mode 100644 (file)
index 0000000..8b17d92
--- /dev/null
@@ -0,0 +1,6 @@
+CONSOLE MESSAGE: line 0: IframeException
+Test that exceptions in iframe are not reported to the main frame window.onerror handler. window.onerror should print exactly one line.
+
+Main frame window.onerror: MainFrameException at undefined:0
+DONE
+
diff --git a/LayoutTests/http/tests/security/window-onerror-exception-in-iframe.html b/LayoutTests/http/tests/security/window-onerror-exception-in-iframe.html
new file mode 100644 (file)
index 0000000..0904e39
--- /dev/null
@@ -0,0 +1,39 @@
+<html>
+<body>
+<p>Test that exceptions in iframe are not reported to the main frame window.onerror handler.
+window.onerror should print exactly one line.</p>
+<div id="result"></div>
+<script>
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntilDone();
+}
+
+function log(msg) {
+    document.getElementById("result").innerHTML += msg + "<br>";
+}
+
+window.onerror = function(msg, url, line)
+{
+    url = url ? url.match( /[^\/]+\/?$/ )[0] : url;
+    log("Main frame window.onerror: " + msg + " at " + url + ":" + line);
+    return false;
+}
+
+function receiveMessage(event) {
+    if (event.data === "IFrameLoaded") {
+        log("DONE");
+        if (window.layoutTestController)
+            layoutTestController.notifyDone();
+    } else
+        log("FAIL " + event.data);
+}
+
+window.addEventListener("message", receiveMessage, false);
+
+throw "MainFrameException";
+
+</script>
+<iframe src="http://localhost:8000/security/resources/onerror-iframe.html"/>
+</body>
+</html>
index fdf660bd50c667d430f165a7fa837401641a1ca1..ef0a391e4787b33bbbb0d9f706038493fe318129 100644 (file)
@@ -3,8 +3,8 @@ Test Worker script error handling functionality. Should print a series of PASS m
 PASS: onerror invoked for a script that has invalid syntax.
 PASS: onerror invoked for a script that has script error 'Uncaught ReferenceError: foo is not defined' at line 1.
 PASS: event listener invoked for a script that has script error 'Uncaught ReferenceError: foo is not defined' at line 1.
-PASS: onerror invoked for a script that has script error 'Uncaught ReferenceError: bar is not defined' at line 3.
 PASS: onerror invoked for a script that has script error 'Uncaught ReferenceError: foo is not defined' at line 7.
+PASS: onerror invoked for a script that has script error 'Uncaught ReferenceError: bar is not defined' at line 3.
 PASS: onerror invoked for a script that has script error 'Uncaught ReferenceError: foo is not defined' at line 7.
 PASS: onerror invoked for a script that has script error 'Uncaught ReferenceError: foo is not defined' at line 7.
 PASS: message received from WorkerGlobalScope.onerror: onerror invoked for a script that has script error 'Uncaught ReferenceError: foo is not defined' at line 7.
diff --git a/LayoutTests/platform/chromium/fast/events/window-onerror1-expected.txt b/LayoutTests/platform/chromium/fast/events/window-onerror1-expected.txt
new file mode 100644 (file)
index 0000000..65b624b
--- /dev/null
@@ -0,0 +1,3 @@
+This page tests setting onerror handlers through the DOM. If it passes, you will see "PASS" messages below.Bug 8519.\r
+\r
+PASS: caught global error: Uncaught ReferenceError: hahaha_good_luck_finding_me is not defined at window-onerror1.html:25\r
diff --git a/LayoutTests/platform/chromium/fast/events/window-onerror10-expected.txt b/LayoutTests/platform/chromium/fast/events/window-onerror10-expected.txt
new file mode 100644 (file)
index 0000000..b3d2d39
--- /dev/null
@@ -0,0 +1,11 @@
+Test that "error" event listener added with window.addEventListener is invoked for uncaucht exceptions. Bug 8519.\r
+\r
+event passed to the listener is the same as window.event: true\r
+Event details:\r
+type: error\r
+phase: 2\r
+currentTarget is the global object: true\r
+message: Uncaught Error: My fault.\r
+filename: window-onerror10.html\r
+lineno: 29\r
+\r
diff --git a/LayoutTests/platform/chromium/fast/events/window-onerror11-expected.txt b/LayoutTests/platform/chromium/fast/events/window-onerror11-expected.txt
new file mode 100644 (file)
index 0000000..92e3cf5
--- /dev/null
@@ -0,0 +1,4 @@
+Test that window.onerror is called on window object. Bug 8519.\r
+\r
+Main frame window.onerror: Uncaught Error: An exception at window-onerror.js:2\r
+\r
diff --git a/LayoutTests/platform/chromium/fast/events/window-onerror2-expected.txt b/LayoutTests/platform/chromium/fast/events/window-onerror2-expected.txt
new file mode 100644 (file)
index 0000000..f7b1621
--- /dev/null
@@ -0,0 +1,6 @@
+Test that uncaught exceptions will be reported to the window.onerror handler. Bug 8519.\r
+\r
+Main frame window.onerror: Uncaught Error: Inline script exception at window-onerror2.html:35\r
+Main frame window.onerror: Uncaught Exception in onload at window-onerror2.html:2\r
+Main frame window.onerror: Uncaught Error: Exception in setTimeout at window-onerror2.html:29\r
+\r
diff --git a/LayoutTests/platform/chromium/fast/events/window-onerror3-expected.txt b/LayoutTests/platform/chromium/fast/events/window-onerror3-expected.txt
new file mode 100644 (file)
index 0000000..a1b8bd5
--- /dev/null
@@ -0,0 +1,4 @@
+You should see a message if window.onerror is working properly for this test.Bug 8519.\r
+\r
+Error caught successfully: Uncaught ReferenceError: unknownObject is not defined File: window-onerror3.html Line: 16\r
+\r
diff --git a/LayoutTests/platform/chromium/fast/events/window-onerror4-expected.txt b/LayoutTests/platform/chromium/fast/events/window-onerror4-expected.txt
new file mode 100644 (file)
index 0000000..50f09e0
--- /dev/null
@@ -0,0 +1,4 @@
+You should see a log record if window.onerror is working properly for this test.Bug 8519.\r
+\r
+Error caught successfully: Uncaught ReferenceError: Invalid left-hand side in assignment File: window-onerror4.html Line: 1\r
+\r
diff --git a/LayoutTests/platform/chromium/fast/events/window-onerror5-expected.txt b/LayoutTests/platform/chromium/fast/events/window-onerror5-expected.txt
new file mode 100644 (file)
index 0000000..e45369e
--- /dev/null
@@ -0,0 +1,4 @@
+Test that window.onerror is invoked for syntax error in eval. You should see a log record if window.onerror is working properly for this test.Bug 8519.\r
+\r
+Error caught successfully: Uncaught SyntaxError: Unexpected end of input File: window-onerror5.html Line: 1\r
+\r
diff --git a/LayoutTests/platform/chromium/fast/events/window-onerror6-expected.txt b/LayoutTests/platform/chromium/fast/events/window-onerror6-expected.txt
new file mode 100644 (file)
index 0000000..18ed81a
--- /dev/null
@@ -0,0 +1,4 @@
+Test that syntax error will be reported to the window.onerror handler. Bug 8519.\r
+\r
+Main frame window.onerror: Uncaught SyntaxError: Unexpected token ) at window-onerror6.html:22\r
+\r
diff --git a/LayoutTests/platform/chromium/fast/events/window-onerror7-expected.txt b/LayoutTests/platform/chromium/fast/events/window-onerror7-expected.txt
new file mode 100644 (file)
index 0000000..23d0407
--- /dev/null
@@ -0,0 +1,6 @@
+CONSOLE MESSAGE: line 20: Uncaught Error: Original error\r
+CONSOLE MESSAGE: line 17: Uncaught Error: Nested error\r
+Test that exception in window.onerror won't lead to recursive window.onerror call. Bug 8519.\r
+\r
+Main frame window.onerror: Uncaught Error: Original error at window-onerror7.html:20\r
+\r
diff --git a/LayoutTests/platform/chromium/fast/events/window-onerror8-expected.txt b/LayoutTests/platform/chromium/fast/events/window-onerror8-expected.txt
new file mode 100644 (file)
index 0000000..13f2b32
--- /dev/null
@@ -0,0 +1,5 @@
+Test that window.onerror is called on window object. Bug 8519.\r
+\r
+Main frame window.onerror: Uncaught 2010 at window-onerror8.html:24\r
+PASSED: this === window\r
+\r
diff --git a/LayoutTests/platform/chromium/fast/events/window-onerror9-expected.txt b/LayoutTests/platform/chromium/fast/events/window-onerror9-expected.txt
new file mode 100644 (file)
index 0000000..1677e50
--- /dev/null
@@ -0,0 +1,8 @@
+Test that when window.onerror handler is called, window.event is the corresponding ErrorEvent object. Bug 8519.\r
+\r
+Main frame window.onerror: Uncaught Error: 2010 at window-onerror9.html:31\r
+window.event.type = error\r
+window.event.message = Uncaught Error: 2010\r
+window.event.filename = window-onerror9.html\r
+window.event.lineno = 31\r
+\r
diff --git a/LayoutTests/platform/chromium/http/tests/security/window-onerror-exception-in-iframe-expected.txt b/LayoutTests/platform/chromium/http/tests/security/window-onerror-exception-in-iframe-expected.txt
new file mode 100644 (file)
index 0000000..9e9c2ea
--- /dev/null
@@ -0,0 +1,6 @@
+CONSOLE MESSAGE: line 7: Uncaught IframeException\r
+Test that exceptions in iframe are not reported to the main frame window.onerror handler. window.onerror should print exactly one line.\r
+\r
+Main frame window.onerror: Uncaught MainFrameException at window-onerror-exception-in-iframe.html:34\r
+DONE\r
+\r
diff --git a/LayoutTests/platform/chromium/userscripts/window-onerror-for-isolated-world-1-expected.txt b/LayoutTests/platform/chromium/userscripts/window-onerror-for-isolated-world-1-expected.txt
new file mode 100644 (file)
index 0000000..2a3d068
--- /dev/null
@@ -0,0 +1,14 @@
+Test that window.onerror and "error" event listeners from main world are invoked for uncaught exceptions in user scripts running in isolate worlds as well as for exceptions in the main world.Bug 8519.\r
+\r
+Main world window.onerror: Uncaught Error: Error in main world inline script. at window-onerror-for-isolated-world-1.html:54\r
+Main world error event listener: Uncaught Error: Error in main world inline script. at window-onerror-for-isolated-world-1.html:54\r
+Main world window.onerror: Uncaught Error: Error in user script inline script. at :12\r
+Main world error event listener: Uncaught Error: Error in user script inline script. at :12\r
+Main world window.onerror: Uncaught Error: Error in main world load handler. at window-onerror-for-isolated-world-1.html:46\r
+Main world error event listener: Uncaught Error: Error in main world load handler. at window-onerror-for-isolated-world-1.html:46\r
+Main world window.onerror: Uncaught Error: Error in user script load handler. at :4\r
+Main world error event listener: Uncaught Error: Error in user script load handler. at :4\r
+Main world window.onerror: Uncaught Error: Error in main world setTimeout callback. at window-onerror-for-isolated-world-1.html:51\r
+Main world error event listener: Uncaught Error: Error in main world setTimeout callback. at window-onerror-for-isolated-world-1.html:51\r
+Main world window.onerror: Uncaught Error: Error in user script setTimeout callback. at :9\r
+Main world error event listener: Uncaught Error: Error in user script setTimeout callback. at :9\r
diff --git a/LayoutTests/platform/chromium/userscripts/window-onerror-for-isolated-world-2-expected.txt b/LayoutTests/platform/chromium/userscripts/window-onerror-for-isolated-world-2-expected.txt
new file mode 100644 (file)
index 0000000..93994db
--- /dev/null
@@ -0,0 +1,13 @@
+CONSOLE MESSAGE: line 30: Uncaught Error: Error in main world inline script.\r
+Test that window.onerror and "error" event listeners from isolated world are invoked for uncaught exceptions in user scripts running in isolate worlds as well as for exceptions in the main world.Bug 8519.\r
+\r
+user script window.onerror: Uncaught Error: Error in user script inline script. at :33\r
+user script error event listener: Uncaught Error: Error in user script inline script. at :33\r
+user script window.onerror: Uncaught Error: Error in main world load handler. at window-onerror-for-isolated-world-2.html:23\r
+user script error event listener: Uncaught Error: Error in main world load handler. at window-onerror-for-isolated-world-2.html:23\r
+user script window.onerror: Uncaught Error: Error in user script load handler. at :26\r
+user script error event listener: Uncaught Error: Error in user script load handler. at :26\r
+user script window.onerror: Uncaught Error: Error in main world setTimeout callback. at window-onerror-for-isolated-world-2.html:27\r
+user script error event listener: Uncaught Error: Error in main world setTimeout callback. at window-onerror-for-isolated-world-2.html:27\r
+user script window.onerror: Uncaught Error: Error in user script setTimeout callback. at :30\r
+user script error event listener: Uncaught Error: Error in user script setTimeout callback. at :30\r
index 68be9d656e68363bc5b0d1cc8e268c1807c2d6af..52535381f70f0b7e05480748569303080eb5549e 100644 (file)
@@ -4711,6 +4711,8 @@ userscripts/user-script-plugin-document.html
 userscripts/user-script-top-frame-only.html
 userscripts/user-script-video-document.html
 userscripts/user-style-top-frame-only.html
+userscripts/window-onerror-for-isolated-world-1.html
+userscripts/window-onerror-for-isolated-world-2.html
 
 # XHR sends sometimes yield null bytes sent instead of 0.
 http/tests/xmlhttprequest/workers/shared-worker-methods.html
diff --git a/LayoutTests/platform/gtk/fast/events/window-onerror2-expected.txt b/LayoutTests/platform/gtk/fast/events/window-onerror2-expected.txt
new file mode 100755 (executable)
index 0000000..fe78d16
--- /dev/null
@@ -0,0 +1,6 @@
+Test that uncaught exceptions will be reported to the window.onerror handler. Bug 8519.
+
+Main frame window.onerror: Error: Inline script exception at window-onerror2.html:35
+Main frame window.onerror: Error: Exception in setTimeout at window-onerror2.html:29
+Main frame window.onerror: Exception in onload at undefined:0
+
diff --git a/LayoutTests/userscripts/window-onerror-for-isolated-world-1-expected.txt b/LayoutTests/userscripts/window-onerror-for-isolated-world-1-expected.txt
new file mode 100644 (file)
index 0000000..6895c41
--- /dev/null
@@ -0,0 +1,14 @@
+Test that window.onerror and "error" event listeners from main world are invoked for uncaught exceptions in user scripts running in isolate worlds as well as for exceptions in the main world.Bug 8519.
+
+Main world window.onerror: Error: Error in main world inline script. at window-onerror-for-isolated-world-1.html:54
+Main world error event listener: Error: Error in main world inline script. at window-onerror-for-isolated-world-1.html:54
+Main world window.onerror: Error: Error in user script inline script. at undefined:11
+Main world error event listener: Error: Error in user script inline script. at undefined:11
+Main world window.onerror: Error: Error in main world load handler. at window-onerror-for-isolated-world-1.html:46
+Main world error event listener: Error: Error in main world load handler. at window-onerror-for-isolated-world-1.html:46
+Main world window.onerror: Error: Error in user script load handler. at undefined:3
+Main world error event listener: Error: Error in user script load handler. at undefined:3
+Main world window.onerror: Error: Error in main world setTimeout callback. at window-onerror-for-isolated-world-1.html:51
+Main world error event listener: Error: Error in main world setTimeout callback. at window-onerror-for-isolated-world-1.html:51
+Main world window.onerror: Error: Error in user script setTimeout callback. at undefined:8
+Main world error event listener: Error: Error in user script setTimeout callback. at undefined:8
diff --git a/LayoutTests/userscripts/window-onerror-for-isolated-world-1.html b/LayoutTests/userscripts/window-onerror-for-isolated-world-1.html
new file mode 100644 (file)
index 0000000..3c6bac2
--- /dev/null
@@ -0,0 +1,67 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+</head>
+<body>
+<p>Test that window.onerror and "error" event listeners from main world are
+invoked for uncaught exceptions in user scripts running in isolate worlds as
+well as for exceptions in the main world.<a href="https://bugs.webkit.org/show_bug.cgi?id=8519">Bug 8519.</a>
+</p>
+<div id="console"></div>
+<script>
+
+var expectedRecordCount = 12;
+var recordCount = 0;
+document.getElementById("console").addEventListener("DOMNodeInserted", function(e) {
+    recordCount++;
+    if (recordCount === expectedRecordCount && window.layoutTestController)
+        layoutTestController.notifyDone();
+}, false);
+
+function log(msg) {
+    var record = document.createElement("div");
+    record.innerHTML = msg;
+    document.getElementById("console").appendChild(record);
+}
+
+function lastUrlComponent(url) {
+    return url ? url.match( /[^\/]+\/?$/ )[0] : url;
+}
+
+window.onerror = function(msg, url, line)
+{
+    log("Main world window.onerror: " + msg + " at " + lastUrlComponent(url) + ":" + line);
+    return false;
+}
+
+window.addEventListener("error", function(e)
+{
+    var url = lastUrlComponent(e.filename);
+    log("Main world error event listener: " + e.message + " at " + url + ":" + e.lineno);
+}, false);
+
+var exceptions = function(isolatedWorld)
+{
+    window.addEventListener("load", function(e) {
+        throw new Error("Error in " + isolatedWorld + " load handler.");
+    }, false);
+
+
+    setTimeout(function() {
+        throw new Error("Error in " + isolatedWorld + " setTimeout callback.");
+    }, 0);
+
+    throw new Error("Error in "+ isolatedWorld + " inline script.");
+}
+
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntilDone();
+    layoutTestController.addUserScript("(" + exceptions + ")('user script')", false, true);
+}
+
+exceptions("main world");
+
+</script>
+</body>
+</html>
diff --git a/LayoutTests/userscripts/window-onerror-for-isolated-world-2-expected.txt b/LayoutTests/userscripts/window-onerror-for-isolated-world-2-expected.txt
new file mode 100644 (file)
index 0000000..b909a99
--- /dev/null
@@ -0,0 +1,13 @@
+CONSOLE MESSAGE: line 30: Error: Error in main world inline script.
+Test that window.onerror and "error" event listeners from isolated world are invoked for uncaught exceptions in user scripts running in isolate worlds as well as for exceptions in the main world.Bug 8519.
+
+user script window.onerror: Error: Error in user script inline script. at undefined:31
+user script error event listener: Error: Error in user script inline script. at undefined:31
+user script window.onerror: Error: Error in main world load handler. at window-onerror-for-isolated-world-2.html:23
+user script error event listener: Error: Error in main world load handler. at window-onerror-for-isolated-world-2.html:23
+user script window.onerror: Error: Error in user script load handler. at undefined:24
+user script error event listener: Error: Error in user script load handler. at undefined:24
+user script window.onerror: Error: Error in main world setTimeout callback. at window-onerror-for-isolated-world-2.html:27
+user script error event listener: Error: Error in main world setTimeout callback. at window-onerror-for-isolated-world-2.html:27
+user script window.onerror: Error: Error in user script setTimeout callback. at undefined:28
+user script error event listener: Error: Error in user script setTimeout callback. at undefined:28
diff --git a/LayoutTests/userscripts/window-onerror-for-isolated-world-2.html b/LayoutTests/userscripts/window-onerror-for-isolated-world-2.html
new file mode 100644 (file)
index 0000000..a6ec699
--- /dev/null
@@ -0,0 +1,67 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+</head>
+<body>
+<p>Test that window.onerror and "error" event listeners from isolated world are
+invoked for uncaught exceptions in user scripts running in isolate worlds as
+well as for exceptions in the main world.<a href="https://bugs.webkit.org/show_bug.cgi?id=8519">Bug 8519.</a>
+</p>
+<div id="console"></div>
+<script>
+
+var expectedRecordCount = 10;
+var recordCount = 0;
+document.getElementById("console").addEventListener("DOMNodeInserted", function(e) {
+    if (++recordCount === expectedRecordCount && window.layoutTestController)
+        layoutTestController.notifyDone();
+}, false);
+
+var throwExceptions = function(isolatedWorld)
+{
+    window.addEventListener("load", function(e) {
+        throw new Error("Error in " + isolatedWorld + " load handler.");
+    }, false);
+
+    setTimeout(function() {
+        throw new Error("Error in " + isolatedWorld + " setTimeout callback.");
+    }, 0);
+    
+    throw new Error("Error in "+ isolatedWorld + " inline script.");
+};
+
+var errorHandlers = function(isolatedWorld)
+{
+    function lastUrlComponent(url) {
+        return url ? url.match( /[^\/]+\/?$/ )[0] : url;
+    }
+
+    function log(msg) {
+        var record = document.createElement("div");
+        record.innerHTML = msg;
+        document.getElementById("console").appendChild(record);
+    }
+
+    window.onerror = function(msg, url, line) {
+        log(isolatedWorld + " window.onerror: " + msg + " at " + lastUrlComponent(url) + ":" + line, "*");
+        return false;
+    }
+
+    window.addEventListener("error", function(e) {
+        var url = lastUrlComponent(e.filename);
+        log(isolatedWorld + " error event listener: " + e.message + " at " + url + ":" + e.lineno, "*");
+        e.preventDefault();
+    }, false);
+};
+
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    layoutTestController.waitUntilDone();
+    layoutTestController.addUserScript("(" + errorHandlers + ")('user script'); (" + throwExceptions + ")('user script')", false, true);
+}
+
+throwExceptions("main world");
+
+</script>
+</body>
+</html>
index a7713e3bf86eeea9224a560c27328a595e4e84a3..d40b2aedeb1fe6703bb01d9ab0ad298b184025e2 100644 (file)
@@ -102,6 +102,7 @@ LOCAL_SRC_FILES += \
        bindings/js/JSDeviceOrientationEventCustom.cpp \
        bindings/js/JSDocumentCustom.cpp \
        bindings/js/JSElementCustom.cpp \
+       bindings/js/JSErrorHandler.cpp \
        bindings/js/JSEventCustom.cpp \
        bindings/js/JSEventListener.cpp \
        bindings/js/JSEventTarget.cpp \
@@ -170,7 +171,6 @@ LOCAL_SRC_FILES += \
        bindings/js/JSWebKitPointCustom.cpp \
        bindings/js/JSWorkerContextBase.cpp \
        bindings/js/JSWorkerContextCustom.cpp \
-       bindings/js/JSWorkerContextErrorHandler.cpp \
        bindings/js/JSWorkerCustom.cpp \
        bindings/js/JSXMLHttpRequestCustom.cpp \
        bindings/js/JSXMLHttpRequestUploadCustom.cpp \
index 138c847e0a9e6f56c9920240530b685d01102998..65d45766d602f9f98f1fe731125b571dd437d4f2 100644 (file)
@@ -638,6 +638,7 @@ SET(WebCore_SOURCES
     bindings/js/JSDeviceOrientationEventCustom.cpp
     bindings/js/JSDocumentCustom.cpp
     bindings/js/JSElementCustom.cpp
+    bindings/js/JSErrorHandler.cpp
     bindings/js/JSEventCustom.cpp
     bindings/js/JSEventListener.cpp
     bindings/js/JSEventSourceCustom.cpp
@@ -706,7 +707,6 @@ SET(WebCore_SOURCES
     bindings/js/JSWebSocketCustom.cpp
     bindings/js/JSWorkerContextBase.cpp
     bindings/js/JSWorkerContextCustom.cpp
-    bindings/js/JSWorkerContextErrorHandler.cpp
     bindings/js/JSWorkerCustom.cpp
     bindings/js/JSXMLHttpRequestCustom.cpp
     bindings/js/JSXMLHttpRequestUploadCustom.cpp
index a182bb2ede6f13e35542aac7afffdb4d0fa087bc..3a06a2ecd337cf7e05872a0061f1e67d85328bc7 100644 (file)
@@ -1,3 +1,112 @@
+2010-12-27  Yury Semikhatsky  <yurys@chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        WebCore doesn't fire window.onerror event when uncaught JavaScript exceptions are thrown
+        https://bugs.webkit.org/show_bug.cgi?id=8519
+
+        Uncaught exceptions are propagated to window.onerror hander if one is present.
+        The handler is expected to be a function accepting three arguments: error message,
+        resource url and line number where the exception occured.
+
+        It was decided to dispatch ErrorEvent to all listeners/handlers no matter if they
+        were created in the same isolated world where the exception occured or not.
+
+        Tests: fast/events/window-onerror1.html
+               fast/events/window-onerror10.html
+               fast/events/window-onerror11.html
+               fast/events/window-onerror12.html
+               fast/events/window-onerror2.html
+               fast/events/window-onerror3.html
+               fast/events/window-onerror4.html
+               fast/events/window-onerror5.html
+               fast/events/window-onerror6.html
+               fast/events/window-onerror7.html
+               fast/events/window-onerror8.html
+               fast/events/window-onerror9.html
+               http/tests/security/window-onerror-exception-in-iframe.html
+               userscripts/window-onerror-for-isolated-world-1.html
+               userscripts/window-onerror-for-isolated-world-2.html
+
+        * Android.jscbindings.mk:
+        * CMakeLists.txt:
+        * GNUmakefile.am:
+        * WebCore.gypi:
+        * WebCore.order:
+        * WebCore.pro:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSBindingsAllInOne.cpp:
+        * bindings/js/JSDOMBinding.cpp:
+        (WebCore::reportException):
+        * bindings/js/JSErrorHandler.cpp: Renamed from WebCore/bindings/js/JSWorkerContextErrorHandler.cpp.
+        (WebCore::JSErrorHandler::JSErrorHandler):
+        (WebCore::JSErrorHandler::~JSErrorHandler):
+        (WebCore::JSErrorHandler::handleEvent):
+        * bindings/js/JSErrorHandler.h: Copied from WebCore/bindings/js/JSWorkerContextErrorHandler.h.
+        (WebCore::JSErrorHandler::create):
+        (WebCore::createJSErrorHandler):
+        * bindings/js/JSEventListener.h:
+        * bindings/scripts/CodeGeneratorJS.pm:
+        * bindings/scripts/CodeGeneratorV8.pm:
+        * bindings/v8/V8ConsoleMessage.cpp:
+        (WebCore::V8ConsoleMessage::dispatchNow):
+        (WebCore::V8ConsoleMessage::handler): the method was changed to use generic WebCore exception
+        reporting mechanism which is also used by JSC bindings.
+        * bindings/v8/V8ConsoleMessage.h:
+        * bindings/v8/V8EventListener.h:
+        * bindings/v8/V8WindowErrorHandler.cpp: Renamed from WebCore/bindings/js/JSWorkerContextErrorHandler.h.
+        (WebCore::V8WindowErrorHandler::V8WindowErrorHandler):
+        (WebCore::V8WindowErrorHandler::callListenerFunction):
+        * bindings/v8/V8WindowErrorHandler.h: Copied from WebCore/dom/ErrorEvent.cpp.
+        (WebCore::V8WindowErrorHandler::create):
+        * bindings/v8/WorkerContextExecutionProxy.cpp:
+        (WebCore::v8MessageHandler):
+        * bindings/v8/WorkerScriptController.cpp:
+        (WebCore::WorkerScriptController::evaluate):
+        * dom/Document.cpp:
+        (WebCore::Document::errorEventTarget):
+        (WebCore::Document::logExceptionToConsole):
+        (WebCore::Document::addMessage):
+        * dom/Document.h:
+        * dom/ErrorEvent.cpp:
+        * dom/ErrorEvent.h:
+        * dom/Event.cpp:
+        (WebCore::Event::isErrorEvent):
+        * dom/Event.h:
+        * dom/ScriptExecutionContext.cpp:
+        (WebCore::ScriptExecutionContext::PendingException::PendingException):
+        (WebCore::ScriptExecutionContext::ScriptExecutionContext):
+        (WebCore::ScriptExecutionContext::reportException): this method is not virtual anymore to
+        ensure that error event dispatching algorithm is the same in WorkerContext and in Document.
+        (WebCore::ScriptExecutionContext::dispatchErrorEvent):
+        * dom/ScriptExecutionContext.h:
+        * websockets/WebSocket.cpp:
+        (WebCore::WebSocket::connect):
+        * websockets/WebSocketChannel.cpp:
+        (WebCore::WebSocketChannel::didOpen):
+        (WebCore::WebSocketChannel::didFail):
+        (WebCore::WebSocketChannel::appendToBuffer):
+        * websockets/WebSocketHandshake.cpp:
+        (WebCore::WebSocketHandshake::readServerHandshake):
+        (WebCore::WebSocketHandshake::readStatusLine):
+        (WebCore::WebSocketHandshake::readHTTPHeaders):
+        (WebCore::WebSocketHandshake::checkResponseHeaders):
+        * workers/DefaultSharedWorkerRepository.cpp:
+        (WebCore::postExceptionTask):
+        (WebCore::postConsoleMessageTask):
+        * workers/WorkerContext.cpp:
+        (WebCore::WorkerContext::WorkerContext):
+        (WebCore::WorkerContext::errorEventTarget):
+        (WebCore::WorkerContext::logExceptionToConsole):
+        (WebCore::WorkerContext::addMessage):
+        * workers/WorkerContext.h:
+        * workers/WorkerMessagingProxy.cpp:
+        (WebCore::WorkerExceptionTask::performTask):
+        (WebCore::postConsoleMessageTask):
+        * xml/XMLHttpRequest.cpp:
+        (WebCore::reportUnsafeUsage):
+
 2011-01-19  MORITA Hajime  <morrita@google.com>
 
         Reviewed by Ryosuke Niwa.
index 2d655327d11ac7adbb56d5040dcc186993ec9bd3..1330c01de7a0d3c92d95951ac74b0b764d7fe60e 100644 (file)
@@ -777,6 +777,8 @@ webcore_sources += \
        Source/WebCore/bindings/js/JSEventSourceCustom.cpp \
        Source/WebCore/bindings/js/JSEventTarget.cpp \
        Source/WebCore/bindings/js/JSEventTarget.h \
+       Source/WebCore/bindings/js/JSErrorHandler.cpp \
+       Source/WebCore/bindings/js/JSErrorHandler.h \
        Source/WebCore/bindings/js/JSExceptionBase.cpp \
        Source/WebCore/bindings/js/JSExceptionBase.h \
        Source/WebCore/bindings/js/JSFileReaderCustom.cpp \
@@ -868,8 +870,6 @@ webcore_sources += \
        Source/WebCore/bindings/js/JSWorkerContextBase.cpp \
        Source/WebCore/bindings/js/JSWorkerContextBase.h \
        Source/WebCore/bindings/js/JSWorkerContextCustom.cpp \
-       Source/WebCore/bindings/js/JSWorkerContextErrorHandler.cpp \
-       Source/WebCore/bindings/js/JSWorkerContextErrorHandler.h \
        Source/WebCore/bindings/js/JSWorkerCustom.cpp \
        Source/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp \
        Source/WebCore/bindings/js/JSXMLHttpRequestUploadCustom.cpp \
index 5e2eee1d1aeafc07dda3384c9ea5fc688993c6e9..8492e1ed4369bbb7ed43ab63550ccb60646f76bb 100644 (file)
             'bindings/js/JSElementCustom.cpp',
             'bindings/js/JSEntryCustom.cpp',
             'bindings/js/JSEntrySyncCustom.cpp',
+            'bindings/js/JSErrorHandler.cpp',
+            'bindings/js/JSErrorHandler.h',
             'bindings/js/JSEventCustom.cpp',
             'bindings/js/JSEventListener.cpp',
             'bindings/js/JSEventListener.h',
             'bindings/js/JSWorkerContextBase.cpp',
             'bindings/js/JSWorkerContextBase.h',
             'bindings/js/JSWorkerContextCustom.cpp',
-            'bindings/js/JSWorkerContextErrorHandler.cpp',
-            'bindings/js/JSWorkerContextErrorHandler.h',
             'bindings/js/JSWorkerCustom.cpp',
             'bindings/js/JSXMLHttpRequestCustom.cpp',
             'bindings/js/JSXMLHttpRequestUploadCustom.cpp',
             'bindings/v8/V8Proxy.h',
             'bindings/v8/V8Utilities.cpp',
             'bindings/v8/V8Utilities.h',
+            'bindings/v8/V8WindowErrorHandler.cpp',
+            'bindings/v8/V8WindowErrorHandler.h',
             'bindings/v8/V8WorkerContextErrorHandler.cpp',
             'bindings/v8/V8WorkerContextErrorHandler.h',
             'bindings/v8/V8WorkerContextEventListener.cpp',
index e88c444bbb71661e030a3831d7132a25277d4dff..136a34dad65b170c5be0fb1aa3d62ac014c58da4 100644 (file)
@@ -25208,13 +25208,9 @@ __ZN7WebCore15JSWorkerContext10setTimeoutEPN3JSC9ExecStateERKNS1_7ArgListE
 __ZN7WebCore13WorkerContext10setTimeoutEPNS_15ScheduledActionEi
 __ZN7WebCore17WorkerSharedTimer11setFireTimeEd
 __ZN7WebCore15ScheduledAction7executeEPNS_13WorkerContextE
-__ZN7WebCore27JSWorkerContextErrorHandlerC1EPN3JSC8JSObjectES3_bPNS_15DOMWrapperWorldE
-__ZN7WebCore27JSWorkerContextErrorHandlerC2EPN3JSC8JSObjectES3_bPNS_15DOMWrapperWorldE
 __ZN7WebCore10ErrorEventC1ERKNS_6StringES3_j
 __ZN7WebCore10ErrorEventC2ERKNS_6StringES3_j
-__ZN7WebCore27JSWorkerContextErrorHandler11handleEventEPNS_22ScriptExecutionContextEPNS_5EventE
 __ZN7WebCore10ErrorEventD0Ev
-__ZN7WebCore27JSWorkerContextErrorHandlerD0Ev
 __ZN7WebCore17jsWorkerOnmessageEPN3JSC9ExecStateENS0_7JSValueERKNS0_10IdentifierE
 __ZN7WebCore34jsWorkerPrototypeFunctionTerminateEPN3JSC9ExecStateEPNS0_8JSObjectENS0_7JSValueERKNS0_7ArgListE
 __ZThn8_N7WebCore20WorkerMessagingProxy19workerContextClosedEv
index eef7e00f29b6ebbb57fdd7da41747fb2859b70a5..67580625b9c0bb7b737fc9d7dd652eeb08722fe9 100644 (file)
@@ -407,6 +407,7 @@ v8 {
         bindings/v8/V8NodeFilterCondition.cpp \
         bindings/v8/V8Proxy.cpp \
         bindings/v8/V8Utilities.cpp \
+        bindings/v8/V8WindowErrorHandler.cpp \
         bindings/v8/V8WorkerContextEventListener.cpp \
         bindings/v8/WorkerContextExecutionProxy.cpp \
         bindings/v8/WorkerScriptController.cpp \
@@ -548,6 +549,7 @@ v8 {
         bindings/js/JSDeviceOrientationEventCustom.cpp \
         bindings/js/JSDocumentCustom.cpp \
         bindings/js/JSElementCustom.cpp \
+        bindings/js/JSErrorHandler.cpp \
         bindings/js/JSEventCustom.cpp \
         bindings/js/JSEventListener.cpp \
         bindings/js/JSEventSourceCustom.cpp \
@@ -606,7 +608,6 @@ v8 {
         bindings/js/JSWebKitCSSKeyframesRuleCustom.cpp \
         bindings/js/JSWebKitCSSMatrixCustom.cpp \
         bindings/js/JSWebKitPointCustom.cpp \
-        bindings/js/JSWorkerContextErrorHandler.cpp \
         bindings/js/JSXMLHttpRequestCustom.cpp \
         bindings/js/JSXMLHttpRequestUploadCustom.cpp \
         bindings/js/ScheduledAction.cpp \
@@ -1482,6 +1483,7 @@ v8 {
         bindings/v8/V8NPUtils.h \
         bindings/v8/V8Proxy.h \
         bindings/v8/V8Utilities.h \
+        bindings/v8/V8WindowErrorHandler.h \
         bindings/v8/V8WorkerContextEventListener.h \
         bindings/v8/WorkerContextExecutionProxy.h \
         bindings/v8/WorkerScriptController.h \
@@ -1508,6 +1510,7 @@ v8 {
         bindings/js/JSDOMWindowCustom.h \
         bindings/js/JSDOMWindowShell.h \
         bindings/js/JSDOMWrapper.h \
+        bindings/js/JSErrorHandler.h \
         bindings/js/JSEventListener.h \
         bindings/js/JSEventTarget.h \
         bindings/js/JSHistoryCustom.h \
@@ -1525,7 +1528,6 @@ v8 {
         bindings/js/JSPluginElementFunctions.h \
         bindings/js/JSStorageCustom.h \
         bindings/js/JSWorkerContextBase.h \
-        bindings/js/JSWorkerContextErrorHandler.h \
         bindings/js/JavaScriptCallFrame.h \
         bindings/js/ScheduledAction.h \
         bindings/js/ScriptCachedFrameData.h \
index 3daf5b9c8c2c2ac7611e2e969b4da76b2866eaff..5ce45cd24334bbff44f7c8768697f764ec4ffe06 100755 (executable)
                                        RelativePath="..\bindings\js\JSEntrySyncCustom.cpp"
                                        >
                                </File>
+                               <File
+                                       RelativePath="..\bindings\js\JSErrorHandler.cpp"
+                                       >
+                                       <FileConfiguration
+                                               Name="Debug|Win32"
+                                               ExcludedFromBuild="true"
+                                               >
+                                               <Tool
+                                                       Name="VCCLCompilerTool"
+                                               />
+                                       </FileConfiguration>
+                                       <FileConfiguration
+                                               Name="Release|Win32"
+                                               ExcludedFromBuild="true"
+                                               >
+                                               <Tool
+                                                       Name="VCCLCompilerTool"
+                                               />
+                                       </FileConfiguration>
+                                       <FileConfiguration
+                                               Name="Debug_Cairo_CFLite|Win32"
+                                               ExcludedFromBuild="true"
+                                               >
+                                               <Tool
+                                                       Name="VCCLCompilerTool"
+                                               />
+                                       </FileConfiguration>
+                                       <FileConfiguration
+                                               Name="Release_Cairo_CFLite|Win32"
+                                               ExcludedFromBuild="true"
+                                               >
+                                               <Tool
+                                                       Name="VCCLCompilerTool"
+                                               />
+                                       </FileConfiguration>
+                                       <FileConfiguration
+                                               Name="Debug_All|Win32"
+                                               ExcludedFromBuild="true"
+                                               >
+                                               <Tool
+                                                       Name="VCCLCompilerTool"
+                                               />
+                                       </FileConfiguration>
+                                       <FileConfiguration
+                                               Name="Release_LTCG|Win32"
+                                               ExcludedFromBuild="true"
+                                               >
+                                               <Tool
+                                                       Name="VCCLCompilerTool"
+                                               />
+                                       </FileConfiguration>
+                               </File>
+                               <File
+                                       RelativePath="..\bindings\js\JSErrorHandler.h"
+                                       >
+                               </File>
                                <File
                                        RelativePath="..\bindings\js\JSEventCustom.cpp"
                                        >
                                                />
                                        </FileConfiguration>
                                </File>
-                               <File
-                                       RelativePath="..\bindings\js\JSWorkerContextErrorHandler.cpp"
-                                       >
-                                       <FileConfiguration
-                                               Name="Debug|Win32"
-                                               ExcludedFromBuild="true"
-                                               >
-                                               <Tool
-                                                       Name="VCCLCompilerTool"
-                                               />
-                                       </FileConfiguration>
-                                       <FileConfiguration
-                                               Name="Release|Win32"
-                                               ExcludedFromBuild="true"
-                                               >
-                                               <Tool
-                                                       Name="VCCLCompilerTool"
-                                               />
-                                       </FileConfiguration>
-                                       <FileConfiguration
-                                               Name="Debug_Cairo_CFLite|Win32"
-                                               ExcludedFromBuild="true"
-                                               >
-                                               <Tool
-                                                       Name="VCCLCompilerTool"
-                                               />
-                                       </FileConfiguration>
-                                       <FileConfiguration
-                                               Name="Release_Cairo_CFLite|Win32"
-                                               ExcludedFromBuild="true"
-                                               >
-                                               <Tool
-                                                       Name="VCCLCompilerTool"
-                                               />
-                                       </FileConfiguration>
-                                       <FileConfiguration
-                                               Name="Debug_All|Win32"
-                                               ExcludedFromBuild="true"
-                                               >
-                                               <Tool
-                                                       Name="VCCLCompilerTool"
-                                               />
-                                       </FileConfiguration>
-                                       <FileConfiguration
-                                               Name="Release_LTCG|Win32"
-                                               ExcludedFromBuild="true"
-                                               >
-                                               <Tool
-                                                       Name="VCCLCompilerTool"
-                                               />
-                                       </FileConfiguration>
-                               </File>
-                               <File
-                                       RelativePath="..\bindings\js\JSWorkerContextErrorHandler.h"
-                                       >
-                               </File>
                                <File
                                        RelativePath="..\bindings\js\JSWorkerCustom.cpp"
                                        >
index 689c4d2cd52744dab57173bf7a512b6dc934e246..3af5015d2fcb71f8dd288db14146d9c164c6b785 100644 (file)
                F392249D126F11AE00A926D9 /* ScriptCallStackFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = F392249B126F11AE00A926D9 /* ScriptCallStackFactory.h */; };
                F39BE95B12673BF400E0A674 /* ScriptArguments.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F39BE95912673BF400E0A674 /* ScriptArguments.cpp */; };
                F39BE95C12673BF400E0A674 /* ScriptArguments.h in Headers */ = {isa = PBXBuildFile; fileRef = F39BE95A12673BF400E0A674 /* ScriptArguments.h */; };
-               F3D461481161D53200CA0D09 /* JSWorkerContextErrorHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F3D461461161D53200CA0D09 /* JSWorkerContextErrorHandler.cpp */; };
-               F3D461491161D53200CA0D09 /* JSWorkerContextErrorHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = F3D461471161D53200CA0D09 /* JSWorkerContextErrorHandler.h */; };
+               F3D461481161D53200CA0D09 /* JSErrorHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F3D461461161D53200CA0D09 /* JSErrorHandler.cpp */; };
+               F3D461491161D53200CA0D09 /* JSErrorHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = F3D461471161D53200CA0D09 /* JSErrorHandler.h */; };
                F3D4C47812E07663003DA150 /* InspectorBrowserDebuggerAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F3D4C47612E07663003DA150 /* InspectorBrowserDebuggerAgent.cpp */; };
                F3D4C47912E07663003DA150 /* InspectorBrowserDebuggerAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = F3D4C47712E07663003DA150 /* InspectorBrowserDebuggerAgent.h */; };
                F4EAF4AE10C742B1009100D3 /* OpenTypeSanitizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4EAF4AC10C742B1009100D3 /* OpenTypeSanitizer.cpp */; };
                F392249B126F11AE00A926D9 /* ScriptCallStackFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptCallStackFactory.h; sourceTree = "<group>"; };
                F39BE95912673BF400E0A674 /* ScriptArguments.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptArguments.cpp; sourceTree = "<group>"; };
                F39BE95A12673BF400E0A674 /* ScriptArguments.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptArguments.h; sourceTree = "<group>"; };
-               F3D461461161D53200CA0D09 /* JSWorkerContextErrorHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWorkerContextErrorHandler.cpp; sourceTree = "<group>"; };
-               F3D461471161D53200CA0D09 /* JSWorkerContextErrorHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWorkerContextErrorHandler.h; sourceTree = "<group>"; };
+               F3D461461161D53200CA0D09 /* JSErrorHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSErrorHandler.cpp; sourceTree = "<group>"; };
+               F3D461471161D53200CA0D09 /* JSErrorHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSErrorHandler.h; sourceTree = "<group>"; };
                F3D4C47612E07663003DA150 /* InspectorBrowserDebuggerAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorBrowserDebuggerAgent.cpp; sourceTree = "<group>"; };
                F3D4C47712E07663003DA150 /* InspectorBrowserDebuggerAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorBrowserDebuggerAgent.h; sourceTree = "<group>"; };
                F4EAF4AC10C742B1009100D3 /* OpenTypeSanitizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OpenTypeSanitizer.cpp; path = opentype/OpenTypeSanitizer.cpp; sourceTree = "<group>"; };
                                BCBFB53B0DCD29CF0019B3E5 /* JSDOMWindowShell.h */,
                                BC53DAC611433064000D817E /* JSDOMWrapper.cpp */,
                                65E0E9431133C89F00B4CB10 /* JSDOMWrapper.h */,
+                               F3D461461161D53200CA0D09 /* JSErrorHandler.cpp */,
+                               F3D461471161D53200CA0D09 /* JSErrorHandler.h */,
                                BC60901E0E91B8EC000C68B5 /* JSEventTarget.cpp */,
                                BC60901D0E91B8EC000C68B5 /* JSEventTarget.h */,
                                3314ACE910892086000F0E56 /* JSExceptionBase.cpp */,
                                14CD8D81106B529000A46D23 /* JSSharedWorkerCustom.cpp */,
                                E1C36D320EB0A094007410BC /* JSWorkerContextBase.cpp */,
                                E1C36D330EB0A094007410BC /* JSWorkerContextBase.h */,
-                               F3D461461161D53200CA0D09 /* JSWorkerContextErrorHandler.cpp */,
-                               F3D461471161D53200CA0D09 /* JSWorkerContextErrorHandler.h */,
                                BCA378BA0D15F64200B793D6 /* ScheduledAction.cpp */,
                                BCA378BB0D15F64200B793D6 /* ScheduledAction.h */,
                                41F1D21E0EF35C2A00DA8753 /* ScriptCachedFrameData.cpp */,
                                E1CAA5C60E8BD23600A73ECA /* JSWorker.h in Headers */,
                                E18256900EF2B02D00933242 /* JSWorkerContext.h in Headers */,
                                E1C36D350EB0A094007410BC /* JSWorkerContextBase.h in Headers */,
-                               F3D461491161D53200CA0D09 /* JSWorkerContextErrorHandler.h in Headers */,
+                               F3D461491161D53200CA0D09 /* JSErrorHandler.h in Headers */,
                                E1C362EF0EAF2AA9007410BC /* JSWorkerLocation.h in Headers */,
                                E1271A580EEECDE400F61213 /* JSWorkerNavigator.h in Headers */,
                                BC348BD40DB7F804004ABAB9 /* JSXMLHttpRequest.h in Headers */,
                                E182568F0EF2B02D00933242 /* JSWorkerContext.cpp in Sources */,
                                E1C36D340EB0A094007410BC /* JSWorkerContextBase.cpp in Sources */,
                                E18258AC0EF3CD7000933242 /* JSWorkerContextCustom.cpp in Sources */,
-                               F3D461481161D53200CA0D09 /* JSWorkerContextErrorHandler.cpp in Sources */,
+                               F3D461481161D53200CA0D09 /* JSErrorHandler.cpp in Sources */,
                                E1CA5CBC0E8CDCAF00E8EF90 /* JSWorkerCustom.cpp in Sources */,
                                E1C362F00EAF2AA9007410BC /* JSWorkerLocation.cpp in Sources */,
                                E1271A590EEECDE400F61213 /* JSWorkerNavigator.cpp in Sources */,
index 853e2efa277b9f69d164120d884ba091ce3b8e19..af74e8cbc966fe4ca1b235b16d7f755ea6d9eff0 100644 (file)
@@ -71,6 +71,7 @@
 #include "JSDeviceOrientationEventCustom.cpp"
 #include "JSDocumentCustom.cpp"
 #include "JSElementCustom.cpp"
+#include "JSErrorHandler.cpp"
 #include "JSEventCustom.cpp"
 #include "JSEventListener.cpp"
 #include "JSEventSourceCustom.cpp"
 #include "JSWebSocketCustom.cpp"
 #include "JSWorkerContextBase.cpp"
 #include "JSWorkerContextCustom.cpp"
-#include "JSWorkerContextErrorHandler.cpp"
 #include "JSWorkerCustom.cpp"
 #include "JSXMLHttpRequestCustom.cpp"
 #include "JSXMLHttpRequestUploadCustom.cpp"
index 72c7cd6dc4b79105afed3ca1ea719e63658ee30c..e53dcfb601aa2b92fa1e5b08f44662f73423c76d 100644 (file)
@@ -53,6 +53,7 @@
 #include "ProcessingInstruction.h"
 #include "RangeException.h"
 #include "ScriptCachedFrameData.h"
+#include "ScriptCallStack.h"
 #include "ScriptController.h"
 #include "Settings.h"
 #include "WebCoreJSClientData.h"
@@ -589,7 +590,7 @@ void reportException(ExecState* exec, JSValue exception)
     if (!scriptExecutionContext)
         return;
 
-    scriptExecutionContext->reportException(ustringToString(errorMessage), lineNumber, ustringToString(exceptionSourceURL));
+    scriptExecutionContext->reportException(ustringToString(errorMessage), lineNumber, ustringToString(exceptionSourceURL), 0);
 }
 
 void reportCurrentException(ExecState* exec)
similarity index 86%
rename from Source/WebCore/bindings/js/JSWorkerContextErrorHandler.cpp
rename to Source/WebCore/bindings/js/JSErrorHandler.cpp
index f7d2b02ac22370078f505d9380fbca98709ab575..ae8e3632195f6b1361424e48a2ce5d3e5c5411d7 100644 (file)
@@ -30,9 +30,7 @@
 
 #include "config.h"
 
-#if ENABLE(WORKERS)
-
-#include "JSWorkerContextErrorHandler.h"
+#include "JSErrorHandler.h"
 
 #include "ErrorEvent.h"
 #include "Event.h"
@@ -43,21 +41,26 @@ using namespace JSC;
 
 namespace WebCore {
 
-JSWorkerContextErrorHandler::JSWorkerContextErrorHandler(JSObject* function, JSObject* wrapper, bool isAttribute, DOMWrapperWorld* isolatedWorld)
+JSErrorHandler::JSErrorHandler(JSObject* function, JSObject* wrapper, bool isAttribute, DOMWrapperWorld* isolatedWorld)
     : JSEventListener(function, wrapper, isAttribute, isolatedWorld)
 {
 }
 
-JSWorkerContextErrorHandler::~JSWorkerContextErrorHandler()
+JSErrorHandler::~JSErrorHandler()
 {
 }
 
-void JSWorkerContextErrorHandler::handleEvent(ScriptExecutionContext* scriptExecutionContext, Event* event)
+void JSErrorHandler::handleEvent(ScriptExecutionContext* scriptExecutionContext, Event* event)
 {
+    if (!event->isErrorEvent())
+        return JSEventListener::handleEvent(scriptExecutionContext, event);
+
     ASSERT(scriptExecutionContext);
     if (!scriptExecutionContext)
         return;
 
+    ErrorEvent* errorEvent = static_cast<ErrorEvent*>(event);
+
     JSLock lock(SilenceAssertionsOnly);
 
     JSObject* jsFunction = this->jsFunction(scriptExecutionContext);
@@ -74,15 +77,11 @@ void JSWorkerContextErrorHandler::handleEvent(ScriptExecutionContext* scriptExec
     CallType callType = jsFunction->getCallData(callData);
 
     if (callType != CallTypeNone) {
-
-        ref();
+        RefPtr<JSErrorHandler> protectedctor(this);
 
         Event* savedEvent = globalObject->currentEvent();
         globalObject->setCurrentEvent(event);
 
-        ASSERT(event->isErrorEvent());
-        ErrorEvent* errorEvent = static_cast<ErrorEvent*>(event);
-
         MarkedArgumentBuffer args;
         args.append(jsString(exec, errorEvent->message()));
         args.append(jsString(exec, errorEvent->filename()));
@@ -106,11 +105,7 @@ void JSWorkerContextErrorHandler::handleEvent(ScriptExecutionContext* scriptExec
             if (returnValue.getBoolean(retvalbool) && !retvalbool)
                 event->preventDefault();
         }
-
-        deref();
     }
 }
 
 } // namespace WebCore
-
-#endif // ENABLE(WORKERS)
similarity index 69%
rename from Source/WebCore/bindings/js/JSWorkerContextErrorHandler.h
rename to Source/WebCore/bindings/js/JSErrorHandler.h
index a188299038c9cdfe72286b71feaeb3a49c2a0d81..957fd81daa057469b2112e11d7e704ad4e29d7ed 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef JSWorkerContextErrorHandler_h
-#define JSWorkerContextErrorHandler_h
+#ifndef JSErrorHandler_h
+#define JSErrorHandler_h
 
 #include "JSEventListener.h"
 
 namespace WebCore {
 
-class JSWorkerContextErrorHandler : public JSEventListener {
+class JSErrorHandler : public JSEventListener {
 public:
-    static PassRefPtr<JSWorkerContextErrorHandler> create(JSC::JSObject* listener, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld* isolatedWorld)
+    static PassRefPtr<JSErrorHandler> create(JSC::JSObject* listener, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld* isolatedWorld)
     {
-        return adoptRef(new JSWorkerContextErrorHandler(listener, wrapper, isAttribute, isolatedWorld));
+        return adoptRef(new JSErrorHandler(listener, wrapper, isAttribute, isolatedWorld));
     }
 
-    virtual ~JSWorkerContextErrorHandler();
+    virtual ~JSErrorHandler();
 
 private:
-    JSWorkerContextErrorHandler(JSC::JSObject* function, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld* isolatedWorld);
+    JSErrorHandler(JSC::JSObject* function, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld* isolatedWorld);
     virtual void handleEvent(ScriptExecutionContext*, Event*);
 };
 
 // Creates a JS EventListener for "onerror" event handler in worker context. It has custom implementation because
 // unlike other event listeners it accepts three parameters.
-inline PassRefPtr<JSWorkerContextErrorHandler> createJSWorkerContextErrorHandler(JSC::ExecState* exec, JSC::JSValue listener, JSC::JSObject* wrapper)
+inline PassRefPtr<JSErrorHandler> createJSErrorHandler(JSC::ExecState* exec, JSC::JSValue listener, JSC::JSObject* wrapper)
 {
     if (!listener.isObject())
         return 0;
 
-    return JSWorkerContextErrorHandler::create(asObject(listener), wrapper, true, currentWorld(exec));
+    return JSErrorHandler::create(asObject(listener), wrapper, true, currentWorld(exec));
 }
 
 } // namespace WebCore
 
-#endif // JSWorkerContextErrorHandler_h
+#endif // JSErrorHandler_h
index b15c5894359df43dd1d124b1583a4d5a7296e1d6..83d0d2ee9b8ccfdc4a008121c56a2a7681990f6c 100644 (file)
@@ -59,11 +59,11 @@ namespace WebCore {
         virtual JSC::JSObject* initializeJSFunction(ScriptExecutionContext*) const;
         virtual void markJSFunction(JSC::MarkStack&);
         virtual void invalidateJSFunction(JSC::JSObject*);
-        virtual void handleEvent(ScriptExecutionContext*, Event*);
         virtual bool virtualisAttribute() const;
 
     protected:
         JSEventListener(JSC::JSObject* function, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld* isolatedWorld);
+        virtual void handleEvent(ScriptExecutionContext*, Event*);
 
     private:
         mutable JSC::JSObject* m_jsFunction;
index cff51e9e9bf235b9e12ae63ee70e0bed79494856..abef04e87f7c68d490358160766c78f9d89b9c9b 100644 (file)
@@ -1721,9 +1721,9 @@ sub GenerateImplementation
                                 push(@implContent, "    JSDOMGlobalObject* globalObject = castedThis->globalObject();\n");
                             }
                             push(@implContent, "    $implClassName* imp = static_cast<$implClassName*>(static_cast<$className*>(thisObject)->impl());\n");
-                            if ($interfaceName eq "WorkerContext" and $name eq "onerror") {
-                                $implIncludes{"JSWorkerContextErrorHandler.h"} = 1;
-                                push(@implContent, "    imp->set$implSetterFunctionName(createJSWorkerContextErrorHandler(exec, value, thisObject));\n");
+                            if ((($interfaceName eq "DOMWindow") or ($interfaceName eq "WorkerContext")) and $name eq "onerror") {
+                                $implIncludes{"JSErrorHandler.h"} = 1;
+                                push(@implContent, "    imp->set$implSetterFunctionName(createJSErrorHandler(exec, value, thisObject));\n");
                             } else {
                                 push(@implContent, GenerateAttributeEventListenerCall($className, $implSetterFunctionName, $windowEventListener));
                             }
index f50e74a5c6e56754e4fb391a54037a00621bd40f..c06fe17087b32a4f80089847c571174a52faf012 100644 (file)
@@ -1001,6 +1001,10 @@ END
                 $implIncludes{"V8EventListenerList.h"} = 1;
                 $implIncludes{"V8WorkerContextErrorHandler.h"} = 1;
                 push(@implContentDecls, "    imp->set$implSetterFunctionName(V8EventListenerList::findOrCreateWrapper<V8WorkerContextErrorHandler>(value, true)");
+            } elsif ($interfaceName eq "DOMWindow" and $attribute->signature->name eq "onerror") {
+                $implIncludes{"V8EventListenerList.h"} = 1;
+                $implIncludes{"V8WindowErrorHandler.h"} = 1;
+                push(@implContentDecls, "    imp->set$implSetterFunctionName(V8EventListenerList::findOrCreateWrapper<V8WindowErrorHandler>(value, true)");
             } else {
                 push(@implContentDecls, "    imp->set$implSetterFunctionName(V8DOMWrapper::getEventListener(value, true, ListenerFindOrCreate)");
             }
index e6871fdca397162022f2b0bfd519a7437654df51..d92822ceeac666945dba026b5c1fa096aff88101 100644 (file)
@@ -54,7 +54,14 @@ V8ConsoleMessage::V8ConsoleMessage(const String& string, const String& sourceID,
 
 void V8ConsoleMessage::dispatchNow(Page* page)
 {
-    dispatchNow(page, 0);
+    ASSERT(page);
+
+    // Process any delayed messages to make sure that messages
+    // appear in the right order in the console.
+    processDelayed();
+
+    Console* console = page->mainFrame()->domWindow()->console();
+    console->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, m_string, m_lineNumber, m_sourceID);
 }
 
 void V8ConsoleMessage::dispatchLater()
@@ -105,8 +112,8 @@ void V8ConsoleMessage::handler(v8::Handle<v8::Message> message, v8::Handle<v8::V
     Frame* frame = V8Proxy::retrieveFrameForEnteredContext();
     if (!frame)
         return;
-    Page* page = frame->page();
-    if (!page)
+    Document* document = frame->document();
+    if (!document)
         return;
 
     v8::Handle<v8::String> errorMessageString = message->Get();
@@ -122,21 +129,7 @@ void V8ConsoleMessage::handler(v8::Handle<v8::Message> message, v8::Handle<v8::V
     v8::Handle<v8::Value> resourceName = message->GetScriptResourceName();
     bool useURL = resourceName.IsEmpty() || !resourceName->IsString();
     String resourceNameString = useURL ? frame->document()->url() : toWebCoreString(resourceName);
-    V8ConsoleMessage consoleMessage(errorMessage, resourceNameString, message->GetLineNumber());
-    consoleMessage.dispatchNow(page, callStack);
-}
-
-void V8ConsoleMessage::dispatchNow(Page* page, PassRefPtr<ScriptCallStack> callStack)
-{
-    ASSERT(page);
-
-    // Process any delayed messages to make sure that messages
-    // appear in the right order in the console.
-    processDelayed();
-
-    Console* console = page->mainFrame()->domWindow()->console();
-    MessageType messageType = callStack ? UncaughtExceptionMessageType : LogMessageType;
-    console->addMessage(JSMessageSource, messageType, ErrorMessageLevel, m_string, m_lineNumber, m_sourceID, callStack);
+    document->reportException(errorMessage, message->GetLineNumber(), resourceNameString, callStack);
 }
 
 } // namespace WebCore
index 97de24f1023ddcfc7e40b220f32ad8762061027a..6183fc6867dc1a5d0a62cf263e07b6bbb8e9947b 100644 (file)
@@ -82,8 +82,6 @@ namespace WebCore {
         const String m_sourceID;
         const unsigned m_lineNumber;
 
-        void dispatchNow(Page*, PassRefPtr<ScriptCallStack>);
-
         // All delayed messages are stored in this vector. If the vector
         // is 0, there are no delayed messages.
         static Vector<V8ConsoleMessage>* m_delayedMessages;
index fb6c0bc6ae0feadf4b3ea00ca6b98277f19d8400..bcf72139c9599a1a19fc1c6341cec7bdd63a55e0 100644 (file)
@@ -54,8 +54,7 @@ namespace WebCore {
 
         v8::Local<v8::Function> getListenerFunction(ScriptExecutionContext*);
 
-    private:
-      virtual v8::Local<v8::Value> callListenerFunction(ScriptExecutionContext*, v8::Handle<v8::Value> jsEvent, Event*);
+        virtual v8::Local<v8::Value> callListenerFunction(ScriptExecutionContext*, v8::Handle<v8::Value> jsEvent, Event*);
      };
 
 } // namespace WebCore
diff --git a/Source/WebCore/bindings/v8/V8WindowErrorHandler.cpp b/Source/WebCore/bindings/v8/V8WindowErrorHandler.cpp
new file mode 100644 (file)
index 0000000..4203ad5
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "V8WindowErrorHandler.h"
+
+#include "ErrorEvent.h"
+#include "V8Binding.h"
+
+namespace WebCore {
+
+V8WindowErrorHandler::V8WindowErrorHandler(v8::Local<v8::Object> listener, bool isInline, const WorldContextHandle& worldContext)
+    : V8EventListener(listener, isInline, worldContext)
+{
+}
+
+v8::Local<v8::Value> V8WindowErrorHandler::callListenerFunction(ScriptExecutionContext* context, v8::Handle<v8::Value> jsEvent, Event* event)
+{
+    if (!event->isErrorEvent())
+        return V8EventListener::callListenerFunction(context, jsEvent, event);
+    
+    ErrorEvent* errorEvent = static_cast<ErrorEvent*>(event);
+    v8::Local<v8::Object> listener = getListenerObject(context);
+    v8::Local<v8::Value> returnValue;
+    if (!listener.IsEmpty() && listener->IsFunction()) {
+        v8::Local<v8::Function> callFunction = v8::Local<v8::Function>::Cast(listener);
+        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;
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/bindings/v8/V8WindowErrorHandler.h b/Source/WebCore/bindings/v8/V8WindowErrorHandler.h
new file mode 100644 (file)
index 0000000..493a9bf
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef V8WindowErrorHandler_h
+#define V8WindowErrorHandler_h
+
+#include "V8EventListener.h"
+#include <v8.h>
+#include <wtf/PassRefPtr.h>
+
+namespace WebCore {
+
+class V8WindowErrorHandler : public V8EventListener {
+public:
+    static PassRefPtr<V8WindowErrorHandler> create(v8::Local<v8::Object> listener, bool isInline, const WorldContextHandle& worldContext)
+    {
+        return adoptRef(new V8WindowErrorHandler(listener, isInline, worldContext));
+    }
+
+private:
+    V8WindowErrorHandler(v8::Local<v8::Object> listener, bool isInline, const WorldContextHandle& worldContext);
+
+    virtual v8::Local<v8::Value> callListenerFunction(ScriptExecutionContext*, v8::Handle<v8::Value> jsEvent, Event*);
+};
+
+} // namespace WebCore
+
+#endif // V8WindowErrorHandler_h
index cefb2faa7390894b35d65ad53f21a8fbc7dda561..eb258149f06665fe107b8fcb5b93b289407e68a9 100644 (file)
@@ -37,6 +37,7 @@
 
 #include "DedicatedWorkerContext.h"
 #include "Event.h"
+#include "ScriptCallStack.h"
 #include "SharedWorker.h"
 #include "SharedWorkerContext.h"
 #include "V8Binding.h"
@@ -72,7 +73,7 @@ static void v8MessageHandler(v8::Handle<v8::Message> message, v8::Handle<v8::Val
         String errorMessage = toWebCoreString(message->Get());
         int lineNumber = message->GetLineNumber();
         String sourceURL = toWebCoreString(message->GetScriptResourceName());
-        context->reportException(errorMessage, lineNumber, sourceURL);
+        context->reportException(errorMessage, lineNumber, sourceURL, 0);
     }
 
     isReportingException = false;
index b56d3836d7e6bb1ac5d2c8c5ed630f07c276ef22..42e02e66d2e433b793b855b3be139d7ea98ca4d5 100644 (file)
 
 #include "WorkerScriptController.h"
 
-#include <v8.h>
-
+#include "DOMTimer.h"
+#include "ScriptCallStack.h"
 #include "ScriptSourceCode.h"
 #include "ScriptValue.h"
-#include "DOMTimer.h"
 #include "V8DOMMap.h"
 #include "V8Proxy.h"
 #include "V8WorkerContext.h"
@@ -46,6 +45,7 @@
 #include "WorkerContextExecutionProxy.h"
 #include "WorkerObjectProxy.h"
 #include "WorkerThread.h"
+#include <v8.h>
 
 namespace WebCore {
 
@@ -80,7 +80,7 @@ ScriptValue WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode,
         if (exception)
             *exception = state.exception;
         else
-            m_workerContext->reportException(state.errorMessage, state.lineNumber, state.sourceURL);
+            m_workerContext->reportException(state.errorMessage, state.lineNumber, state.sourceURL, 0);
     }
 
     return result;
index ce05a09963d297c43eccfef5c8d5e147975df4f5..0bb025ae477c542ab04eb5592a4acb05b89560c4 100644 (file)
 #include "RenderTextControl.h"
 #include "RenderView.h"
 #include "RenderWidget.h"
+#include "ScriptCallStack.h"
 #include "ScriptController.h"
 #include "ScriptElement.h"
 #include "ScriptEventListener.h"
@@ -2298,6 +2299,17 @@ KURL Document::virtualCompleteURL(const String& url) const
     return completeURL(url);
 }
 
+EventTarget* Document::errorEventTarget()
+{
+    return domWindow();
+}
+
+void Document::logExceptionToConsole(const String& errorMessage, int lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack> callStack)
+{
+    MessageType messageType = callStack ? UncaughtExceptionMessageType : LogMessageType;
+    addMessage(JSMessageSource, messageType, ErrorMessageLevel, errorMessage, lineNumber, sourceURL, callStack);
+}
+
 void Document::setURL(const KURL& url)
 {
     const KURL& newURL = url.isEmpty() ? blankURL() : url;
@@ -4673,15 +4685,10 @@ void Document::parseDNSPrefetchControlHeader(const String& dnsPrefetchControl)
     m_haveExplicitlyDisabledDNSPrefetch = true;
 }
 
-void Document::reportException(const String& errorMessage, int lineNumber, const String& sourceURL)
-{
-    addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, errorMessage, lineNumber, sourceURL);
-}
-
-void Document::addMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL)
+void Document::addMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack> callStack)
 {
     if (DOMWindow* window = domWindow())
-        window->console()->addMessage(source, type, level, message, lineNumber, sourceURL);
+        window->console()->addMessage(source, type, level, message, lineNumber, sourceURL, callStack);
 }
 
 struct PerformTaskContext : Noncopyable {
index 2cd26f9ed32c93b7f03f5cfcb3eefb4a062f99d2..1ab98a6320a2d099849a260c3f7a674e683807ed 100644 (file)
@@ -931,8 +931,7 @@ public:
     bool isDNSPrefetchEnabled() const { return m_isDNSPrefetchEnabled; }
     void parseDNSPrefetchControlHeader(const String&);
 
-    virtual void reportException(const String& errorMessage, int lineNumber, const String& sourceURL);
-    virtual void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL);
+    virtual void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>);
     virtual void postTask(PassOwnPtr<Task>); // Executes the task on context's thread asynchronously.
 
 #if USE(JSC)
@@ -1074,6 +1073,9 @@ public:
 
     bool mayCauseFlashOfUnstyledContent() const;
 
+    virtual EventTarget* errorEventTarget();
+    virtual void logExceptionToConsole(const String& errorMessage, int lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>);
+
     void initDNSPrefetch();
 
 protected:
index 2627d0154e623abaad91d49baa9df1986d293d50..c5988367c0279a429fc6ce2819e54ef5b86f405e 100644 (file)
@@ -30,8 +30,6 @@
 
 #include "config.h"
 
-#if ENABLE(WORKERS)
-
 #include "ErrorEvent.h"
 
 #include "EventNames.h"
@@ -72,5 +70,3 @@ bool ErrorEvent::isErrorEvent() const
 }
 
 } // namespace WebCore
-
-#endif // ENABLE(WORKERS)
index f81530aee620b89217e164ccfaba730f1db61140..719ca2d5e1974b65a63893fe26106b6f51c73aad 100644 (file)
@@ -31,8 +31,6 @@
 #ifndef ErrorEvent_h
 #define ErrorEvent_h
 
-#if ENABLE(WORKERS)
-
 #include "Event.h"
 #include "PlatformString.h"
 
@@ -69,6 +67,4 @@ namespace WebCore {
 
 } // namespace WebCore
 
-#endif // ENABLE(WORKERS)
-
 #endif // ErrorEvent_h
index 24efc4eee90b82aa02ec127b5f62987c858d6a27..0e11c695b84db5be0d87bc5da7f655530a36d654 100644 (file)
@@ -204,12 +204,10 @@ bool Event::isIDBSuccessEvent() const
 }
 #endif
 
-#if ENABLE(WORKERS)
 bool Event::isErrorEvent() const
 {
     return false;
 }
-#endif
 
 #if ENABLE(TOUCH_EVENTS)
 bool Event::isTouchEvent() const
index 8562cadb78d02fd3bf14029a9c5f8ac317f72af5..f629241586d3b7a51f12de1470751aa84cdd63f9 100644 (file)
@@ -132,9 +132,7 @@ namespace WebCore {
 #if ENABLE(WEB_AUDIO)
         virtual bool isAudioProcessingEvent() const;
 #endif
-#if ENABLE(WORKERS)
         virtual bool isErrorEvent() const;
-#endif
 #if ENABLE(TOUCH_EVENTS)
         virtual bool isTouchEvent() const;
 #endif
index bfda17b3f1b4d93dabd8f6410db765b50367dec8..f498be005034d12cbbd5b8a70f49e15eb043e48c 100644 (file)
 #include "Database.h"
 #include "DatabaseTask.h"
 #include "DatabaseThread.h"
+#include "ErrorEvent.h"
+#include "EventListener.h"
+#include "EventTarget.h"
 #include "FileThread.h"
 #include "MessagePort.h"
+#include "ScriptCallStack.h"
 #include "SecurityOrigin.h"
 #include "ThreadableBlobRegistry.h"
 #include "WorkerContext.h"
 #include "WorkerThread.h"
 #include <wtf/MainThread.h>
 #include <wtf/PassRefPtr.h>
+#include <wtf/Vector.h>
 
 #if USE(JSC)
 #include "JSDOMWindow.h"
@@ -61,9 +66,25 @@ public:
     }
 };
 
+class ScriptExecutionContext::PendingException : public Noncopyable {
+public:
+    PendingException(const String& errorMessage, int lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack> callStack)
+        : m_errorMessage(errorMessage)
+        , m_lineNumber(lineNumber)
+        , m_sourceURL(sourceURL)
+        , m_callStack(callStack)
+    {
+    }
+    String m_errorMessage;
+    int m_lineNumber;
+    String m_sourceURL;
+    RefPtr<ScriptCallStack> m_callStack;
+};
+
 ScriptExecutionContext::ScriptExecutionContext()
+    : m_inDispatchErrorEvent(false)
 #if ENABLE(DATABASE)
-    : m_hasOpenDatabases(false)
+    , m_hasOpenDatabases(false)
 #endif
 {
 }
@@ -243,6 +264,43 @@ void ScriptExecutionContext::setSecurityOrigin(PassRefPtr<SecurityOrigin> securi
     m_securityOrigin = securityOrigin;
 }
 
+void ScriptExecutionContext::reportException(const String& errorMessage, int lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack> callStack)
+{
+    if (m_inDispatchErrorEvent) {
+        if (!m_pendingExceptions)
+            m_pendingExceptions = adoptPtr(new Vector<OwnPtr<PendingException> >());
+        m_pendingExceptions->append(adoptPtr(new PendingException(errorMessage, lineNumber, sourceURL, callStack)));
+        return;
+    }
+
+    // First report the original exception and only then all the nested ones.
+    if (!dispatchErrorEvent(errorMessage, lineNumber, sourceURL))
+        logExceptionToConsole(errorMessage, lineNumber, sourceURL, callStack);
+
+    if (!m_pendingExceptions)
+        return;
+
+    for (size_t i = 0; i < m_pendingExceptions->size(); i++) {
+        PendingException* e = m_pendingExceptions->at(i).get();
+        logExceptionToConsole(e->m_errorMessage, e->m_lineNumber, e->m_sourceURL, e->m_callStack);
+    }
+    m_pendingExceptions.clear();
+}
+
+bool ScriptExecutionContext::dispatchErrorEvent(const String& errorMessage, int lineNumber, const String& sourceURL)
+{
+    EventTarget* target = errorEventTarget();
+    if (!target)
+        return false;
+
+    ASSERT(!m_inDispatchErrorEvent);
+    m_inDispatchErrorEvent = true;
+    RefPtr<ErrorEvent> errorEvent = ErrorEvent::create(errorMessage, sourceURL, lineNumber);
+    target->dispatchEvent(errorEvent);
+    m_inDispatchErrorEvent = false;
+    return errorEvent->defaultPrevented();
+}
+
 void ScriptExecutionContext::addTimeout(int timeoutId, DOMTimer* timer)
 {
     ASSERT(!m_timeouts.contains(timeoutId));
index e473a4b7c496b842b5d0eb0c8ff4fb41092b91c8..fbb96ec651fb5047d0240d56a489b67f4eee4b28 100644 (file)
@@ -33,6 +33,7 @@
 #include <wtf/Forward.h>
 #include <wtf/HashMap.h>
 #include <wtf/HashSet.h>
+#include <wtf/OwnPtr.h>
 #include <wtf/PassOwnPtr.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefPtr.h>
@@ -52,11 +53,14 @@ namespace WebCore {
     class DatabaseThread;
 #endif
     class DOMTimer;
+    class EventListener;
+    class EventTarget;
 #if ENABLE(BLOB) || ENABLE(FILE_SYSTEM)
     class FileThread;
 #endif
     class MessagePort;
     class SecurityOrigin;
+    class ScriptCallStack;
 
     class ScriptExecutionContext {
     public:
@@ -85,8 +89,8 @@ namespace WebCore {
 
         SecurityOrigin* securityOrigin() const { return m_securityOrigin.get(); }
 
-        virtual void reportException(const String& errorMessage, int lineNumber, const String& sourceURL) = 0;
-        virtual void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL) = 0;
+        void reportException(const String& errorMessage, int lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>);
+        virtual void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>) = 0;
 
         // Active objects are not garbage collected even if inaccessible, e.g. because their activity may result in callbacks being invoked.
         bool canSuspendActiveDOMObjects();
@@ -148,6 +152,10 @@ namespace WebCore {
         virtual const KURL& virtualURL() const = 0;
         virtual KURL virtualCompleteURL(const String&) const = 0;
 
+        virtual EventTarget* errorEventTarget() = 0;
+        virtual void logExceptionToConsole(const String& errorMessage, int lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>) = 0;
+        bool dispatchErrorEvent(const String& errorMessage, int lineNumber, const String& sourceURL);
+
         void closeMessagePorts();
 
         RefPtr<SecurityOrigin> m_securityOrigin;
@@ -165,6 +173,10 @@ namespace WebCore {
         virtual void refScriptExecutionContext() = 0;
         virtual void derefScriptExecutionContext() = 0;
 
+        bool m_inDispatchErrorEvent;
+        class PendingException;
+        OwnPtr<Vector<OwnPtr<PendingException> > > m_pendingExceptions;
+
 #if ENABLE(DATABASE)
         RefPtr<DatabaseThread> m_databaseThread;
         bool m_hasOpenDatabases; // This never changes back to false, even after the database thread is closed.
index 358a742cb040524abd1dbc65abdab6a5881825f2..e15d079062dbc211aa368b2366bc45787eac0a9e 100644 (file)
@@ -41,6 +41,7 @@
 #include "EventNames.h"
 #include "Logging.h"
 #include "MessageEvent.h"
+#include "ScriptCallStack.h"
 #include "ScriptExecutionContext.h"
 #include "ThreadableWebSocketChannel.h"
 #include "WebSocketChannel.h"
@@ -116,32 +117,32 @@ void WebSocket::connect(const KURL& url, const String& protocol, ExceptionCode&
     m_protocol = protocol;
 
     if (!m_url.isValid()) {
-        scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Invalid url for WebSocket " + url.string(), 0, scriptExecutionContext()->securityOrigin()->toString());
+        scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Invalid url for WebSocket " + url.string(), 0, scriptExecutionContext()->securityOrigin()->toString(), 0);
         m_state = CLOSED;
         ec = SYNTAX_ERR;
         return;
     }
 
     if (!m_url.protocolIs("ws") && !m_url.protocolIs("wss")) {
-        scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Wrong url scheme for WebSocket " + url.string(), 0, scriptExecutionContext()->securityOrigin()->toString());
+        scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Wrong url scheme for WebSocket " + url.string(), 0, scriptExecutionContext()->securityOrigin()->toString(), 0);
         m_state = CLOSED;
         ec = SYNTAX_ERR;
         return;
     }
     if (m_url.hasFragmentIdentifier()) {
-        scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "URL has fragment component " + url.string(), 0, scriptExecutionContext()->securityOrigin()->toString());
+        scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "URL has fragment component " + url.string(), 0, scriptExecutionContext()->securityOrigin()->toString(), 0);
         m_state = CLOSED;
         ec = SYNTAX_ERR;
         return;
     }
     if (!isValidProtocolString(m_protocol)) {
-        scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Wrong protocol for WebSocket '" + encodeProtocolString(m_protocol) + "'", 0, scriptExecutionContext()->securityOrigin()->toString());
+        scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Wrong protocol for WebSocket '" + encodeProtocolString(m_protocol) + "'", 0, scriptExecutionContext()->securityOrigin()->toString(), 0);
         m_state = CLOSED;
         ec = SYNTAX_ERR;
         return;
     }
     if (!portAllowed(url)) {
-        scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, makeString("WebSocket port ", String::number(url.port()), " blocked"), 0, scriptExecutionContext()->securityOrigin()->toString());
+        scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, makeString("WebSocket port ", String::number(url.port()), " blocked"), 0, scriptExecutionContext()->securityOrigin()->toString(), 0);
         m_state = CLOSED;
         ec = SECURITY_ERR;
         return;
index 09fcd6b5e609071b0e37b65b185f8a07e0d0d867..c4cb2e2043934426e269fd267cd3c16bfc14a633 100644 (file)
@@ -41,6 +41,7 @@
 #include "Page.h"
 #include "PlatformString.h"
 #include "ProgressTracker.h"
+#include "ScriptCallStack.h"
 #include "ScriptExecutionContext.h"
 #include "SocketStreamError.h"
 #include "SocketStreamHandle.h"
@@ -155,7 +156,7 @@ void WebSocketChannel::didOpen(SocketStreamHandle* handle)
         InspectorInstrumentation::willSendWebSocketHandshakeRequest(m_context, m_identifier, m_handshake.clientHandshakeRequest());
     CString handshakeMessage = m_handshake.clientHandshakeMessage();
     if (!handle->send(handshakeMessage.data(), handshakeMessage.length())) {
-        m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error sending handshake message.", 0, m_handshake.clientOrigin());
+        m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error sending handshake message.", 0, m_handshake.clientOrigin(), 0);
         handle->close();
     }
 }
@@ -218,7 +219,7 @@ void WebSocketChannel::didFail(SocketStreamHandle* handle, const SocketStreamErr
             message = makeString("WebSocket network error: error code ", String::number(error.errorCode()));
         else
             message = makeString("WebSocket network error: ", error.localizedDescription());
-        m_context->addMessage(OtherMessageSource, NetworkErrorMessageType, ErrorMessageLevel, message, 0, error.failingURL());
+        m_context->addMessage(OtherMessageSource, NetworkErrorMessageType, ErrorMessageLevel, message, 0, error.failingURL(), 0);
     }
     m_shouldDiscardReceivedData = true;
     handle->close();
@@ -249,7 +250,7 @@ bool WebSocketChannel::appendToBuffer(const char* data, size_t len)
         m_bufferSize = newBufferSize;
         return true;
     }
-    m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, makeString("WebSocket frame (at ", String::number(static_cast<unsigned long>(newBufferSize)), " bytes) is too long."), 0, m_handshake.clientOrigin());
+    m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, makeString("WebSocket frame (at ", String::number(static_cast<unsigned long>(newBufferSize)), " bytes) is too long."), 0, m_handshake.clientOrigin(), 0);
     return false;
 }
 
index 9506ad4476b0fc6e493e0fe341e9508ba77ad03c..f65341580eef31fc77699c2af7d824e46ecad5f3 100644 (file)
@@ -42,6 +42,7 @@
 #include "HTTPHeaderMap.h"
 #include "KURL.h"
 #include "Logging.h"
+#include "ScriptCallStack.h"
 #include "ScriptExecutionContext.h"
 #include "SecurityOrigin.h"
 
@@ -320,7 +321,7 @@ int WebSocketHandshake::readServerHandshake(const char* header, size_t len)
     m_response.setStatusText(statusText);
     if (statusCode != 101) {
         m_mode = Failed;
-        m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, makeString("Unexpected response code: ", String::number(statusCode)), 0, clientOrigin());
+        m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, makeString("Unexpected response code: ", String::number(statusCode)), 0, clientOrigin(), 0);
         return len;
     }
     m_mode = Normal;
@@ -450,7 +451,7 @@ int WebSocketHandshake::readStatusLine(const char* header, size_t headerLength,
             // The caller isn't prepared to deal with null bytes in status
             // line. WebSockets specification doesn't prohibit this, but HTTP
             // does, so we'll just treat this as an error. 
-            m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Status line contains embedded null", 0, clientOrigin());
+            m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Status line contains embedded null", 0, clientOrigin(), 0);
             return p + 1 - header;
         } else if (*p == '\n')
             break;
@@ -460,19 +461,19 @@ int WebSocketHandshake::readStatusLine(const char* header, size_t headerLength,
 
     const char* end = p + 1;
     if (end - header > maximumLength) {
-        m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Status line is too long", 0, clientOrigin());
+        m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Status line is too long", 0, clientOrigin(), 0);
         return maximumLength;
     }
     int lineLength = end - header;
 
     if (!space1 || !space2) {
-        m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "No response code found: " + trimConsoleMessage(header, lineLength - 1), 0, clientOrigin());
+        m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "No response code found: " + trimConsoleMessage(header, lineLength - 1), 0, clientOrigin(), 0);
         return lineLength;
     }
 
     // The line must end with "\r\n".
     if (*(end - 2) != '\r') {
-        m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Status line does not end with CRLF", 0, clientOrigin());
+        m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Status line does not end with CRLF", 0, clientOrigin(), 0);
         return lineLength;
     }
 
@@ -481,7 +482,7 @@ int WebSocketHandshake::readStatusLine(const char* header, size_t headerLength,
         return lineLength;
     for (int i = 0; i < 3; ++i)
         if (statusCodeString[i] < '0' || statusCodeString[i] > '9') {
-            m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Invalid status code: " + statusCodeString, 0, clientOrigin());
+            m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Invalid status code: " + statusCodeString, 0, clientOrigin(), 0);
             return lineLength;
         }
 
@@ -509,13 +510,13 @@ const char* WebSocketHandshake::readHTTPHeaders(const char* start, const char* e
                 if (name.isEmpty()) {
                     if (p + 1 < end && *(p + 1) == '\n')
                         return p + 2;
-                    m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "CR doesn't follow LF at " + trimConsoleMessage(p, end - p), 0, clientOrigin());
+                    m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "CR doesn't follow LF at " + trimConsoleMessage(p, end - p), 0, clientOrigin(), 0);
                     return 0;
                 }
-                m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Unexpected CR in name at " + trimConsoleMessage(name.data(), name.size()), 0, clientOrigin());
+                m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Unexpected CR in name at " + trimConsoleMessage(name.data(), name.size()), 0, clientOrigin(), 0);
                 return 0;
             case '\n':
-                m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Unexpected LF in name at " + trimConsoleMessage(name.data(), name.size()), 0, clientOrigin());
+                m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Unexpected LF in name at " + trimConsoleMessage(name.data(), name.size()), 0, clientOrigin(), 0);
                 return 0;
             case ':':
                 break;
@@ -536,7 +537,7 @@ const char* WebSocketHandshake::readHTTPHeaders(const char* start, const char* e
             case '\r':
                 break;
             case '\n':
-                m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Unexpected LF in value at " + trimConsoleMessage(value.data(), value.size()), 0, clientOrigin());
+                m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Unexpected LF in value at " + trimConsoleMessage(value.data(), value.size()), 0, clientOrigin(), 0);
                 return 0;
             default:
                 value.append(*p);
@@ -547,17 +548,17 @@ const char* WebSocketHandshake::readHTTPHeaders(const char* start, const char* e
             }
         }
         if (p >= end || *p != '\n') {
-            m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "CR doesn't follow LF after value at " + trimConsoleMessage(p, end - p), 0, clientOrigin());
+            m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "CR doesn't follow LF after value at " + trimConsoleMessage(p, end - p), 0, clientOrigin(), 0);
             return 0;
         }
         AtomicString nameStr(String::fromUTF8(name.data(), name.size()));
         String valueStr = String::fromUTF8(value.data(), value.size());
         if (nameStr.isNull()) {
-            m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "invalid UTF-8 sequence in header name", 0, clientOrigin());
+            m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "invalid UTF-8 sequence in header name", 0, clientOrigin(), 0);
             return 0;
         }
         if (valueStr.isNull()) {
-            m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "invalid UTF-8 sequence in header value", 0, clientOrigin());
+            m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "invalid UTF-8 sequence in header value", 0, clientOrigin(), 0);
             return 0;
         }
         LOG(Network, "name=%s value=%s", nameStr.string().utf8().data(), valueStr.utf8().data());
@@ -581,24 +582,24 @@ void WebSocketHandshake::processHeaders()
 bool WebSocketHandshake::checkResponseHeaders()
 {
     if (m_wsOrigin.isNull()) {
-        m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error during WebSocket handshake: 'sec-websocket-origin' header is missing", 0, clientOrigin());
+        m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error during WebSocket handshake: 'sec-websocket-origin' header is missing", 0, clientOrigin(), 0);
         return false;
     }
     if (m_wsLocation.isNull()) {
-        m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error during WebSocket handshake: 'sec-websocket-location' header is missing", 0, clientOrigin());
+        m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error during WebSocket handshake: 'sec-websocket-location' header is missing", 0, clientOrigin(), 0);
         return false;
     }
 
     if (clientOrigin() != m_wsOrigin) {
-        m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error during WebSocket handshake: origin mismatch: " + clientOrigin() + " != " + m_wsOrigin, 0, clientOrigin());
+        m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error during WebSocket handshake: origin mismatch: " + clientOrigin() + " != " + m_wsOrigin, 0, clientOrigin(), 0);
         return false;
     }
     if (clientLocation() != m_wsLocation) {
-        m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error during WebSocket handshake: location mismatch: " + clientLocation() + " != " + m_wsLocation, 0, clientOrigin());
+        m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error during WebSocket handshake: location mismatch: " + clientLocation() + " != " + m_wsLocation, 0, clientOrigin(), 0);
         return false;
     }
     if (!m_clientProtocol.isEmpty() && m_clientProtocol != m_wsProtocol) {
-        m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error during WebSocket handshake: protocol mismatch: " + m_clientProtocol + " != " + m_wsProtocol, 0, clientOrigin());
+        m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error during WebSocket handshake: protocol mismatch: " + m_clientProtocol + " != " + m_wsProtocol, 0, clientOrigin(), 0);
         return false;
     }
     return true;
index 3a14b62de5c275dc1951bc549cc0d9f9e915b2bd..c20cd30c1d46775c01a5479d6c38ea7f69efaecb 100644 (file)
@@ -42,6 +42,7 @@
 #include "MessagePort.h"
 #include "NotImplemented.h"
 #include "PlatformString.h"
+#include "ScriptCallStack.h"
 #include "SecurityOrigin.h"
 #include "SecurityOriginHash.h"
 #include "SharedWorker.h"
@@ -155,7 +156,7 @@ void SharedWorkerProxy::postTaskForModeToWorkerContext(PassOwnPtr<ScriptExecutio
 
 static void postExceptionTask(ScriptExecutionContext* context, const String& errorMessage, int lineNumber, const String& sourceURL)
 {
-    context->reportException(errorMessage, lineNumber, sourceURL);
+    context->reportException(errorMessage, lineNumber, sourceURL, 0);
 }
 
 void SharedWorkerProxy::postExceptionToWorkerObject(const String& errorMessage, int lineNumber, const String& sourceURL)
@@ -167,7 +168,7 @@ void SharedWorkerProxy::postExceptionToWorkerObject(const String& errorMessage,
 
 static void postConsoleMessageTask(ScriptExecutionContext* document, MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL)
 {
-    document->addMessage(source, type, level, message, lineNumber, sourceURL);
+    document->addMessage(source, type, level, message, lineNumber, sourceURL, 0);
 }
 
 void SharedWorkerProxy::postConsoleMessageToWorkerObject(MessageSource source, MessageType type, MessageLevel level, const String& message, int lineNumber, const String& sourceURL)
index d5d1ccc3ff526f96bbdaf8f3f91e193f5ca279d7..36c42154a7d5886b36893c103940cb0af94a1c8c 100644 (file)
@@ -47,6 +47,7 @@
 #include "KURL.h"
 #include "MessagePort.h"
 #include "NotImplemented.h"
+#include "ScriptCallStack.h"
 #include "ScriptSourceCode.h"
 #include "ScriptValue.h"
 #include "SecurityOrigin.h"
@@ -103,7 +104,6 @@ WorkerContext::WorkerContext(const KURL& url, const String& userAgent, WorkerThr
     , m_script(new WorkerScriptController(this))
     , m_thread(thread)
     , m_closing(false)
-    , m_reportingException(false)
 {
     setSecurityOrigin(SecurityOrigin::create(url));
 }
@@ -257,23 +257,17 @@ void WorkerContext::importScripts(const Vector<String>& urls, ExceptionCode& ec)
     }
 }
 
-void WorkerContext::reportException(const String& errorMessage, int lineNumber, const String& sourceURL)
+EventTarget* WorkerContext::errorEventTarget()
 {
-    bool errorHandled = false;
-    if (!m_reportingException) {
-        if (onerror()) {
-            m_reportingException = true;
-            RefPtr<ErrorEvent> errorEvent(ErrorEvent::create(errorMessage, sourceURL, lineNumber));
-            onerror()->handleEvent(this, errorEvent.get());
-            errorHandled = errorEvent->defaultPrevented();
-            m_reportingException = false;
-        }
-    }
-    if (!errorHandled)
-        thread()->workerReportingProxy().postExceptionToWorkerObject(errorMessage, lineNumber, sourceURL);
+    return this;
+}
+
+void WorkerContext::logExceptionToConsole(const String& errorMessage, int lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>)
+{
+    thread()->workerReportingProxy().postExceptionToWorkerObject(errorMessage, lineNumber, sourceURL);
 }
 
-void WorkerContext::addMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL)
+void WorkerContext::addMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>)
 {
     thread()->workerReportingProxy().postConsoleMessageToWorkerObject(source, type, level, message, lineNumber, sourceURL);
 }
index a0dbaae829049900e47c4a6397b76f38f213f280..ae370e09f5fc0b5a43b04e5f504e47dea0076aad 100644 (file)
@@ -101,8 +101,7 @@ namespace WebCore {
         void clearInterval(int timeoutId);
 
         // ScriptExecutionContext
-        virtual void reportException(const String& errorMessage, int lineNumber, const String& sourceURL);
-        virtual void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL);
+        virtual void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>);
 
 #if ENABLE(NOTIFICATIONS)
         NotificationCenter* webkitNotifications() const;
@@ -174,6 +173,9 @@ namespace WebCore {
         virtual const KURL& virtualURL() const;
         virtual KURL virtualCompleteURL(const String&) const;
 
+        virtual EventTarget* errorEventTarget();
+        virtual void logExceptionToConsole(const String& errorMessage, int lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>);
+
         KURL m_url;
         String m_userAgent;
 
@@ -190,7 +192,6 @@ namespace WebCore {
         mutable RefPtr<DOMURL> m_domURL;
 #endif
         bool m_closing;
-        bool m_reportingException;
         EventTargetData m_eventTargetData;
 
         HashSet<Observer*> m_workerObservers;
index e89ccb41f6b19ba3bab03a4ea7f18952ee46052c..eca8e2e722e6fd18464d20221258a0d791b752f9 100644 (file)
@@ -39,6 +39,7 @@
 #include "ErrorEvent.h"
 #include "ExceptionCode.h"
 #include "MessageEvent.h"
+#include "ScriptCallStack.h"
 #include "ScriptExecutionContext.h"
 #include "Worker.h"
 
@@ -130,7 +131,7 @@ private:
 
         bool errorHandled = !workerObject->dispatchEvent(ErrorEvent::create(m_errorMessage, m_sourceURL, m_lineNumber));
         if (!errorHandled)
-            context->reportException(m_errorMessage, m_lineNumber, m_sourceURL);
+            context->reportException(m_errorMessage, m_lineNumber, m_sourceURL, 0);
     }
 
     String m_errorMessage;
@@ -282,7 +283,7 @@ static void postConsoleMessageTask(ScriptExecutionContext* context, WorkerMessag
 {
     if (messagingProxy->askedToTerminate())
         return;
-    context->addMessage(source, type, level, message, lineNumber, sourceURL);
+    context->addMessage(source, type, level, message, lineNumber, sourceURL, 0);
 }
 
 void WorkerMessagingProxy::postConsoleMessageToWorkerObject(MessageSource source, MessageType type, MessageLevel level, const String& message, int lineNumber, const String& sourceURL)
index ee9e20f112e789823f8dadac83dd82aabe936af1..48a4f7f181a8ef6fce0cbfcbb60864e80b1d1351 100644 (file)
@@ -38,6 +38,7 @@
 #include "InspectorInstrumentation.h"
 #include "ResourceError.h"
 #include "ResourceRequest.h"
+#include "ScriptCallStack.h"
 #include "SecurityOrigin.h"
 #include "Settings.h"
 #include "SharedBuffer.h"
@@ -806,7 +807,7 @@ static void reportUnsafeUsage(ScriptExecutionContext* context, const String& mes
         return;
     // FIXME: It's not good to report the bad usage without indicating what source line it came from.
     // We should pass additional parameters so we can tell the console where the mistake occurred.
-    context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, message, 1, String());
+    context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, message, 1, String(), 0);
 }
 
 void XMLHttpRequest::setRequestHeader(const AtomicString& name, const String& value, ExceptionCode& ec)
index e81736f8d8c18ad133090700b85662858b460c9d..27afde93a1167cd1eb498dfb8da46fa2e4027a3c 100644 (file)
@@ -1,3 +1,39 @@
+2010-12-27  Yury Semikhatsky  <yurys@chromium.org>
+
+        Reviewed by Pavel Feldman.
+
+        WebCore doesn't fire window.onerror event when uncaught JavaScript exceptions are thrown
+        https://bugs.webkit.org/show_bug.cgi?id=8519
+
+        Uncaught exceptions are propagated to window.onerror hander if one is present.
+        The handler is expected to be a function accepting three arguments: error message,
+        resource url and line number where the exception occured.
+
+        It was decided to dispatch ErrorEvent to all listeners/handlers no matter if they
+        were created in the same isolated world where the exception occured or not.
+
+        Tests: fast/events/window-onerror1.html
+               fast/events/window-onerror10.html
+               fast/events/window-onerror11.html
+               fast/events/window-onerror12.html
+               fast/events/window-onerror2.html
+               fast/events/window-onerror3.html
+               fast/events/window-onerror4.html
+               fast/events/window-onerror5.html
+               fast/events/window-onerror6.html
+               fast/events/window-onerror7.html
+               fast/events/window-onerror8.html
+               fast/events/window-onerror9.html
+               http/tests/security/window-onerror-exception-in-iframe.html
+               userscripts/window-onerror-for-isolated-world-1.html
+               userscripts/window-onerror-for-isolated-world-2.html
+
+        * src/WebWorkerClientImpl.cpp:
+        (WebKit::WebWorkerClientImpl::postExceptionToWorkerObject):
+        (WebKit::WebWorkerClientImpl::postConsoleMessageToWorkerObject):
+        (WebKit::WebWorkerClientImpl::postExceptionToWorkerObjectTask):
+        (WebKit::WebWorkerClientImpl::postConsoleMessageToWorkerObjectTask):
+
 2011-01-19  Dmitry Titov  <dimich@chromium.org>
 
         [Chromium] Unreviewed, build fix.
index 18282e3416b73de2ecd04632d6bce752fdd329a6..f90e7e8ad0211f4a217ffa79aff091024f6b0c6b 100644 (file)
@@ -41,6 +41,7 @@
 #include "MessageEvent.h"
 #include "MessagePort.h"
 #include "MessagePortChannel.h"
+#include "ScriptCallStack.h"
 #include "ScriptExecutionContext.h"
 #include "Worker.h"
 #include "WorkerContext.h"
@@ -247,7 +248,7 @@ void WebWorkerClientImpl::postExceptionToWorkerObject(const WebString& errorMess
                                                                 sourceURL,
                                                                 lineNumber));
     if (unhandled)
-        m_scriptExecutionContext->reportException(errorMessage, lineNumber, sourceURL);
+        m_scriptExecutionContext->reportException(errorMessage, lineNumber, sourceURL, 0);
 }
 
 void WebWorkerClientImpl::postConsoleMessageToWorkerObject(int destination,
@@ -274,7 +275,7 @@ void WebWorkerClientImpl::postConsoleMessageToWorkerObject(int destination,
                                          static_cast<MessageType>(messageType),
                                          static_cast<MessageLevel>(messageLevel),
                                          String(message), lineNumber,
-                                         String(sourceURL));
+                                         String(sourceURL), 0);
 }
 
 void WebWorkerClientImpl::postConsoleMessageToWorkerObject(int sourceId,
@@ -381,9 +382,7 @@ void WebWorkerClientImpl::postExceptionToWorkerObjectTask(
                                                                       sourceURL,
                                                                       lineNumber));
     if (!handled)
-        thisPtr->m_scriptExecutionContext->reportException(errorMessage,
-                                                           lineNumber,
-                                                           sourceURL);
+        thisPtr->m_scriptExecutionContext->reportException(errorMessage, lineNumber, sourceURL, 0);
 }
 
 void WebWorkerClientImpl::postConsoleMessageToWorkerObjectTask(ScriptExecutionContext* context,
@@ -398,8 +397,7 @@ void WebWorkerClientImpl::postConsoleMessageToWorkerObjectTask(ScriptExecutionCo
     thisPtr->m_scriptExecutionContext->addMessage(static_cast<MessageSource>(sourceId),
                                                   static_cast<MessageType>(messageType),
                                                   static_cast<MessageLevel>(messageLevel),
-                                                  message, lineNumber,
-                                                  sourceURL);
+                                                  message, lineNumber, sourceURL, 0);
 }
 
 void WebWorkerClientImpl::confirmMessageFromWorkerObjectTask(ScriptExecutionContext* context,