Index: third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp |
diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp b/third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp |
index 342dff7dd84a2ae37a3408aa7e3997b9d989dd25..dfec7d7037378df2947dae5f79b48cda1e764473 100644 |
--- a/third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp |
+++ b/third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp |
@@ -9,10 +9,12 @@ |
#include "bindings/core/v8/V8BindingMacros.h" |
#include "bindings/core/v8/V8CustomElementsRegistry.h" |
#include "bindings/core/v8/V8Element.h" |
+#include "bindings/core/v8/V8ErrorHandler.h" |
#include "bindings/core/v8/V8HiddenValue.h" |
#include "bindings/core/v8/V8ScriptRunner.h" |
#include "bindings/core/v8/V8ThrowException.h" |
#include "core/dom/ExceptionCode.h" |
+#include "core/events/ErrorEvent.h" |
#include "core/html/HTMLElement.h" |
#include "core/html/HTMLUnknownElement.h" |
#include "v8.h" |
@@ -229,18 +231,29 @@ bool ScriptCustomElementDefinition::runConstructor(Element* element) |
tryCatch.SetVerbose(true); |
Element* result = runConstructor(); |
- if (!result) |
+ if (tryCatch.HasCaught()) |
return false; |
if (result != element) { |
+ const String& message = "custom element constructors must call super() first and must " |
haraken
2016/07/26 11:25:16
I want to create a helper method that runs line 23
|
+ "not return a different object"; |
V8ThrowException::throwException( |
V8ThrowException::createDOMException( |
m_scriptState->isolate(), |
InvalidStateError, |
- "custom element constructors must call super() first and must " |
- "not return a different object", |
+ message, |
constructor()), |
m_scriptState->isolate()); |
+ |
+ v8::Local<v8::Function> function = constructor().As<v8::Function>(); |
+ ErrorEvent* event = ErrorEvent::create( |
+ message, |
+ SourceLocation::fromFunction(function), |
+ &m_scriptState->world()); |
+ V8ErrorHandler::storeExceptionOnErrorEventWrapper(m_scriptState.get(), event, tryCatch.Exception(), m_scriptState->context()->Global()); |
haraken
2016/07/26 11:46:16
BTW, is this line needed?
e.g., Lazy event listen
|
+ ExecutionContext* executionContext = m_scriptState->getExecutionContext(); |
+ executionContext->reportException(event, NotSharableCrossOrigin); |
haraken
2016/07/22 09:31:53
Do we really need to report the exception synchron
|
+ |
return false; |
} |