From 89623771ba7288738b16d498d5f2c5404e2f1e10 Mon Sep 17 00:00:00 2001 From: "jianli@chromium.org" Date: Tue, 23 Jun 2009 21:23:30 +0000 Subject: Fix the V8 bindings problem that causes crash when an XHR exception is thrown in worker context. This is one of two patches needed for the fix. The other patch is https://bugs.webkit.org/show_bug.cgi?id=26626. BUG=14753 TEST=WebKit layout tests should cover this. Review URL: http://codereview.chromium.org/144008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19060 0039d316-1c4b-4281-b951-d872f2087c98 --- webkit/port/bindings/v8/v8_proxy.cpp | 41 +++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 15 deletions(-) (limited to 'webkit/port/bindings/v8/v8_proxy.cpp') diff --git a/webkit/port/bindings/v8/v8_proxy.cpp b/webkit/port/bindings/v8/v8_proxy.cpp index 1f2a669..26d727b 100644 --- a/webkit/port/bindings/v8/v8_proxy.cpp +++ b/webkit/port/bindings/v8/v8_proxy.cpp @@ -48,6 +48,7 @@ #include "ScriptController.h" #include "V8CustomBinding.h" #include "V8DOMMap.h" +#include "WorkerContextExecutionProxy.h" namespace WebCore { @@ -2272,6 +2273,16 @@ void V8Proxy::InitContextIfNeeded() m_frame->loader()->dispatchWindowObjectAvailable(); } +template +void setDOMExceptionHelper(V8ClassIndex::V8WrapperType type, PassRefPtr exception) { + v8::Handle v8Exception; + if (WorkerContextExecutionProxy::retrieve()) + v8Exception = WorkerContextExecutionProxy::ToV8Object(type, exception.get()); + else + v8Exception = V8Proxy::ToV8Object(type, exception.get()); + + v8::ThrowException(v8Exception); +} void V8Proxy::SetDOMException(int exception_code) { @@ -2284,37 +2295,37 @@ void V8Proxy::SetDOMException(int exception_code) v8::Handle exception; switch (description.type) { case DOMExceptionType: - exception = ToV8Object(V8ClassIndex::DOMCOREEXCEPTION, - DOMCoreException::create(description)); + setDOMExceptionHelper(V8ClassIndex::DOMCOREEXCEPTION, + DOMCoreException::create(description)); break; case RangeExceptionType: - exception = ToV8Object(V8ClassIndex::RANGEEXCEPTION, - RangeException::create(description)); + setDOMExceptionHelper(V8ClassIndex::RANGEEXCEPTION, + RangeException::create(description)); break; case EventExceptionType: - exception = ToV8Object(V8ClassIndex::EVENTEXCEPTION, - EventException::create(description)); + setDOMExceptionHelper(V8ClassIndex::EVENTEXCEPTION, + EventException::create(description)); break; case XMLHttpRequestExceptionType: - exception = ToV8Object(V8ClassIndex::XMLHTTPREQUESTEXCEPTION, - XMLHttpRequestException::create(description)); + setDOMExceptionHelper(V8ClassIndex::XMLHTTPREQUESTEXCEPTION, + XMLHttpRequestException::create(description)); break; #if ENABLE(SVG) case SVGExceptionType: - exception = ToV8Object(V8ClassIndex::SVGEXCEPTION, - SVGException::create(description)); + setDOMExceptionHelper(V8ClassIndex::SVGEXCEPTION, + SVGException::create(description)); break; #endif #if ENABLE(XPATH) case XPathExceptionType: - exception = ToV8Object(V8ClassIndex::XPATHEXCEPTION, - XPathException::create(description)); + setDOMExceptionHelper(V8ClassIndex::XPATHEXCEPTION, + XPathException::create(description)); break; #endif + default: + ASSERT(false); + break; } - - ASSERT(!exception.IsEmpty()); - v8::ThrowException(exception); } v8::Handle V8Proxy::ThrowError(ErrorType type, const char* message) -- cgit v1.1