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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp

Issue 2161003002: CustomElements: upgrade element patch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@upgrade-element
Patch Set: patch update Created 4 years, 5 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
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;
}

Powered by Google App Engine
This is Rietveld 408576698