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

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

Issue 2244203002: Fix "report the exception" in Custom Elements V1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: New approach to use TryCatch::ReThrow Created 4 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
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 6c7b1e3de4e39b0513efb14349dddf12a81ff0b4..77161073a5eae4edfa6169df18935a0db2b1e633 100644
--- a/third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/ScriptCustomElementDefinition.cpp
@@ -189,6 +189,20 @@ HTMLElement* ScriptCustomElementDefinition::createElementSync(
return toHTMLElement(element);
}
+static void dispatchErrorEvent(ExceptionState& exceptionState)
+{
+ // Report an exception
+ // https://html.spec.whatwg.org/multipage/webappapis.html#report-the-exception
+ DCHECK(exceptionState.hadException());
+ v8::TryCatch tryCatch(exceptionState.isolate());
+ tryCatch.SetVerbose(true);
+ exceptionState.throwIfNeeded();
+ tryCatch.ReThrow();
Yuki 2016/08/19 07:31:33 This usage is simply wrong.
+
+ // Clear the ExceptionState since it's handled.
+ exceptionState.clearException();
+}
+
HTMLElement* ScriptCustomElementDefinition::createElementSync(
Document& document, const QualifiedName& tagName)
{
@@ -202,16 +216,13 @@ HTMLElement* ScriptCustomElementDefinition::createElementSync(
"CustomElement", constructor(), isolate);
HTMLElement* element = createElementSync(document, tagName, exceptionState);
- if (exceptionState.hadException() || !element) {
+ if (exceptionState.hadException()) {
+ DCHECK(!element);
// 7. If this step throws an exception, then report the exception, ...
- {
- v8::TryCatch tryCatch(isolate);
- tryCatch.SetVerbose(true);
- exceptionState.throwIfNeeded();
- }
-
+ dispatchErrorEvent(exceptionState);
return CustomElement::createFailedElement(document, tagName);
}
+ DCHECK(element);
return element;
}

Powered by Google App Engine
This is Rietveld 408576698