Chromium Code Reviews| 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; |
| } |