Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(406)

Unified Diff: Source/bindings/v8/V8Initializer.cpp

Issue 22650008: Add 'error' property to exceptions thrown via Worker::importScripts. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Feedback. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/bindings/v8/V8ErrorHandler.cpp ('k') | Source/bindings/v8/WorkerScriptController.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/v8/V8Initializer.cpp
diff --git a/Source/bindings/v8/V8Initializer.cpp b/Source/bindings/v8/V8Initializer.cpp
index fa8be8f0948c6ef17a96a92aa343c1f988aaf8b4..d2e2d9c26a1e2b149bc5fc1e486d06d518e791fe 100644
--- a/Source/bindings/v8/V8Initializer.cpp
+++ b/Source/bindings/v8/V8Initializer.cpp
@@ -35,6 +35,7 @@
#include "bindings/v8/ScriptController.h"
#include "bindings/v8/ScriptProfiler.h"
#include "bindings/v8/V8Binding.h"
+#include "bindings/v8/V8ErrorHandler.h"
#include "bindings/v8/V8GCController.h"
#include "bindings/v8/V8HiddenPropertyName.h"
#include "bindings/v8/V8PerContextData.h"
@@ -46,9 +47,9 @@
#include "core/page/DOMWindow.h"
#include "core/page/Frame.h"
#include "core/platform/MemoryUsageSupport.h"
-#include <v8-debug.h>
#include "wtf/RefPtr.h"
#include "wtf/text/WTFString.h"
+#include <v8-debug.h>
namespace WebCore {
@@ -99,20 +100,14 @@ static void messageHandlerInMainThread(v8::Handle<v8::Message> message, v8::Hand
bool shouldUseDocumentURL = resourceName.IsEmpty() || !resourceName->IsString();
String resource = shouldUseDocumentURL ? firstWindow->document()->url() : toWebCoreString(resourceName);
RefPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, resource, message->GetLineNumber(), message->GetStartColumn());
+ AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? SharableCrossOrigin : NotSharableCrossOrigin;
- // messageHandlerInMainThread can be called while we're creating a new context.
- // Since we cannot create a wrapper in the intermediate timing, we need to skip
- // creating a wrapper for |event|.
+ // This method might be called while we're creating a new context. In this case, we
+ // avoid storing the exception object, as we can't create a wrapper during context creation.
DOMWrapperWorld* world = DOMWrapperWorld::current();
Frame* frame = firstWindow->document()->frame();
- if (world && frame && frame->script()->existingWindowShell(world)) {
- v8::Local<v8::Value> wrappedEvent = toV8(event.get(), v8::Handle<v8::Object>(), v8::Isolate::GetCurrent());
- if (!wrappedEvent.IsEmpty()) {
- ASSERT(wrappedEvent->IsObject());
- v8::Local<v8::Object>::Cast(wrappedEvent)->SetHiddenValue(V8HiddenPropertyName::error(), data);
- }
- }
- AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? SharableCrossOrigin : NotSharableCrossOrigin;
+ if (world && frame && frame->script()->existingWindowShell(world))
+ V8ErrorHandler::storeExceptionOnErrorEventWrapper(event.get(), data, v8::Isolate::GetCurrent());
firstWindow->document()->reportException(event.release(), callStack, corsStatus);
}
@@ -183,12 +178,9 @@ static void messageHandlerInWorker(v8::Handle<v8::Message> message, v8::Handle<v
String errorMessage = toWebCoreString(message->Get());
String sourceURL = toWebCoreString(message->GetScriptResourceName());
RefPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, sourceURL, message->GetLineNumber(), message->GetStartColumn());
- v8::Local<v8::Value> wrappedEvent = toV8(event.get(), v8::Handle<v8::Object>(), v8::Isolate::GetCurrent());
- if (!wrappedEvent.IsEmpty()) {
- ASSERT(wrappedEvent->IsObject());
- v8::Local<v8::Object>::Cast(wrappedEvent)->SetHiddenValue(V8HiddenPropertyName::error(), data);
- }
AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? SharableCrossOrigin : NotSharableCrossOrigin;
+
+ V8ErrorHandler::storeExceptionOnErrorEventWrapper(event.get(), data, v8::Isolate::GetCurrent());
context->reportException(event.release(), 0, corsStatus);
}
« no previous file with comments | « Source/bindings/v8/V8ErrorHandler.cpp ('k') | Source/bindings/v8/WorkerScriptController.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698