Commit 9f68e8db authored by yurys@chromium.org's avatar yurys@chromium.org

2010-04-05 Yury Semikhatsky <yurys@chromium.org>

        Unreviewed, revert r57078.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@57082 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d3762f6e
2010-04-05 Yury Semikhatsky <yurys@chromium.org>
Unreviewed, revert r57078.
* fast/workers/worker-script-error-expected.txt:
* fast/workers/worker-script-error.html:
2010-04-05 Dimitri Glazkov <dglazkov@chromium.org>
Reviewed by Darin Adler.
......
......@@ -4,7 +4,6 @@ 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: foo' at line 7.
PASS: onerror invoked for a script that has script error 'ReferenceError: Can't find variable: foo' at line 7.
......
......@@ -81,13 +81,9 @@ function testErrorInHandlingScriptError()
{
try {
var worker = new Worker("resources/worker-error-in-handling-script-error.js");
var errorCount = 0;
worker.onerror = function(evt) {
log("PASS: onerror invoked for a script that has script error '" + evt.message + "' at line " + evt.lineno + ".");
++errorCount;
// Second error happens in the onerror handler. Run next test only when it's reported.
if (errorCount == 2)
runNextTest();
runNextTest();
return false;
}
} catch (ex) {
......
......@@ -157,7 +157,6 @@ LOCAL_SRC_FILES += \
bindings/js/JSWorkerConstructor.cpp \
bindings/js/JSWorkerContextBase.cpp \
bindings/js/JSWorkerContextCustom.cpp \
bindings/js/JSWorkerContextErrorHandler.cpp \
bindings/js/JSWorkerCustom.cpp \
bindings/js/JSXMLHttpRequestConstructor.cpp \
bindings/js/JSXMLHttpRequestCustom.cpp \
......
2010-04-05 Yury Semikhatsky <yurys@chromium.org>
Unreviewed, revert r57078.
* Android.jscbindings.mk:
* GNUmakefile.am:
* WebCore.gypi:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSEventListener.cpp:
(WebCore::JSEventListener::reportError):
* bindings/js/JSEventListener.h:
* bindings/js/JSWorkerContextErrorHandler.cpp: Removed.
* bindings/js/JSWorkerContextErrorHandler.h: Removed.
* bindings/scripts/CodeGeneratorJS.pm:
* bindings/scripts/CodeGeneratorV8.pm:
* bindings/v8/V8WorkerContextErrorHandler.cpp: Removed.
* bindings/v8/V8WorkerContextErrorHandler.h: Removed.
* bindings/v8/V8WorkerContextEventListener.cpp:
(WebCore::V8WorkerContextEventListener::reportError):
* bindings/v8/V8WorkerContextEventListener.h:
* dom/EventListener.h:
(WebCore::EventListener::reportError):
* workers/WorkerContext.cpp:
(WebCore::WorkerContext::WorkerContext):
(WebCore::WorkerContext::reportException):
* workers/WorkerContext.h:
2010-04-05 Dimitri Glazkov <dglazkov@chromium.org>
Reviewed by Darin Adler.
......@@ -473,8 +473,6 @@ webcore_sources += \
WebCore/bindings/js/JSWebKitCSSMatrixConstructor.h \
WebCore/bindings/js/JSWebKitPointConstructor.cpp \
WebCore/bindings/js/JSWebKitPointConstructor.h \
WebCore/bindings/js/JSWorkerContextErrorHandler.cpp \
WebCore/bindings/js/JSWorkerContextErrorHandler.h \
WebCore/bindings/js/JSXMLHttpRequestConstructor.cpp \
WebCore/bindings/js/JSXMLHttpRequestConstructor.h \
WebCore/bindings/js/JSXMLHttpRequestCustom.cpp \
......
......@@ -624,8 +624,6 @@
'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/JSXMLHttpRequestConstructor.cpp',
'bindings/js/JSXMLHttpRequestConstructor.h',
......@@ -888,8 +886,6 @@
'bindings/v8/V8SVGPODTypeWrapper.h',
'bindings/v8/V8Utilities.cpp',
'bindings/v8/V8Utilities.h',
'bindings/v8/V8WorkerContextErrorHandler.cpp',
'bindings/v8/V8WorkerContextErrorHandler.h',
'bindings/v8/V8WorkerContextEventListener.cpp',
'bindings/v8/V8WorkerContextEventListener.h',
'bindings/v8/WorkerContextExecutionProxy.h',
......
......@@ -363,7 +363,6 @@ SOURCES += \
bindings/js/JSLazyEventListener.cpp \
bindings/js/JSPluginElementFunctions.cpp \
bindings/js/JSPopStateEventCustom.cpp \
bindings/js/JSWorkerContextErrorHandler.cpp \
bindings/js/JavaScriptProfile.h \
bindings/js/JavaScriptProfileNode.h \
bindings/js/JavaScriptProfile.cpp \
......@@ -1072,7 +1071,7 @@ HEADERS += \
bindings/js/JSWebKitPointConstructor.h \
bindings/js/JSWorkerConstructor.h \
bindings/js/JSWorkerContextBase.h \
bindings/js/JSWorkerContextErrorHandler.h \
bindings/js/JSWorkerContextBase.h \
bindings/js/JSXMLHttpRequestConstructor.h \
bindings/js/JSXSLTProcessorConstructor.h \
bindings/js/ScheduledAction.h \
......
......@@ -40063,61 +40063,6 @@
/>
</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_Internal|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug_Cairo|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Release_Cairo|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug_All|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\bindings\js\JSWorkerContextErrorHandler.h"
>
</File>
<File
RelativePath="..\bindings\js\JSXMLHttpRequestConstructor.cpp"
>
......
......@@ -4893,8 +4893,6 @@
F3644AFF1119805900E0D537 /* InjectedScript.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F3644AFD1119805900E0D537 /* InjectedScript.cpp */; };
F3644B001119805900E0D537 /* InjectedScript.h in Headers */ = {isa = PBXBuildFile; fileRef = F3644AFE1119805900E0D537 /* InjectedScript.h */; };
F375CC071150D300008DDB81 /* InspectorWorkerResource.h in Headers */ = {isa = PBXBuildFile; fileRef = F375CC061150D300008DDB81 /* InspectorWorkerResource.h */; };
F3D461481161D53200CA0D09 /* JSWorkerContextErrorHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F3D461461161D53200CA0D09 /* JSWorkerContextErrorHandler.cpp */; };
F3D461491161D53200CA0D09 /* JSWorkerContextErrorHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = F3D461471161D53200CA0D09 /* JSWorkerContextErrorHandler.h */; };
F4EAF4AE10C742B1009100D3 /* OpenTypeSanitizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F4EAF4AC10C742B1009100D3 /* OpenTypeSanitizer.cpp */; };
F4EAF4AF10C742B1009100D3 /* OpenTypeSanitizer.h in Headers */ = {isa = PBXBuildFile; fileRef = F4EAF4AD10C742B1009100D3 /* OpenTypeSanitizer.h */; };
F5C041DA0FFCA7CE00839D4A /* HTMLDataListElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F5C041D70FFCA7CE00839D4A /* HTMLDataListElement.cpp */; };
......@@ -10266,8 +10264,6 @@
F3644AFD1119805900E0D537 /* InjectedScript.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InjectedScript.cpp; sourceTree = "<group>"; };
F3644AFE1119805900E0D537 /* InjectedScript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectedScript.h; sourceTree = "<group>"; };
F375CC061150D300008DDB81 /* InspectorWorkerResource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorWorkerResource.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>"; };
F4EAF4AC10C742B1009100D3 /* OpenTypeSanitizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OpenTypeSanitizer.cpp; path = opentype/OpenTypeSanitizer.cpp; sourceTree = "<group>"; };
F4EAF4AD10C742B1009100D3 /* OpenTypeSanitizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OpenTypeSanitizer.h; path = opentype/OpenTypeSanitizer.h; sourceTree = "<group>"; };
F523D23B02DE4396018635CA /* HTMLDocument.cpp */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLDocument.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
......@@ -14857,8 +14853,6 @@
B21127A50B3186770009BE53 /* JSSVGPODTypeWrapper.h */,
E1C36D320EB0A094007410BC /* JSWorkerContextBase.cpp */,
E1C36D330EB0A094007410BC /* JSWorkerContextBase.h */,
F3D461461161D53200CA0D09 /* JSWorkerContextErrorHandler.cpp */,
F3D461471161D53200CA0D09 /* JSWorkerContextErrorHandler.h */,
BCA378BA0D15F64200B793D6 /* ScheduledAction.cpp */,
BCA378BB0D15F64200B793D6 /* ScheduledAction.h */,
7A1E88F3101CC384000C4DF5 /* ScriptArray.cpp */,
......@@ -17961,7 +17955,6 @@
E1CA5CD30E8CDE8000E8EF90 /* JSWorkerConstructor.h in Headers */,
E18256900EF2B02D00933242 /* JSWorkerContext.h in Headers */,
E1C36D350EB0A094007410BC /* JSWorkerContextBase.h in Headers */,
F3D461491161D53200CA0D09 /* JSWorkerContextErrorHandler.h in Headers */,
E1C362EF0EAF2AA9007410BC /* JSWorkerLocation.h in Headers */,
E1271A580EEECDE400F61213 /* JSWorkerNavigator.h in Headers */,
BC348BD40DB7F804004ABAB9 /* JSXMLHttpRequest.h in Headers */,
......@@ -20277,7 +20270,6 @@
E182568F0EF2B02D00933242 /* JSWorkerContext.cpp in Sources */,
E1C36D340EB0A094007410BC /* JSWorkerContextBase.cpp in Sources */,
E18258AC0EF3CD7000933242 /* JSWorkerContextCustom.cpp in Sources */,
F3D461481161D53200CA0D09 /* JSWorkerContextErrorHandler.cpp in Sources */,
E1CA5CBC0E8CDCAF00E8EF90 /* JSWorkerCustom.cpp in Sources */,
E1C362F00EAF2AA9007410BC /* JSWorkerLocation.cpp in Sources */,
E1271A590EEECDE400F61213 /* JSWorkerNavigator.cpp in Sources */,
......@@ -133,6 +133,47 @@ void JSEventListener::handleEvent(ScriptExecutionContext* scriptExecutionContext
}
}
bool JSEventListener::reportError(ScriptExecutionContext* context, const String& message, const String& url, int lineNumber)
{
JSLock lock(SilenceAssertionsOnly);
JSObject* jsFunction = this->jsFunction(context);
if (!jsFunction)
return false;
JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(context, m_isolatedWorld.get());
ExecState* exec = globalObject->globalExec();
CallData callData;
CallType callType = jsFunction->getCallData(callData);
if (callType == CallTypeNone)
return false;
MarkedArgumentBuffer args;
args.append(jsString(exec, message));
args.append(jsString(exec, url));
args.append(jsNumber(exec, lineNumber));
JSGlobalData* globalData = globalObject->globalData();
DynamicGlobalObjectScope globalObjectScope(exec, globalData->dynamicGlobalObject ? globalData->dynamicGlobalObject : globalObject);
JSValue thisValue = globalObject->toThisObject(exec);
globalData->timeoutChecker.start();
JSValue returnValue = JSC::call(exec, jsFunction, callType, callData, thisValue, args);
globalData->timeoutChecker.stop();
// If an error occurs while handling the script error, it should be bubbled up.
if (exec->hadException()) {
exec->clearException();
return false;
}
bool bubbleEvent;
return returnValue.getBoolean(bubbleEvent) && !bubbleEvent;
}
bool JSEventListener::virtualisAttribute() const
{
return m_isAttribute;
......
......@@ -60,6 +60,7 @@ namespace WebCore {
virtual void markJSFunction(JSC::MarkStack&);
virtual void invalidateJSFunction(JSC::JSObject*);
virtual void handleEvent(ScriptExecutionContext*, Event*);
virtual bool reportError(ScriptExecutionContext*, const String& message, const String& url, int lineNumber);
virtual bool virtualisAttribute() const;
protected:
......
/*
* 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 "JSWorkerContextErrorHandler.h"
#include "ErrorEvent.h"
#include "Event.h"
#include "JSEvent.h"
#include <runtime/JSLock.h>
using namespace JSC;
namespace WebCore {
JSWorkerContextErrorHandler::JSWorkerContextErrorHandler(JSObject* function, JSObject* wrapper, bool isAttribute, DOMWrapperWorld* isolatedWorld)
: JSEventListener(function, wrapper, isAttribute, isolatedWorld)
{
}
JSWorkerContextErrorHandler::~JSWorkerContextErrorHandler()
{
}
void JSWorkerContextErrorHandler::handleEvent(ScriptExecutionContext* scriptExecutionContext, Event* event)
{
ASSERT(scriptExecutionContext);
if (!scriptExecutionContext)
return;
JSLock lock(SilenceAssertionsOnly);
JSObject* jsFunction = this->jsFunction(scriptExecutionContext);
if (!jsFunction)
return;
JSDOMGlobalObject* globalObject = toJSDOMGlobalObject(scriptExecutionContext, isolatedWorld());
if (!globalObject)
return;
ExecState* exec = globalObject->globalExec();
CallData callData;
CallType callType = jsFunction->getCallData(callData);
if (callType != CallTypeNone) {
ref();
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()));
args.append(jsNumber(exec, errorEvent->lineno()));
JSGlobalData* globalData = globalObject->globalData();
DynamicGlobalObjectScope globalObjectScope(exec, globalData->dynamicGlobalObject ? globalData->dynamicGlobalObject : globalObject);
JSValue thisValue = globalObject->toThisObject(exec);
globalData->timeoutChecker.start();
JSValue returnValue = JSC::call(exec, jsFunction, callType, callData, thisValue, args);
globalData->timeoutChecker.stop();
globalObject->setCurrentEvent(savedEvent);
if (exec->hadException())
reportCurrentException(exec);
else {
bool retvalbool;
if (returnValue.getBoolean(retvalbool) && !retvalbool)
event->preventDefault();
}
deref();
}
}
} // namespace WebCore
/*
* 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 JSWorkerContextErrorHandler_h
#define JSWorkerContextErrorHandler_h
#include "JSEventListener.h"
namespace WebCore {
class JSWorkerContextErrorHandler : public JSEventListener {
public:
static PassRefPtr<JSWorkerContextErrorHandler> create(JSC::JSObject* listener, JSC::JSObject* wrapper, bool isAttribute, DOMWrapperWorld* isolatedWorld)
{
return adoptRef(new JSWorkerContextErrorHandler(listener, wrapper, isAttribute, isolatedWorld));
}
virtual ~JSWorkerContextErrorHandler();
private:
JSWorkerContextErrorHandler(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)
{
if (!listener.isObject())
return 0;
return JSWorkerContextErrorHandler::create(asObject(listener), wrapper, true, currentWorld(exec));
}
} // namespace WebCore
#endif // JSWorkerContextErrorHandler_h
......@@ -1484,12 +1484,7 @@ sub GenerateImplementation
$implIncludes{"JSEventListener.h"} = 1;
push(@implContent, " UNUSED_PARAM(exec);\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");
} else {
push(@implContent, " imp->set$implSetterFunctionName(createJSAttributeEventListener(exec, value, thisObject));\n");
}
push(@implContent, " imp->set$implSetterFunctionName(createJSAttributeEventListener(exec, value, thisObject));\n");
} elsif ($attribute->signature->type =~ /Constructor$/) {
my $constructorType = $attribute->signature->type;
$constructorType =~ s/Constructor$//;
......
......@@ -911,13 +911,7 @@ END
} elsif ($attribute->signature->type eq "EventListener") {
$implIncludes{"V8AbstractEventListener.h"} = 1;
push(@implContentDecls, " transferHiddenDependency(info.Holder(), imp->$attrName(), value, V8${interfaceName}::eventListenerCacheIndex);\n");
if ($interfaceName eq "WorkerContext" and $attribute->signature->name eq "onerror") {
$implIncludes{"V8EventListenerList.h"} = 1;
$implIncludes{"V8WorkerContextErrorHandler.h"} = 1;
push(@implContentDecls, " imp->set$implSetterFunctionName(V8EventListenerList::findOrCreateWrapper<V8WorkerContextErrorHandler>(value, true)");
} else {
push(@implContentDecls, " imp->set$implSetterFunctionName(V8DOMWrapper::getEventListener(value, true, ListenerFindOrCreate)");
}
push(@implContentDecls, " imp->set$implSetterFunctionName(V8DOMWrapper::getEventListener(value, true, ListenerFindOrCreate)");
} else {
push(@implContentDecls, " imp->set$implSetterFunctionName($result");
}
......
/*
* 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"
#if ENABLE(WORKERS)
#include "V8WorkerContextErrorHandler.h"
#include "ErrorEvent.h"
#include "V8Binding.h"
namespace WebCore {
V8WorkerContextErrorHandler::V8WorkerContextErrorHandler(v8::Local<v8::Object> listener, bool isInline, const WorldContextHandle& worldContext)
: V8WorkerContextEventListener(listener, isInline, worldContext)
{
}
v8::Local<v8::Value> V8WorkerContextErrorHandler::callListenerFunction(ScriptExecutionContext* context, v8::Handle<v8::Value> jsEvent, Event* event)
{
ASSERT(event->isErrorEvent());
v8::Local<v8::Object> listener = getListenerObject(context);
v8::Local<v8::Value> returnValue;
if (!listener.IsEmpty() && listener->IsFunction()) {
ErrorEvent* errorEvent = static_cast<ErrorEvent*>(event);
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
#endif // WORKERS
/*
* 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 V8WorkerContextErrorHandler_h
#define V8WorkerContextErrorHandler_h
#if ENABLE(WORKERS)
#include "V8WorkerContextEventListener.h"
#include <v8.h>
#include <wtf/PassRefPtr.h>
namespace WebCore {
class V8WorkerContextErrorHandler : public V8WorkerContextEventListener {
public:
static PassRefPtr<V8WorkerContextErrorHandler> create(v8::Local<v8::Object> listener, bool isInline, const WorldContextHandle& worldContext)
{
return adoptRef(new V8WorkerContextErrorHandler(listener, isInline, worldContext));
}
private:
V8WorkerContextErrorHandler(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 // WORKERS
#endif // V8WorkerContextErrorHandler_h
......@@ -82,6 +82,56 @@ void V8WorkerContextEventListener::handleEvent(ScriptExecutionContext* context,
invokeEventHandler(context, event, jsEvent);
}
bool V8WorkerContextEventListener::reportError(ScriptExecutionContext* context, const String& message, const String& url, int lineNumber)
{
if (!context)
return false;