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

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: workflow commit 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..3bacdefd5ff9de2bdb91edee14ac44fd60984f0c 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,7 +231,7 @@ bool ScriptCustomElementDefinition::runConstructor(Element* element)
tryCatch.SetVerbose(true);
Element* result = runConstructor();
- if (!result)
+ if (tryCatch.HasCaught())
return false;
if (result != element) {
@@ -241,6 +243,19 @@ bool ScriptCustomElementDefinition::runConstructor(Element* element)
"not return a different object",
constructor()),
m_scriptState->isolate());
+
+ ExecutionContext* executionContext = m_scriptState->getExecutionContext();
dominicc (has gone to gerrit) 2016/07/22 07:34:08 Could you move this line closer to where it is use
+ v8::Local<v8::Function> function = constructor().As<v8::Function>();
+ ErrorEvent* event = ErrorEvent::create(
+ "custom element constructors must call super() first and must"
+ "not return a different object",
+ SourceLocation::fromFunction(function),
+ &m_scriptState->world());
+ v8::Local<v8::Value> data = tryCatch.Exception();
dominicc (has gone to gerrit) 2016/07/22 07:34:08 I don't think "data" is a very descriptive name. M
+
+ V8ErrorHandler::storeExceptionOnErrorEventWrapper(m_scriptState.get(), event, data, m_scriptState->context()->Global());
+ executionContext->reportException(event, NotSharableCrossOrigin);
+
return false;
}

Powered by Google App Engine
This is Rietveld 408576698