Changeset 73914 in webkit


Ignore:
Timestamp:
Dec 13, 2010 7:16:03 AM (13 years ago)
Author:
yurys@chromium.org
Message:

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

Reviewed by Adam Barth.

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-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.
  • 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.

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

Reviewed by Adam Barth.

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-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/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/V8WindowErrorHandler.cpp: Copied from WebCore/bindings/js/JSWorkerContextErrorHandler.h. (WebCore::V8WindowErrorHandler::V8WindowErrorHandler): (WebCore::V8WindowErrorHandler::callListenerFunction):
  • bindings/v8/V8WindowErrorHandler.h: Renamed from WebCore/bindings/js/JSWorkerContextErrorHandler.h. (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):
  • dom/Document.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:
  • workers/DefaultSharedWorkerRepository.cpp: (WebCore::postExceptionTask):
  • workers/WorkerContext.cpp: (WebCore::WorkerContext::WorkerContext): (WebCore::WorkerContext::errorEventTarget): (WebCore::WorkerContext::logExceptionToConsole):
  • workers/WorkerContext.h:
  • workers/WorkerMessagingProxy.cpp: (WebCore::WorkerExceptionTask::performTask):

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

Reviewed by Adam Barth.

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.

  • src/WebWorkerClientImpl.cpp: (WebKit::WebWorkerClientImpl::postExceptionToWorkerObject): (WebKit::WebWorkerClientImpl::postExceptionToWorkerObjectTask):
Location:
trunk
Files:
45 added
35 edited
2 copied
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r73913 r73914  
     12010-12-13  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        WebCore doesn't fire window.onerror event when uncaught JavaScript exceptions are thrown
     6        https://bugs.webkit.org/show_bug.cgi?id=8519
     7
     8        Uncaught exceptions are propagated to window.onerror hander if one is present.
     9        The handler is expected to be a function accepting three arguments: error message,
     10        resource url and line number where the exception occured.
     11
     12        * fast/events/resources/window-onerror.js: Added.
     13        (throwException):
     14        * fast/events/window-onerror1-expected.txt: Added.
     15        * fast/events/window-onerror1.html: Added.
     16        * fast/events/window-onerror10-expected.txt: Added.
     17        * fast/events/window-onerror10.html: Added.
     18        * fast/events/window-onerror11-expected.txt: Added.
     19        * fast/events/window-onerror11.html: Added.
     20        * fast/events/window-onerror2-expected.txt: Added.
     21        * fast/events/window-onerror2.html: Added.
     22        * fast/events/window-onerror3-expected.txt: Added.
     23        * fast/events/window-onerror3.html: Added.
     24        * fast/events/window-onerror4-expected.txt: Added.
     25        * fast/events/window-onerror4.html: Added.
     26        * fast/events/window-onerror5-expected.txt: Added.
     27        * fast/events/window-onerror5.html: Added.
     28        * fast/events/window-onerror6-expected.txt: Added.
     29        * fast/events/window-onerror6.html: Added.
     30        * fast/events/window-onerror7-expected.txt: Added.
     31        * fast/events/window-onerror7.html: Added.
     32        * fast/events/window-onerror8-expected.txt: Added.
     33        * fast/events/window-onerror8.html: Added.
     34        * fast/events/window-onerror9-expected.txt: Added.
     35        * fast/events/window-onerror9.html: Added.
     36        * fast/workers/worker-script-error-expected.txt:
     37        * http/tests/security/resources/onerror-iframe.html: Added.
     38        * http/tests/security/window-onerror-exception-in-iframe-expected.txt: Added.
     39        * http/tests/security/window-onerror-exception-in-iframe.html: Added.
     40        * platform/chromium-win/fast/workers/worker-script-error-expected.txt:
     41        * platform/chromium/fast/events/window-onerror1-expected.txt: Added.
     42        * platform/chromium/fast/events/window-onerror10-expected.txt: Added.
     43        * platform/chromium/fast/events/window-onerror11-expected.txt: Added.
     44        * platform/chromium/fast/events/window-onerror2-expected.txt: Added.
     45        * platform/chromium/fast/events/window-onerror3-expected.txt: Added.
     46        * platform/chromium/fast/events/window-onerror4-expected.txt: Added.
     47        * platform/chromium/fast/events/window-onerror5-expected.txt: Added.
     48        * platform/chromium/fast/events/window-onerror6-expected.txt: Added.
     49        * platform/chromium/fast/events/window-onerror7-expected.txt: Added.
     50        * platform/chromium/fast/events/window-onerror8-expected.txt: Added.
     51        * platform/chromium/fast/events/window-onerror9-expected.txt: Added.
     52        * platform/chromium/http/tests/security/window-onerror-exception-in-iframe-expected.txt: Added.
     53        * platform/chromium/userscripts/window-onerror-for-isolated-world-1-expected.txt: Added.
     54        * platform/chromium/userscripts/window-onerror-for-isolated-world-2-expected.txt: Added.
     55        * userscripts/window-onerror-for-isolated-world-1-expected.txt: Added.
     56        * userscripts/window-onerror-for-isolated-world-1.html: Added.
     57        * userscripts/window-onerror-for-isolated-world-2-expected.txt: Added.
     58        * userscripts/window-onerror-for-isolated-world-2.html: Added.
     59
    1602010-12-08  Alexander Pavlov  <apavlov@chromium.org>
    261
  • trunk/LayoutTests/fast/workers/worker-script-error-expected.txt

    r57134 r73914  
    55PASS: onerror invoked for a script that has script error 'ReferenceError: Can't find variable: foo' at line 1.
    66PASS: event listener invoked for a script that has script error 'ReferenceError: Can't find variable: foo' at line 1.
     7PASS: onerror invoked for a script that has script error 'ReferenceError: Can't find variable: foo' at line 7.
    78PASS: onerror invoked for a script that has script error 'ReferenceError: Can't find variable: bar' at line 3.
    8 PASS: onerror invoked for a script that has script error 'ReferenceError: Can't find variable: foo' at line 7.
    99PASS: onerror invoked for a script that has script error 'ReferenceError: Can't find variable: foo' at line 7.
    1010PASS: onerror invoked for a script that has script error 'ReferenceError: Can't find variable: foo' at line 7.
  • trunk/LayoutTests/platform/chromium-win/fast/workers/worker-script-error-expected.txt

    r57147 r73914  
    44PASS: onerror invoked for a script that has script error 'Uncaught ReferenceError: foo is not defined' at line 1.
    55PASS: event listener invoked for a script that has script error 'Uncaught ReferenceError: foo is not defined' at line 1.
     6PASS: onerror invoked for a script that has script error 'Uncaught ReferenceError: foo is not defined' at line 7.
    67PASS: onerror invoked for a script that has script error 'Uncaught ReferenceError: bar is not defined' at line 3.
    7 PASS: onerror invoked for a script that has script error 'Uncaught ReferenceError: foo is not defined' at line 7.
    88PASS: onerror invoked for a script that has script error 'Uncaught ReferenceError: foo is not defined' at line 7.
    99PASS: onerror invoked for a script that has script error 'Uncaught ReferenceError: foo is not defined' at line 7.
  • trunk/LayoutTests/platform/gtk/Skipped

    r73886 r73914  
    47104710userscripts/user-script-video-document.html
    47114711userscripts/user-style-top-frame-only.html
     4712userscripts/window-onerror-for-isolated-world-1.html
     4713userscripts/window-onerror-for-isolated-world-2.html
    47124714
    47134715# XHR sends sometimes yield null bytes sent instead of 0.
  • trunk/WebCore/Android.jscbindings.mk

    r72590 r73914  
    103103        bindings/js/JSDocumentCustom.cpp \
    104104        bindings/js/JSElementCustom.cpp \
     105        bindings/js/JSErrorHandler.cpp \
    105106        bindings/js/JSEventCustom.cpp \
    106107        bindings/js/JSEventListener.cpp \
     
    171172        bindings/js/JSWorkerContextBase.cpp \
    172173        bindings/js/JSWorkerContextCustom.cpp \
    173         bindings/js/JSWorkerContextErrorHandler.cpp \
    174174        bindings/js/JSWorkerCustom.cpp \
    175175        bindings/js/JSXMLHttpRequestCustom.cpp \
  • trunk/WebCore/CMakeLists.txt

    r73886 r73914  
    635635    bindings/js/JSDocumentCustom.cpp
    636636    bindings/js/JSElementCustom.cpp
     637    bindings/js/JSErrorHandler.cpp
    637638    bindings/js/JSEventCustom.cpp
    638639    bindings/js/JSEventListener.cpp
     
    704705    bindings/js/JSWorkerContextBase.cpp
    705706    bindings/js/JSWorkerContextCustom.cpp
    706     bindings/js/JSWorkerContextErrorHandler.cpp
    707707    bindings/js/JSWorkerCustom.cpp
    708708    bindings/js/JSXMLHttpRequestCustom.cpp
  • trunk/WebCore/ChangeLog

    r73913 r73914  
     12010-12-13  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        WebCore doesn't fire window.onerror event when uncaught JavaScript exceptions are thrown
     6        https://bugs.webkit.org/show_bug.cgi?id=8519
     7
     8        Uncaught exceptions are propagated to window.onerror hander if one is present.
     9        The handler is expected to be a function accepting three arguments: error message,
     10        resource url and line number where the exception occured.
     11
     12        It was decided to dispatch ErrorEvent to all listeners/handlers no matter if they
     13        were created in the same isolated world where the exception occured or not.
     14
     15        Tests: fast/events/window-onerror1.html
     16               fast/events/window-onerror10.html
     17               fast/events/window-onerror11.html
     18               fast/events/window-onerror2.html
     19               fast/events/window-onerror3.html
     20               fast/events/window-onerror4.html
     21               fast/events/window-onerror5.html
     22               fast/events/window-onerror6.html
     23               fast/events/window-onerror7.html
     24               fast/events/window-onerror8.html
     25               fast/events/window-onerror9.html
     26               http/tests/security/window-onerror-exception-in-iframe.html
     27               userscripts/window-onerror-for-isolated-world-1.html
     28               userscripts/window-onerror-for-isolated-world-2.html
     29
     30        * Android.jscbindings.mk:
     31        * CMakeLists.txt:
     32        * GNUmakefile.am:
     33        * WebCore.gypi:
     34        * WebCore.order:
     35        * WebCore.pro:
     36        * WebCore.vcproj/WebCore.vcproj:
     37        * WebCore.xcodeproj/project.pbxproj:
     38        * bindings/js/JSBindingsAllInOne.cpp:
     39        * bindings/js/JSDOMBinding.cpp:
     40        (WebCore::reportException):
     41        * bindings/js/JSErrorHandler.cpp: Renamed from WebCore/bindings/js/JSWorkerContextErrorHandler.cpp.
     42        (WebCore::JSErrorHandler::JSErrorHandler):
     43        (WebCore::JSErrorHandler::~JSErrorHandler):
     44        (WebCore::JSErrorHandler::handleEvent):
     45        * bindings/js/JSErrorHandler.h: Copied from WebCore/bindings/js/JSWorkerContextErrorHandler.h.
     46        (WebCore::JSErrorHandler::create):
     47        (WebCore::createJSErrorHandler):
     48        * bindings/scripts/CodeGeneratorJS.pm:
     49        * bindings/scripts/CodeGeneratorV8.pm:
     50        * bindings/v8/V8ConsoleMessage.cpp:
     51        (WebCore::V8ConsoleMessage::dispatchNow):
     52        (WebCore::V8ConsoleMessage::handler): the method was changed to use generic WebCore exception
     53        reporting mechanism which is also used by JSC bindings.
     54        * bindings/v8/V8ConsoleMessage.h:
     55        * bindings/v8/V8WindowErrorHandler.cpp: Copied from WebCore/bindings/js/JSWorkerContextErrorHandler.h.
     56        (WebCore::V8WindowErrorHandler::V8WindowErrorHandler):
     57        (WebCore::V8WindowErrorHandler::callListenerFunction):
     58        * bindings/v8/V8WindowErrorHandler.h: Renamed from WebCore/bindings/js/JSWorkerContextErrorHandler.h.
     59        (WebCore::V8WindowErrorHandler::create):
     60        * bindings/v8/WorkerContextExecutionProxy.cpp:
     61        (WebCore::v8MessageHandler):
     62        * bindings/v8/WorkerScriptController.cpp:
     63        (WebCore::WorkerScriptController::evaluate):
     64        * dom/Document.cpp:
     65        (WebCore::Document::errorEventTarget):
     66        (WebCore::Document::logExceptionToConsole):
     67        * dom/Document.h:
     68        * dom/ScriptExecutionContext.cpp:
     69        (WebCore::ScriptExecutionContext::PendingException::PendingException):
     70        (WebCore::ScriptExecutionContext::ScriptExecutionContext):
     71        (WebCore::ScriptExecutionContext::reportException): this method is not virtual anymore to
     72        ensure that error event dispatching algorithm is the same in WorkerContext and in Document.
     73        (WebCore::ScriptExecutionContext::dispatchErrorEvent):
     74        * dom/ScriptExecutionContext.h:
     75        * workers/DefaultSharedWorkerRepository.cpp:
     76        (WebCore::postExceptionTask):
     77        * workers/WorkerContext.cpp:
     78        (WebCore::WorkerContext::WorkerContext):
     79        (WebCore::WorkerContext::errorEventTarget):
     80        (WebCore::WorkerContext::logExceptionToConsole):
     81        * workers/WorkerContext.h:
     82        * workers/WorkerMessagingProxy.cpp:
     83        (WebCore::WorkerExceptionTask::performTask):
     84
    1852010-12-08  Alexander Pavlov  <apavlov@chromium.org>
    286
  • trunk/WebCore/GNUmakefile.am

    r73886 r73914  
    774774        WebCore/bindings/js/JSEntryCustom.cpp \
    775775        WebCore/bindings/js/JSEntrySyncCustom.cpp \
     776        WebCore/bindings/js/JSErrorHandler.cpp \
     777        WebCore/bindings/js/JSErrorHandler.h \
    776778        WebCore/bindings/js/JSEventCustom.cpp \
    777779        WebCore/bindings/js/JSEventListener.cpp \
     
    871873        WebCore/bindings/js/JSWorkerContextBase.h \
    872874        WebCore/bindings/js/JSWorkerContextCustom.cpp \
    873         WebCore/bindings/js/JSWorkerContextErrorHandler.cpp \
    874         WebCore/bindings/js/JSWorkerContextErrorHandler.h \
    875875        WebCore/bindings/js/JSWorkerCustom.cpp \
    876876        WebCore/bindings/js/JSXMLHttpRequestCustom.cpp \
  • trunk/WebCore/WebCore.gypi

    r73886 r73914  
    626626            'bindings/js/JSEntryCustom.cpp',
    627627            'bindings/js/JSEntrySyncCustom.cpp',
     628            'bindings/js/JSErrorHandler.cpp',
     629            'bindings/js/JSErrorHandler.h',
    628630            'bindings/js/JSEventCustom.cpp',
    629631            'bindings/js/JSEventListener.cpp',
     
    723725            'bindings/js/JSWorkerContextBase.h',
    724726            'bindings/js/JSWorkerContextCustom.cpp',
    725             'bindings/js/JSWorkerContextErrorHandler.cpp',
    726             'bindings/js/JSWorkerContextErrorHandler.h',
    727727            'bindings/js/JSWorkerCustom.cpp',
    728728            'bindings/js/JSXMLHttpRequestCustom.cpp',
     
    987987            'bindings/v8/V8Utilities.cpp',
    988988            'bindings/v8/V8Utilities.h',
     989            'bindings/v8/V8WindowErrorHandler.cpp',
     990            'bindings/v8/V8WindowErrorHandler.h',
    989991            'bindings/v8/V8WorkerContextErrorHandler.cpp',
    990992            'bindings/v8/V8WorkerContextErrorHandler.h',
  • trunk/WebCore/WebCore.order

    r73121 r73914  
    2521025210__ZN7WebCore17WorkerSharedTimer11setFireTimeEd
    2521125211__ZN7WebCore15ScheduledAction7executeEPNS_13WorkerContextE
    25212 __ZN7WebCore27JSWorkerContextErrorHandlerC1EPN3JSC8JSObjectES3_bPNS_15DOMWrapperWorldE
    25213 __ZN7WebCore27JSWorkerContextErrorHandlerC2EPN3JSC8JSObjectES3_bPNS_15DOMWrapperWorldE
    2521425212__ZN7WebCore10ErrorEventC1ERKNS_6StringES3_j
    2521525213__ZN7WebCore10ErrorEventC2ERKNS_6StringES3_j
    25216 __ZN7WebCore27JSWorkerContextErrorHandler11handleEventEPNS_22ScriptExecutionContextEPNS_5EventE
    2521725214__ZN7WebCore10ErrorEventD0Ev
    25218 __ZN7WebCore27JSWorkerContextErrorHandlerD0Ev
    2521925215__ZN7WebCore17jsWorkerOnmessageEPN3JSC9ExecStateENS0_7JSValueERKNS0_10IdentifierE
    2522025216__ZN7WebCore34jsWorkerPrototypeFunctionTerminateEPN3JSC9ExecStateEPNS0_8JSObjectENS0_7JSValueERKNS0_7ArgListE
  • trunk/WebCore/WebCore.pro

    r73892 r73914  
    386386        bindings/v8/V8Proxy.cpp \
    387387        bindings/v8/V8Utilities.cpp \
     388        bindings/v8/V8WindowErrorHandler.cpp \
    388389        bindings/v8/V8WorkerContextEventListener.cpp \
    389390        bindings/v8/WorkerContextExecutionProxy.cpp \
     
    530531        bindings/js/JSDocumentCustom.cpp \
    531532        bindings/js/JSElementCustom.cpp \
     533        bindings/js/JSErrorHandler.cpp \
    532534        bindings/js/JSEventCustom.cpp \
    533535        bindings/js/JSEventListener.cpp \
     
    589591        bindings/js/JSWebKitCSSMatrixCustom.cpp \
    590592        bindings/js/JSWebKitPointCustom.cpp \
    591         bindings/js/JSWorkerContextErrorHandler.cpp \
    592593        bindings/js/JSXMLHttpRequestCustom.cpp \
    593594        bindings/js/JSXMLHttpRequestUploadCustom.cpp \
     
    14611462        bindings/v8/V8Proxy.h \
    14621463        bindings/v8/V8Utilities.h \
     1464        bindings/v8/V8WindowErrorHandler.h \
    14631465        bindings/v8/V8WorkerContextEventListener.h \
    14641466        bindings/v8/WorkerContextExecutionProxy.h \
     
    14871489        bindings/js/JSDOMWindowShell.h \
    14881490        bindings/js/JSDOMWrapper.h \
     1491        bindings/js/JSErrorHandler.h \
    14891492        bindings/js/JSEventListener.h \
    14901493        bindings/js/JSEventTarget.h \
     
    15041507        bindings/js/JSStorageCustom.h \
    15051508        bindings/js/JSWorkerContextBase.h \
    1506         bindings/js/JSWorkerContextErrorHandler.h \
    15071509        bindings/js/JavaScriptCallFrame.h \
    15081510        bindings/js/ScheduledAction.h \
  • trunk/WebCore/WebCore.vcproj/WebCore.vcproj

    r73887 r73914  
    5792357923                                <File
    5792457924                                        RelativePath="..\bindings\js\JSDOMWindowShell.cpp"
     57925                                        RelativePath="..\bindings\js\JSErrorHandler.cpp"
    5792557926                                        >
    5792657927                                        <FileConfiguration
     
    5794157942                                        </FileConfiguration>
    5794257943                                        <FileConfiguration
     57944                                                Name="Debug_Internal|Win32"
     57945                                                ExcludedFromBuild="true"
     57946                                                >
     57947                                                <Tool
     57948                                                        Name="VCCLCompilerTool"
     57949                                                />
     57950                                        </FileConfiguration>
     57951                                        <FileConfiguration
     57952                                                Name="Debug_Cairo|Win32"
     57953                                                ExcludedFromBuild="true"
     57954                                                >
     57955                                                <Tool
     57956                                                        Name="VCCLCompilerTool"
     57957                                                />
     57958                                        </FileConfiguration>
     57959                                        <FileConfiguration
     57960                                                Name="Release_Cairo|Win32"
     57961                                                ExcludedFromBuild="true"
     57962                                                >
     57963                                                <Tool
     57964                                                        Name="VCCLCompilerTool"
     57965                                                />
     57966                                        </FileConfiguration>
     57967                                        <FileConfiguration
     57968                                                Name="Debug_All|Win32"
     57969                                                ExcludedFromBuild="true"
     57970                                                >
     57971                                                <Tool
     57972                                                        Name="VCCLCompilerTool"
     57973                                                />
     57974                                        </FileConfiguration>
     57975                                </File>
     57976                                <File
     57977                                        RelativePath="..\bindings\js\JSErrorHandler.h"
     57978                                        >
     57979                                </File>
     57980                                <File
     57981                                        RelativePath="..\bindings\js\JSEventCustom.cpp"
     57982                                        >
     57983                                        <FileConfiguration
     57984                                                Name="Debug|Win32"
     57985                                                ExcludedFromBuild="true"
     57986                                                >
     57987                                                <Tool
     57988                                                        Name="VCCLCompilerTool"
     57989                                                />
     57990                                        </FileConfiguration>
     57991                                        <FileConfiguration
     57992                                                Name="Release|Win32"
     57993                                                ExcludedFromBuild="true"
     57994                                                >
     57995                                                <Tool
     57996                                                        Name="VCCLCompilerTool"
     57997                                                />
     57998                                        </FileConfiguration>
     57999                                        <FileConfiguration
    5794358000                                                Name="Debug_Cairo_CFLite|Win32"
    5794458001                                                ExcludedFromBuild="true"
     
    6166061717                                                />
    6166161718                                        </FileConfiguration>
    61662                                 </File>
    61663                                 <File
    61664                                         RelativePath="..\bindings\js\JSWorkerContextErrorHandler.cpp"
    61665                                         >
    61666                                         <FileConfiguration
    61667                                                 Name="Debug|Win32"
    61668                                                 ExcludedFromBuild="true"
    61669                                                 >
    61670                                                 <Tool
    61671                                                         Name="VCCLCompilerTool"
    61672                                                 />
    61673                                         </FileConfiguration>
    61674                                         <FileConfiguration
    61675                                                 Name="Release|Win32"
    61676                                                 ExcludedFromBuild="true"
    61677                                                 >
    61678                                                 <Tool
    61679                                                         Name="VCCLCompilerTool"
    61680                                                 />
    61681                                         </FileConfiguration>
    61682                                         <FileConfiguration
    61683                                                 Name="Debug_Cairo_CFLite|Win32"
    61684                                                 ExcludedFromBuild="true"
    61685                                                 >
    61686                                                 <Tool
    61687                                                         Name="VCCLCompilerTool"
    61688                                                 />
    61689                                         </FileConfiguration>
    61690                                         <FileConfiguration
    61691                                                 Name="Release_Cairo_CFLite|Win32"
    61692                                                 ExcludedFromBuild="true"
    61693                                                 >
    61694                                                 <Tool
    61695                                                         Name="VCCLCompilerTool"
    61696                                                 />
    61697                                         </FileConfiguration>
    61698                                         <FileConfiguration
    61699                                                 Name="Debug_All|Win32"
    61700                                                 ExcludedFromBuild="true"
    61701                                                 >
    61702                                                 <Tool
    61703                                                         Name="VCCLCompilerTool"
    61704                                                 />
    61705                                         </FileConfiguration>
    61706                                         <FileConfiguration
    61707                                                 Name="Release_LTCG|Win32"
    61708                                                 ExcludedFromBuild="true"
    61709                                                 >
    61710                                                 <Tool
    61711                                                         Name="VCCLCompilerTool"
    61712                                                 />
    61713                                         </FileConfiguration>
    61714                                 </File>
    61715                                 <File
    61716                                         RelativePath="..\bindings\js\JSWorkerContextErrorHandler.h"
    61717                                         >
    6171861719                                </File>
    6171961720                                <File
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r73886 r73914  
    55595559                F39BE95B12673BF400E0A674 /* ScriptArguments.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F39BE95912673BF400E0A674 /* ScriptArguments.cpp */; };
    55605560                F39BE95C12673BF400E0A674 /* ScriptArguments.h in Headers */ = {isa = PBXBuildFile; fileRef = F39BE95A12673BF400E0A674 /* ScriptArguments.h */; };
    5561                 F3D461481161D53200CA0D09 /* JSWorkerContextErrorHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F3D461461161D53200CA0D09 /* JSWorkerContextErrorHandler.cpp */; };
    5562                 F3D461491161D53200CA0D09 /* JSWorkerContextErrorHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = F3D461471161D53200CA0D09 /* JSWorkerContextErrorHandler.h */; };
     5561                F3D461481161D53200CA0D09 /* JSErrorHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F3D461461161D53200CA0D09 /* JSErrorHandler.cpp */; };
     5562                F3D461491161D53200CA0D09 /* JSErrorHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = F3D461471161D53200CA0D09 /* JSErrorHandler.h */; };
    55635563                F4EAF4AE10C742B1009100D3 /* OpenTypeSanitizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4EAF4AC10C742B1009100D3 /* OpenTypeSanitizer.cpp */; };
    55645564                F4EAF4AF10C742B1009100D3 /* OpenTypeSanitizer.h in Headers */ = {isa = PBXBuildFile; fileRef = F4EAF4AD10C742B1009100D3 /* OpenTypeSanitizer.h */; };
     
    1186011860                F39BE95912673BF400E0A674 /* ScriptArguments.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptArguments.cpp; sourceTree = "<group>"; };
    1186111861                F39BE95A12673BF400E0A674 /* ScriptArguments.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptArguments.h; sourceTree = "<group>"; };
    11862                 F3D461461161D53200CA0D09 /* JSWorkerContextErrorHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWorkerContextErrorHandler.cpp; sourceTree = "<group>"; };
    11863                 F3D461471161D53200CA0D09 /* JSWorkerContextErrorHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWorkerContextErrorHandler.h; sourceTree = "<group>"; };
     11862                F3D461461161D53200CA0D09 /* JSErrorHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSErrorHandler.cpp; sourceTree = "<group>"; };
     11863                F3D461471161D53200CA0D09 /* JSErrorHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSErrorHandler.h; sourceTree = "<group>"; };
    1186411864                F4EAF4AC10C742B1009100D3 /* OpenTypeSanitizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OpenTypeSanitizer.cpp; path = opentype/OpenTypeSanitizer.cpp; sourceTree = "<group>"; };
    1186511865                F4EAF4AD10C742B1009100D3 /* OpenTypeSanitizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OpenTypeSanitizer.h; path = opentype/OpenTypeSanitizer.h; sourceTree = "<group>"; };
     
    1745717457                                BC53DAC611433064000D817E /* JSDOMWrapper.cpp */,
    1745817458                                65E0E9431133C89F00B4CB10 /* JSDOMWrapper.h */,
     17459                                F3D461461161D53200CA0D09 /* JSErrorHandler.cpp */,
     17460                                F3D461471161D53200CA0D09 /* JSErrorHandler.h */,
    1745917461                                BC60901E0E91B8EC000C68B5 /* JSEventTarget.cpp */,
    1746017462                                BC60901D0E91B8EC000C68B5 /* JSEventTarget.h */,
     
    1746817470                                E1C36D320EB0A094007410BC /* JSWorkerContextBase.cpp */,
    1746917471                                E1C36D330EB0A094007410BC /* JSWorkerContextBase.h */,
    17470                                 F3D461461161D53200CA0D09 /* JSWorkerContextErrorHandler.cpp */,
    17471                                 F3D461471161D53200CA0D09 /* JSWorkerContextErrorHandler.h */,
    1747217472                                BCA378BA0D15F64200B793D6 /* ScheduledAction.cpp */,
    1747317473                                BCA378BB0D15F64200B793D6 /* ScheduledAction.h */,
     
    2113421134                                E18256900EF2B02D00933242 /* JSWorkerContext.h in Headers */,
    2113521135                                E1C36D350EB0A094007410BC /* JSWorkerContextBase.h in Headers */,
    21136                                 F3D461491161D53200CA0D09 /* JSWorkerContextErrorHandler.h in Headers */,
     21136                                F3D461491161D53200CA0D09 /* JSErrorHandler.h in Headers */,
    2113721137                                E1C362EF0EAF2AA9007410BC /* JSWorkerLocation.h in Headers */,
    2113821138                                E1271A580EEECDE400F61213 /* JSWorkerNavigator.h in Headers */,
     
    2395423954                                E1C36D340EB0A094007410BC /* JSWorkerContextBase.cpp in Sources */,
    2395523955                                E18258AC0EF3CD7000933242 /* JSWorkerContextCustom.cpp in Sources */,
    23956                                 F3D461481161D53200CA0D09 /* JSWorkerContextErrorHandler.cpp in Sources */,
     23956                                F3D461481161D53200CA0D09 /* JSErrorHandler.cpp in Sources */,
    2395723957                                E1CA5CBC0E8CDCAF00E8EF90 /* JSWorkerCustom.cpp in Sources */,
    2395823958                                E1C362F00EAF2AA9007410BC /* JSWorkerLocation.cpp in Sources */,
  • trunk/WebCore/bindings/js/JSBindingsAllInOne.cpp

    r72590 r73914  
    7373#include "JSDocumentCustom.cpp"
    7474#include "JSElementCustom.cpp"
     75#include "JSErrorHandler.cpp"
    7576#include "JSEventCustom.cpp"
    7677#include "JSEventListener.cpp"
     
    142143#include "JSWorkerContextBase.cpp"
    143144#include "JSWorkerContextCustom.cpp"
    144 #include "JSWorkerContextErrorHandler.cpp"
    145145#include "JSWorkerCustom.cpp"
    146146#include "JSXMLHttpRequestCustom.cpp"
  • trunk/WebCore/bindings/js/JSDOMBinding.cpp

    r73647 r73914  
    5656#include "RangeException.h"
    5757#include "ScriptCachedFrameData.h"
     58#include "ScriptCallStack.h"
    5859#include "ScriptController.h"
    5960#include "Settings.h"
     
    599600        return;
    600601
    601     scriptExecutionContext->reportException(ustringToString(errorMessage), lineNumber, ustringToString(exceptionSourceURL));
     602    scriptExecutionContext->reportException(ustringToString(errorMessage), lineNumber, ustringToString(exceptionSourceURL), 0);
    602603}
    603604
  • trunk/WebCore/bindings/js/JSErrorHandler.cpp

    r73913 r73914  
    3131#include "config.h"
    3232
    33 #if ENABLE(WORKERS)
    34 
    35 #include "JSWorkerContextErrorHandler.h"
     33#include "JSErrorHandler.h"
    3634
    3735#include "ErrorEvent.h"
     
    4442namespace WebCore {
    4543
    46 JSWorkerContextErrorHandler::JSWorkerContextErrorHandler(JSObject* function, JSObject* wrapper, bool isAttribute, DOMWrapperWorld* isolatedWorld)
     44JSErrorHandler::JSErrorHandler(JSObject* function, JSObject* wrapper, bool isAttribute, DOMWrapperWorld* isolatedWorld)
    4745    : JSEventListener(function, wrapper, isAttribute, isolatedWorld)
    4846{
    4947}
    5048
    51 JSWorkerContextErrorHandler::~JSWorkerContextErrorHandler()
     49JSErrorHandler::~JSErrorHandler()
    5250{
    5351}
    5452
    55 void JSWorkerContextErrorHandler::handleEvent(ScriptExecutionContext* scriptExecutionContext, Event* event)
     53void JSErrorHandler::handleEvent(ScriptExecutionContext* scriptExecutionContext, Event* event)
    5654{
    5755    ASSERT(scriptExecutionContext);
    5856    if (!scriptExecutionContext)
    5957        return;
     58
     59    ASSERT(event->isErrorEvent());
     60    ErrorEvent* errorEvent = static_cast<ErrorEvent*>(event);
    6061
    6162    JSLock lock(SilenceAssertionsOnly);
     
    7576
    7677    if (callType != CallTypeNone) {
    77 
    78         ref();
     78        RefPtr<JSErrorHandler> protectedctor(this);
    7979
    8080        Event* savedEvent = globalObject->currentEvent();
    8181        globalObject->setCurrentEvent(event);
    82 
    83         ASSERT(event->isErrorEvent());
    84         ErrorEvent* errorEvent = static_cast<ErrorEvent*>(event);
    8582
    8683        MarkedArgumentBuffer args;
     
    107104                event->preventDefault();
    108105        }
    109 
    110         deref();
    111106    }
    112107}
    113108
    114109} // namespace WebCore
    115 
    116 #endif // ENABLE(WORKERS)
  • trunk/WebCore/bindings/js/JSErrorHandler.h

    r73913 r73914  
    2929 */
    3030
    31 #ifndef JSWorkerContextErrorHandler_h
    32 #define JSWorkerContextErrorHandler_h
     31#ifndef JSErrorHandler_h
     32#define JSErrorHandler_h
    3333
    3434#include "JSEventListener.h"
     
    3636namespace WebCore {
    3737
    38 class JSWorkerContextErrorHandler : public JSEventListener {
     38class JSErrorHandler : public JSEventListener {
    3939public:
    40     static PassRefPtr<JSWorkerContextErrorHandler> create(JSC::JSObject* listener, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld* isolatedWorld)
     40    static PassRefPtr<JSErrorHandler> create(JSC::JSObject* listener, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld* isolatedWorld)
    4141    {
    42         return adoptRef(new JSWorkerContextErrorHandler(listener, wrapper, isAttribute, isolatedWorld));
     42        return adoptRef(new JSErrorHandler(listener, wrapper, isAttribute, isolatedWorld));
    4343    }
    4444
    45     virtual ~JSWorkerContextErrorHandler();
     45    virtual ~JSErrorHandler();
    4646
    4747private:
    48     JSWorkerContextErrorHandler(JSC::JSObject* function, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld* isolatedWorld);
     48    JSErrorHandler(JSC::JSObject* function, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld* isolatedWorld);
    4949    virtual void handleEvent(ScriptExecutionContext*, Event*);
    5050};
     
    5252// Creates a JS EventListener for "onerror" event handler in worker context. It has custom implementation because
    5353// unlike other event listeners it accepts three parameters.
    54 inline PassRefPtr<JSWorkerContextErrorHandler> createJSWorkerContextErrorHandler(JSC::ExecState* exec, JSC::JSValue listener, JSC::JSObject* wrapper)
     54inline PassRefPtr<JSErrorHandler> createJSErrorHandler(JSC::ExecState* exec, JSC::JSValue listener, JSC::JSObject* wrapper)
    5555{
    5656    if (!listener.isObject())
    5757        return 0;
    5858
    59     return JSWorkerContextErrorHandler::create(asObject(listener), wrapper, true, currentWorld(exec));
     59    return JSErrorHandler::create(asObject(listener), wrapper, true, currentWorld(exec));
    6060}
    6161
    6262} // namespace WebCore
    6363
    64 #endif // JSWorkerContextErrorHandler_h
     64#endif // JSErrorHandler_h
  • trunk/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r73564 r73914  
    17101710                            }
    17111711                            push(@implContent, "    $implClassName* imp = static_cast<$implClassName*>(static_cast<$className*>(thisObject)->impl());\n");
    1712                             if ($interfaceName eq "WorkerContext" and $name eq "onerror") {
    1713                                 $implIncludes{"JSWorkerContextErrorHandler.h"} = 1;
    1714                                 push(@implContent, "    imp->set$implSetterFunctionName(createJSWorkerContextErrorHandler(exec, value, thisObject));\n");
     1712                            if ((($interfaceName eq "DOMWindow") or ($interfaceName eq "WorkerContext")) and $name eq "onerror") {
     1713                                $implIncludes{"JSErrorHandler.h"} = 1;
     1714                                push(@implContent, "    imp->set$implSetterFunctionName(createJSErrorHandler(exec, value, thisObject));\n");
    17151715                            } else {
    17161716                                push(@implContent, GenerateAttributeEventListenerCall($className, $implSetterFunctionName, $windowEventListener));
  • trunk/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r73266 r73914  
    10021002                $implIncludes{"V8WorkerContextErrorHandler.h"} = 1;
    10031003                push(@implContentDecls, "    imp->set$implSetterFunctionName(V8EventListenerList::findOrCreateWrapper<V8WorkerContextErrorHandler>(value, true)");
     1004            } elsif ($interfaceName eq "DOMWindow" and $attribute->signature->name eq "onerror") {
     1005                $implIncludes{"V8EventListenerList.h"} = 1;
     1006                $implIncludes{"V8WindowErrorHandler.h"} = 1;
     1007                push(@implContentDecls, "    imp->set$implSetterFunctionName(V8EventListenerList::findOrCreateWrapper<V8WindowErrorHandler>(value, true)");
    10041008            } else {
    10051009                push(@implContentDecls, "    imp->set$implSetterFunctionName(V8DOMWrapper::getEventListener(value, true, ListenerFindOrCreate)");
  • trunk/WebCore/bindings/v8/V8ConsoleMessage.cpp

    r73366 r73914  
    5555void V8ConsoleMessage::dispatchNow(Page* page)
    5656{
    57     dispatchNow(page, 0);
     57    ASSERT(page);
     58
     59    // Process any delayed messages to make sure that messages
     60    // appear in the right order in the console.
     61    processDelayed();
     62
     63    Console* console = page->mainFrame()->domWindow()->console();
     64    console->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, m_string, m_lineNumber, m_sourceID);
    5865}
    5966
     
    106113    if (!frame)
    107114        return;
    108     Page* page = frame->page();
    109     if (!page)
     115    Document* document = frame->document();
     116    if (!document)
    110117        return;
    111118
     
    123130    bool useURL = resourceName.IsEmpty() || !resourceName->IsString();
    124131    String resourceNameString = useURL ? frame->document()->url() : toWebCoreString(resourceName);
    125     V8ConsoleMessage consoleMessage(errorMessage, resourceNameString, message->GetLineNumber());
    126     consoleMessage.dispatchNow(page, callStack);
    127 }
    128 
    129 void V8ConsoleMessage::dispatchNow(Page* page, PassRefPtr<ScriptCallStack> callStack)
    130 {
    131     ASSERT(page);
    132 
    133     // Process any delayed messages to make sure that messages
    134     // appear in the right order in the console.
    135     processDelayed();
    136 
    137     Console* console = page->mainFrame()->domWindow()->console();
    138     MessageType messageType = callStack ? UncaughtExceptionMessageType : LogMessageType;
    139     console->addMessage(JSMessageSource, messageType, ErrorMessageLevel, m_string, m_lineNumber, m_sourceID, callStack);
     132    document->reportException(errorMessage, message->GetLineNumber(), resourceNameString, callStack);
    140133}
    141134
  • trunk/WebCore/bindings/v8/V8ConsoleMessage.h

    r72895 r73914  
    8383        const unsigned m_lineNumber;
    8484
    85         void dispatchNow(Page*, PassRefPtr<ScriptCallStack>);
    86 
    8785        // All delayed messages are stored in this vector. If the vector
    8886        // is 0, there are no delayed messages.
  • trunk/WebCore/bindings/v8/V8WindowErrorHandler.cpp

    • Property svn:executable set to *
    r73913 r73914  
    2929 */
    3030
    31 #ifndef JSWorkerContextErrorHandler_h
    32 #define JSWorkerContextErrorHandler_h
     31#include "config.h"
    3332
    34 #include "JSEventListener.h"
     33#include "V8WindowErrorHandler.h"
     34
     35#include "ErrorEvent.h"
     36#include "V8Binding.h"
    3537
    3638namespace WebCore {
    3739
    38 class JSWorkerContextErrorHandler : public JSEventListener {
    39 public:
    40     static PassRefPtr<JSWorkerContextErrorHandler> create(JSC::JSObject* listener, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld* isolatedWorld)
    41     {
    42         return adoptRef(new JSWorkerContextErrorHandler(listener, wrapper, isAttribute, isolatedWorld));
     40V8WindowErrorHandler::V8WindowErrorHandler(v8::Local<v8::Object> listener, bool isInline, const WorldContextHandle& worldContext)
     41    : V8EventListener(listener, isInline, worldContext)
     42{
     43}
     44
     45v8::Local<v8::Value> V8WindowErrorHandler::callListenerFunction(ScriptExecutionContext* context, v8::Handle<v8::Value> jsEvent, Event* event)
     46{
     47    ASSERT(event->isErrorEvent());
     48    ErrorEvent* errorEvent = static_cast<ErrorEvent*>(event);
     49    v8::Local<v8::Object> listener = getListenerObject(context);
     50    v8::Local<v8::Value> returnValue;
     51    if (!listener.IsEmpty() && listener->IsFunction()) {
     52        v8::Local<v8::Function> callFunction = v8::Local<v8::Function>::Cast(listener);
     53        v8::Local<v8::Object> thisValue = v8::Context::GetCurrent()->Global();
     54        v8::Handle<v8::Value> parameters[3] = { v8String(errorEvent->message()), v8String(errorEvent->filename()), v8::Integer::New(errorEvent->lineno()) };
     55        returnValue = callFunction->Call(thisValue, 3, parameters);
     56        if (!returnValue.IsEmpty() && returnValue->IsBoolean() && !returnValue->BooleanValue())
     57            event->preventDefault();
    4358    }
    44 
    45     virtual ~JSWorkerContextErrorHandler();
    46 
    47 private:
    48     JSWorkerContextErrorHandler(JSC::JSObject* function, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld* isolatedWorld);
    49     virtual void handleEvent(ScriptExecutionContext*, Event*);
    50 };
    51 
    52 // Creates a JS EventListener for "onerror" event handler in worker context. It has custom implementation because
    53 // unlike other event listeners it accepts three parameters.
    54 inline PassRefPtr<JSWorkerContextErrorHandler> createJSWorkerContextErrorHandler(JSC::ExecState* exec, JSC::JSValue listener, JSC::JSObject* wrapper)
    55 {
    56     if (!listener.isObject())
    57         return 0;
    58 
    59     return JSWorkerContextErrorHandler::create(asObject(listener), wrapper, true, currentWorld(exec));
     59    return returnValue;
    6060}
    6161
    6262} // namespace WebCore
    63 
    64 #endif // JSWorkerContextErrorHandler_h
  • trunk/WebCore/bindings/v8/V8WindowErrorHandler.h

    • Property svn:executable set to *
    r73913 r73914  
    2929 */
    3030
    31 #ifndef JSWorkerContextErrorHandler_h
    32 #define JSWorkerContextErrorHandler_h
     31#ifndef V8WindowErrorHandler_h
     32#define V8WindowErrorHandler_h
    3333
    34 #include "JSEventListener.h"
     34#include "V8CustomEventListener.h"
     35#include <v8.h>
     36#include <wtf/PassRefPtr.h>
    3537
    3638namespace WebCore {
    3739
    38 class JSWorkerContextErrorHandler : public JSEventListener {
     40class V8WindowErrorHandler : public V8EventListener {
    3941public:
    40     static PassRefPtr<JSWorkerContextErrorHandler> create(JSC::JSObject* listener, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld* isolatedWorld)
     42    static PassRefPtr<V8WindowErrorHandler> create(v8::Local<v8::Object> listener, bool isInline, const WorldContextHandle& worldContext)
    4143    {
    42         return adoptRef(new JSWorkerContextErrorHandler(listener, wrapper, isAttribute, isolatedWorld));
     44        return adoptRef(new V8WindowErrorHandler(listener, isInline, worldContext));
    4345    }
    4446
    45     virtual ~JSWorkerContextErrorHandler();
     47private:
     48    V8WindowErrorHandler(v8::Local<v8::Object> listener, bool isInline, const WorldContextHandle& worldContext);
    4649
    47 private:
    48     JSWorkerContextErrorHandler(JSC::JSObject* function, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld* isolatedWorld);
    49     virtual void handleEvent(ScriptExecutionContext*, Event*);
     50    virtual v8::Local<v8::Value> callListenerFunction(ScriptExecutionContext*, v8::Handle<v8::Value> jsEvent, Event*);
    5051};
    51 
    52 // Creates a JS EventListener for "onerror" event handler in worker context. It has custom implementation because
    53 // unlike other event listeners it accepts three parameters.
    54 inline PassRefPtr<JSWorkerContextErrorHandler> createJSWorkerContextErrorHandler(JSC::ExecState* exec, JSC::JSValue listener, JSC::JSObject* wrapper)
    55 {
    56     if (!listener.isObject())
    57         return 0;
    58 
    59     return JSWorkerContextErrorHandler::create(asObject(listener), wrapper, true, currentWorld(exec));
    60 }
    6152
    6253} // namespace WebCore
    6354
    64 #endif // JSWorkerContextErrorHandler_h
     55#endif // V8WindowErrorHandler_h
  • trunk/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp

    r71735 r73914  
    3838#include "DedicatedWorkerContext.h"
    3939#include "Event.h"
     40#include "ScriptCallStack.h"
    4041#include "SharedWorker.h"
    4142#include "SharedWorkerContext.h"
     
    7374        int lineNumber = message->GetLineNumber();
    7475        String sourceURL = toWebCoreString(message->GetScriptResourceName());
    75         context->reportException(errorMessage, lineNumber, sourceURL);
     76        context->reportException(errorMessage, lineNumber, sourceURL, 0);
    7677    }
    7778
  • trunk/WebCore/bindings/v8/WorkerScriptController.cpp

    r71735 r73914  
    3535#include "WorkerScriptController.h"
    3636
    37 #include <v8.h>
    38 
     37#include "DOMTimer.h"
     38#include "ScriptCallStack.h"
    3939#include "ScriptSourceCode.h"
    4040#include "ScriptValue.h"
    41 #include "DOMTimer.h"
    4241#include "V8DOMMap.h"
    4342#include "V8Proxy.h"
     
    4746#include "WorkerObjectProxy.h"
    4847#include "WorkerThread.h"
     48#include <v8.h>
    4949
    5050namespace WebCore {
     
    8181            *exception = state.exception;
    8282        else
    83             m_workerContext->reportException(state.errorMessage, state.lineNumber, state.sourceURL);
     83            m_workerContext->reportException(state.errorMessage, state.lineNumber, state.sourceURL, 0);
    8484    }
    8585
  • trunk/WebCore/dom/Document.cpp

    r73620 r73914  
    119119#include "RenderView.h"
    120120#include "RenderWidget.h"
     121#include "ScriptCallStack.h"
    121122#include "ScriptController.h"
    122123#include "ScriptElement.h"
     
    22702271{
    22712272    return completeURL(url);
     2273}
     2274
     2275EventTarget* Document::errorEventTarget()
     2276{
     2277    return domWindow();
     2278}
     2279
     2280void Document::logExceptionToConsole(const String& errorMessage, int lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack> callStack)
     2281{
     2282    MessageType messageType = callStack ? UncaughtExceptionMessageType : LogMessageType;
     2283    addMessage(JSMessageSource, messageType, ErrorMessageLevel, errorMessage, lineNumber, sourceURL, callStack);
    22722284}
    22732285
     
    46614673}
    46624674
    4663 void Document::reportException(const String& errorMessage, int lineNumber, const String& sourceURL)
    4664 {
    4665     addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, errorMessage, lineNumber, sourceURL);
    4666 }
    4667 
    4668 void Document::addMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL)
     4675void Document::addMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack> callStack)
    46694676{
    46704677    if (DOMWindow* window = domWindow())
    4671         window->console()->addMessage(source, type, level, message, lineNumber, sourceURL);
     4678        window->console()->addMessage(source, type, level, message, lineNumber, sourceURL, callStack);
    46724679}
    46734680
  • trunk/WebCore/dom/Document.h

    r73559 r73914  
    931931    void parseDNSPrefetchControlHeader(const String&);
    932932
    933     virtual void reportException(const String& errorMessage, int lineNumber, const String& sourceURL);
    934     virtual void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL);
     933    virtual void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>);
    935934    virtual void postTask(PassOwnPtr<Task>); // Executes the task on context's thread asynchronously.
    936935
     
    11161115    virtual const KURL& virtualURL() const; // Same as url(), but needed for ScriptExecutionContext to implement it without a performance loss for direct calls.
    11171116    virtual KURL virtualCompleteURL(const String&) const; // Same as completeURL() for the same reason as above.
     1117
     1118    virtual EventTarget* errorEventTarget();
     1119    virtual void logExceptionToConsole(const String& errorMessage, int lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>);
    11181120
    11191121    void initDNSPrefetch();
  • trunk/WebCore/dom/ScriptExecutionContext.cpp

    r67734 r73914  
    3434#include "DatabaseTask.h"
    3535#include "DatabaseThread.h"
     36#include "ErrorEvent.h"
     37#include "EventListener.h"
     38#include "EventTarget.h"
    3639#include "FileThread.h"
    3740#include "MessagePort.h"
     41#include "ScriptCallStack.h"
    3842#include "SecurityOrigin.h"
    3943#include "ThreadableBlobRegistry.h"
     
    4246#include <wtf/MainThread.h>
    4347#include <wtf/PassRefPtr.h>
     48#include <wtf/Vector.h>
    4449
    4550#if USE(JSC)
     
    6267};
    6368
     69class ScriptExecutionContext::PendingException : public Noncopyable {
     70public:
     71    PendingException(const String& errorMessage, int lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack> callStack)
     72        : m_errorMessage(errorMessage)
     73        , m_lineNumber(lineNumber)
     74        , m_sourceURL(sourceURL)
     75        , m_callStack(callStack)
     76    {
     77    }
     78    String m_errorMessage;
     79    int m_lineNumber;
     80    String m_sourceURL;
     81    RefPtr<ScriptCallStack> m_callStack;
     82};
     83
    6484ScriptExecutionContext::ScriptExecutionContext()
    6585#if ENABLE(DATABASE)
    6686    : m_hasOpenDatabases(false)
    6787#endif
     88    , m_inDispatchErrorEvent(false)
    6889{
    6990}
     
    244265}
    245266
     267void ScriptExecutionContext::reportException(const String& errorMessage, int lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack> callStack)
     268{
     269    if (m_inDispatchErrorEvent) {
     270        if (!m_pendingExceptions)
     271            m_pendingExceptions = adoptPtr(new Vector<OwnPtr<PendingException> >());
     272        m_pendingExceptions->append(adoptPtr(new PendingException(errorMessage, lineNumber, sourceURL, callStack)));
     273        return;
     274    }
     275
     276    // First report the original exception and only then all the nested ones.
     277    if (!dispatchErrorEvent(errorMessage, lineNumber, sourceURL))
     278        logExceptionToConsole(errorMessage, lineNumber, sourceURL, callStack);
     279
     280    if (!m_pendingExceptions)
     281        return;
     282
     283    for (size_t i = 0; i < m_pendingExceptions->size(); i++) {
     284        PendingException* e = m_pendingExceptions->at(i).get();
     285        logExceptionToConsole(e->m_errorMessage, e->m_lineNumber, e->m_sourceURL, e->m_callStack);
     286    }
     287    m_pendingExceptions.clear();
     288}
     289
     290bool ScriptExecutionContext::dispatchErrorEvent(const String& errorMessage, int lineNumber, const String& sourceURL)
     291{
     292    EventTarget* target = errorEventTarget();
     293    if (!target)
     294        return false;
     295
     296    ASSERT(!m_inDispatchErrorEvent);
     297    m_inDispatchErrorEvent = true;
     298    RefPtr<ErrorEvent> errorEvent = ErrorEvent::create(errorMessage, sourceURL, lineNumber);
     299    target->dispatchEvent(errorEvent);
     300    m_inDispatchErrorEvent = false;
     301    return errorEvent->defaultPrevented();
     302}
     303
    246304void ScriptExecutionContext::addTimeout(int timeoutId, DOMTimer* timer)
    247305{
  • trunk/WebCore/dom/ScriptExecutionContext.h

    r69688 r73914  
    3434#include <wtf/HashMap.h>
    3535#include <wtf/HashSet.h>
     36#include <wtf/OwnPtr.h>
    3637#include <wtf/PassOwnPtr.h>
    3738#include <wtf/PassRefPtr.h>
     
    5354#endif
    5455    class DOMTimer;
     56    class EventListener;
     57    class EventTarget;
    5558#if ENABLE(BLOB) || ENABLE(FILE_SYSTEM)
    5659    class FileThread;
     
    5861    class MessagePort;
    5962    class SecurityOrigin;
     63    class ScriptCallStack;
    6064#if ENABLE(INSPECTOR)
    6165    class InspectorController;
     
    9296#endif
    9397
    94         virtual void reportException(const String& errorMessage, int lineNumber, const String& sourceURL) = 0;
    95         virtual void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL) = 0;
     98        void reportException(const String& errorMessage, int lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>);
     99        virtual void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>) = 0;
    96100
    97101        // Active objects are not garbage collected even if inaccessible, e.g. because their activity may result in callbacks being invoked.
     
    155159        virtual KURL virtualCompleteURL(const String&) const = 0;
    156160
     161        virtual EventTarget* errorEventTarget() = 0;
     162        virtual void logExceptionToConsole(const String& errorMessage, int lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>) = 0;
     163        bool dispatchErrorEvent(const String& errorMessage, int lineNumber, const String& sourceURL);
     164
    157165        void closeMessagePorts();
    158166
     
    180188        RefPtr<FileThread> m_fileThread;
    181189#endif
     190        bool m_inDispatchErrorEvent;
     191        class PendingException;
     192        OwnPtr<Vector<OwnPtr<PendingException> > > m_pendingExceptions;
    182193    };
    183194
  • trunk/WebCore/websockets/WebSocket.cpp

    r69798 r73914  
    4242#include "Logging.h"
    4343#include "MessageEvent.h"
     44#include "ScriptCallStack.h"
    4445#include "ScriptExecutionContext.h"
    4546#include "ThreadableWebSocketChannel.h"
     
    117118
    118119    if (!m_url.isValid()) {
    119         scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Invalid url for WebSocket " + url.string(), 0, scriptExecutionContext()->securityOrigin()->toString());
     120        scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Invalid url for WebSocket " + url.string(), 0, scriptExecutionContext()->securityOrigin()->toString(), 0);
    120121        m_state = CLOSED;
    121122        ec = SYNTAX_ERR;
     
    124125
    125126    if (!m_url.protocolIs("ws") && !m_url.protocolIs("wss")) {
    126         scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Wrong url scheme for WebSocket " + url.string(), 0, scriptExecutionContext()->securityOrigin()->toString());
     127        scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Wrong url scheme for WebSocket " + url.string(), 0, scriptExecutionContext()->securityOrigin()->toString(), 0);
    127128        m_state = CLOSED;
    128129        ec = SYNTAX_ERR;
     
    130131    }
    131132    if (m_url.hasFragmentIdentifier()) {
    132         scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "URL has fragment component " + url.string(), 0, scriptExecutionContext()->securityOrigin()->toString());
     133        scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "URL has fragment component " + url.string(), 0, scriptExecutionContext()->securityOrigin()->toString(), 0);
    133134        m_state = CLOSED;
    134135        ec = SYNTAX_ERR;
     
    136137    }
    137138    if (!isValidProtocolString(m_protocol)) {
    138         scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Wrong protocol for WebSocket '" + encodeProtocolString(m_protocol) + "'", 0, scriptExecutionContext()->securityOrigin()->toString());
     139        scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Wrong protocol for WebSocket '" + encodeProtocolString(m_protocol) + "'", 0, scriptExecutionContext()->securityOrigin()->toString(), 0);
    139140        m_state = CLOSED;
    140141        ec = SYNTAX_ERR;
     
    142143    }
    143144    if (!portAllowed(url)) {
    144         scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, makeString("WebSocket port ", String::number(url.port()), " blocked"), 0, scriptExecutionContext()->securityOrigin()->toString());
     145        scriptExecutionContext()->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, makeString("WebSocket port ", String::number(url.port()), " blocked"), 0, scriptExecutionContext()->securityOrigin()->toString(), 0);
    145146        m_state = CLOSED;
    146147        ec = SECURITY_ERR;
  • trunk/WebCore/websockets/WebSocketChannel.cpp

    r70216 r73914  
    4242#include "PlatformString.h"
    4343#include "ProgressTracker.h"
     44#include "ScriptCallStack.h"
    4445#include "ScriptExecutionContext.h"
    4546#include "SocketStreamError.h"
     
    156157    CString handshakeMessage = m_handshake.clientHandshakeMessage();
    157158    if (!handle->send(handshakeMessage.data(), handshakeMessage.length())) {
    158         m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error sending handshake message.", 0, m_handshake.clientOrigin());
     159        m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error sending handshake message.", 0, m_handshake.clientOrigin(), 0);
    159160        handle->close();
    160161    }
     
    240241        return true;
    241242    }
    242     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());
     243    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);
    243244    return false;
    244245}
  • trunk/WebCore/websockets/WebSocketHandshake.cpp

    r69798 r73914  
    4242#include "KURL.h"
    4343#include "Logging.h"
     44#include "ScriptCallStack.h"
    4445#include "ScriptExecutionContext.h"
    4546#include "SecurityOrigin.h"
     
    320321    if (statusCode != 101) {
    321322        m_mode = Failed;
    322         m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, makeString("Unexpected response code: ", String::number(statusCode)), 0, clientOrigin());
     323        m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, makeString("Unexpected response code: ", String::number(statusCode)), 0, clientOrigin(), 0);
    323324        return len;
    324325    }
     
    450451    const char* end = p + 1;
    451452    if (end - header > INT_MAX) {
    452         m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Status line is too long: " + trimConsoleMessage(header, maxConsoleMessageSize + 1), 0, clientOrigin());
     453        m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Status line is too long: " + trimConsoleMessage(header, maxConsoleMessageSize + 1), 0, clientOrigin(), 0);
    453454        return INT_MAX;
    454455    }
     
    456457
    457458    if (!space1 || !space2) {
    458         m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "No response code found: " + trimConsoleMessage(header, lineLength - 1), 0, clientOrigin());
     459        m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "No response code found: " + trimConsoleMessage(header, lineLength - 1), 0, clientOrigin(), 0);
    459460        return lineLength;
    460461    }
     
    462463    // The line must end with "\r\n".
    463464    if (*(end - 2) != '\r') {
    464         m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Status line does not end with CRLF", 0, clientOrigin());
     465        m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Status line does not end with CRLF", 0, clientOrigin(), 0);
    465466        return lineLength;
    466467    }
     
    471472    for (int i = 0; i < 3; ++i)
    472473        if (statusCodeString[i] < '0' || statusCodeString[i] > '9') {
    473             m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Invalid status code: " + statusCodeString, 0, clientOrigin());
     474            m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Invalid status code: " + statusCodeString, 0, clientOrigin(), 0);
    474475            return lineLength;
    475476        }
     
    499500                    if (p + 1 < end && *(p + 1) == '\n')
    500501                        return p + 2;
    501                     m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "CR doesn't follow LF at " + trimConsoleMessage(p, end - p), 0, clientOrigin());
     502                    m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "CR doesn't follow LF at " + trimConsoleMessage(p, end - p), 0, clientOrigin(), 0);
    502503                    return 0;
    503504                }
    504                 m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Unexpected CR in name at " + trimConsoleMessage(name.data(), name.size()), 0, clientOrigin());
     505                m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Unexpected CR in name at " + trimConsoleMessage(name.data(), name.size()), 0, clientOrigin(), 0);
    505506                return 0;
    506507            case '\n':
    507                 m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Unexpected LF in name at " + trimConsoleMessage(name.data(), name.size()), 0, clientOrigin());
     508                m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Unexpected LF in name at " + trimConsoleMessage(name.data(), name.size()), 0, clientOrigin(), 0);
    508509                return 0;
    509510            case ':':
     
    526527                break;
    527528            case '\n':
    528                 m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Unexpected LF in value at " + trimConsoleMessage(value.data(), value.size()), 0, clientOrigin());
     529                m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Unexpected LF in value at " + trimConsoleMessage(value.data(), value.size()), 0, clientOrigin(), 0);
    529530                return 0;
    530531            default:
     
    537538        }
    538539        if (p >= end || *p != '\n') {
    539             m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "CR doesn't follow LF after value at " + trimConsoleMessage(p, end - p), 0, clientOrigin());
     540            m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "CR doesn't follow LF after value at " + trimConsoleMessage(p, end - p), 0, clientOrigin(), 0);
    540541            return 0;
    541542        }
     
    543544        String valueStr = String::fromUTF8(value.data(), value.size());
    544545        if (nameStr.isNull()) {
    545             m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "invalid UTF-8 sequence in header name", 0, clientOrigin());
     546            m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "invalid UTF-8 sequence in header name", 0, clientOrigin(), 0);
    546547            return 0;
    547548        }
    548549        if (valueStr.isNull()) {
    549             m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "invalid UTF-8 sequence in header value", 0, clientOrigin());
     550            m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "invalid UTF-8 sequence in header value", 0, clientOrigin(), 0);
    550551            return 0;
    551552        }
     
    571572{
    572573    if (m_wsOrigin.isNull()) {
    573         m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error during WebSocket handshake: 'sec-websocket-origin' header is missing", 0, clientOrigin());
     574        m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error during WebSocket handshake: 'sec-websocket-origin' header is missing", 0, clientOrigin(), 0);
    574575        return false;
    575576    }
    576577    if (m_wsLocation.isNull()) {
    577         m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error during WebSocket handshake: 'sec-websocket-location' header is missing", 0, clientOrigin());
     578        m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error during WebSocket handshake: 'sec-websocket-location' header is missing", 0, clientOrigin(), 0);
    578579        return false;
    579580    }
    580581
    581582    if (clientOrigin() != m_wsOrigin) {
    582         m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error during WebSocket handshake: origin mismatch: " + clientOrigin() + " != " + m_wsOrigin, 0, clientOrigin());
     583        m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error during WebSocket handshake: origin mismatch: " + clientOrigin() + " != " + m_wsOrigin, 0, clientOrigin(), 0);
    583584        return false;
    584585    }
    585586    if (clientLocation() != m_wsLocation) {
    586         m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error during WebSocket handshake: location mismatch: " + clientLocation() + " != " + m_wsLocation, 0, clientOrigin());
     587        m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error during WebSocket handshake: location mismatch: " + clientLocation() + " != " + m_wsLocation, 0, clientOrigin(), 0);
    587588        return false;
    588589    }
    589590    if (!m_clientProtocol.isEmpty() && m_clientProtocol != m_wsProtocol) {
    590         m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error during WebSocket handshake: protocol mismatch: " + m_clientProtocol + " != " + m_wsProtocol, 0, clientOrigin());
     591        m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, "Error during WebSocket handshake: protocol mismatch: " + m_clientProtocol + " != " + m_wsProtocol, 0, clientOrigin(), 0);
    591592        return false;
    592593    }
  • trunk/WebCore/workers/DefaultSharedWorkerRepository.cpp

    r62551 r73914  
    4343#include "NotImplemented.h"
    4444#include "PlatformString.h"
     45#include "ScriptCallStack.h"
    4546#include "SecurityOrigin.h"
    4647#include "SecurityOriginHash.h"
     
    156157static void postExceptionTask(ScriptExecutionContext* context, const String& errorMessage, int lineNumber, const String& sourceURL)
    157158{
    158     context->reportException(errorMessage, lineNumber, sourceURL);
     159    context->reportException(errorMessage, lineNumber, sourceURL, 0);
    159160}
    160161
     
    168169static void postConsoleMessageTask(ScriptExecutionContext* document, MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL)
    169170{
    170     document->addMessage(source, type, level, message, lineNumber, sourceURL);
     171    document->addMessage(source, type, level, message, lineNumber, sourceURL, 0);
    171172}
    172173
  • trunk/WebCore/workers/WorkerContext.cpp

    r70438 r73914  
    4747#include "MessagePort.h"
    4848#include "NotImplemented.h"
     49#include "ScriptCallStack.h"
    4950#include "ScriptSourceCode.h"
    5051#include "ScriptValue.h"
     
    103104    , m_thread(thread)
    104105    , m_closing(false)
    105     , m_reportingException(false)
    106106{
    107107    setSecurityOrigin(SecurityOrigin::create(url));
     
    260260}
    261261
    262 void WorkerContext::reportException(const String& errorMessage, int lineNumber, const String& sourceURL)
    263 {
    264     bool errorHandled = false;
    265     if (!m_reportingException) {
    266         if (onerror()) {
    267             m_reportingException = true;
    268             RefPtr<ErrorEvent> errorEvent(ErrorEvent::create(errorMessage, sourceURL, lineNumber));
    269             onerror()->handleEvent(this, errorEvent.get());
    270             errorHandled = errorEvent->defaultPrevented();
    271             m_reportingException = false;
    272         }
    273     }
    274     if (!errorHandled)
    275         thread()->workerReportingProxy().postExceptionToWorkerObject(errorMessage, lineNumber, sourceURL);
    276 }
    277 
    278 void WorkerContext::addMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL)
     262EventTarget* WorkerContext::errorEventTarget()
     263{
     264    return this;
     265}
     266
     267void WorkerContext::logExceptionToConsole(const String& errorMessage, int lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>)
     268{
     269    thread()->workerReportingProxy().postExceptionToWorkerObject(errorMessage, lineNumber, sourceURL);
     270}
     271
     272void WorkerContext::addMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>)
    279273{
    280274    thread()->workerReportingProxy().postConsoleMessageToWorkerObject(source, type, level, message, lineNumber, sourceURL);
  • trunk/WebCore/workers/WorkerContext.h

    r70102 r73914  
    101101
    102102        // ScriptExecutionContext
    103         virtual void reportException(const String& errorMessage, int lineNumber, const String& sourceURL);
    104         virtual void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL);
     103        virtual void addMessage(MessageSource, MessageType, MessageLevel, const String& message, unsigned lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>);
    105104
    106105#if ENABLE(NOTIFICATIONS)
     
    175174        virtual KURL virtualCompleteURL(const String&) const;
    176175
     176        virtual EventTarget* errorEventTarget();
     177        virtual void logExceptionToConsole(const String& errorMessage, int lineNumber, const String& sourceURL, PassRefPtr<ScriptCallStack>);
     178
    177179        KURL m_url;
    178180        String m_userAgent;
     
    188190#endif
    189191        bool m_closing;
    190         bool m_reportingException;
    191192        EventTargetData m_eventTargetData;
    192193
  • trunk/WebCore/workers/WorkerMessagingProxy.cpp

    r66850 r73914  
    4141#include "InspectorController.h"
    4242#include "MessageEvent.h"
     43#include "ScriptCallStack.h"
    4344#include "ScriptExecutionContext.h"
    4445#include "Worker.h"
     
    132133        bool errorHandled = !workerObject->dispatchEvent(ErrorEvent::create(m_errorMessage, m_sourceURL, m_lineNumber));
    133134        if (!errorHandled)
    134             context->reportException(m_errorMessage, m_lineNumber, m_sourceURL);
     135            context->reportException(m_errorMessage, m_lineNumber, m_sourceURL, 0);
    135136    }
    136137
     
    284285    if (messagingProxy->askedToTerminate())
    285286        return;
    286     context->addMessage(source, type, level, message, lineNumber, sourceURL);
     287    context->addMessage(source, type, level, message, lineNumber, sourceURL, 0);
    287288}
    288289
  • trunk/WebCore/xml/XMLHttpRequest.cpp

    r72985 r73914  
    4040#include "ResourceError.h"
    4141#include "ResourceRequest.h"
     42#include "ScriptCallStack.h"
    4243#include "SecurityOrigin.h"
    4344#include "Settings.h"
     
    812813    // FIXME: It's not good to report the bad usage without indicating what source line it came from.
    813814    // We should pass additional parameters so we can tell the console where the mistake occurred.
    814     context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, message, 1, String());
     815    context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, message, 1, String(), 0);
    815816}
    816817
  • trunk/WebKit/chromium/ChangeLog

    r73909 r73914  
     12010-12-13  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        WebCore doesn't fire window.onerror event when uncaught JavaScript exceptions are thrown
     6        https://bugs.webkit.org/show_bug.cgi?id=8519
     7
     8        Uncaught exceptions are propagated to window.onerror hander if one is present.
     9        The handler is expected to be a function accepting three arguments: error message,
     10        resource url and line number where the exception occured.
     11
     12        * src/WebWorkerClientImpl.cpp:
     13        (WebKit::WebWorkerClientImpl::postExceptionToWorkerObject):
     14        (WebKit::WebWorkerClientImpl::postExceptionToWorkerObjectTask):
     15
    1162010-12-13  Sheriff Bot  <webkit.review.bot@gmail.com>
    217
  • trunk/WebKit/chromium/src/WebWorkerClientImpl.cpp

    r62585 r73914  
    4242#include "MessagePort.h"
    4343#include "MessagePortChannel.h"
     44#include "ScriptCallStack.h"
    4445#include "ScriptExecutionContext.h"
    4546#include "Worker.h"
     
    248249                                                                lineNumber));
    249250    if (unhandled)
    250         m_scriptExecutionContext->reportException(errorMessage, lineNumber, sourceURL);
     251        m_scriptExecutionContext->reportException(errorMessage, lineNumber, sourceURL, 0);
    251252}
    252253
     
    275276                                         static_cast<MessageLevel>(messageLevel),
    276277                                         String(message), lineNumber,
    277                                          String(sourceURL));
     278                                         String(sourceURL), 0);
    278279}
    279280
     
    382383                                                                      lineNumber));
    383384    if (!handled)
    384         thisPtr->m_scriptExecutionContext->reportException(errorMessage,
    385                                                            lineNumber,
    386                                                            sourceURL);
     385        thisPtr->m_scriptExecutionContext->reportException(errorMessage, lineNumber, sourceURL, 0);
    387386}
    388387
     
    399398                                                  static_cast<MessageType>(messageType),
    400399                                                  static_cast<MessageLevel>(messageLevel),
    401                                                   message, lineNumber,
    402                                                   sourceURL);
     400                                                  message, lineNumber, sourceURL, 0);
    403401}
    404402
Note: See TracChangeset for help on using the changeset viewer.