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

Unified Diff: Source/bindings/core/v8/custom/V8NodeCustom.cpp

Issue 374093002: Node.appendChild should throw TypeError when newChild is not an object (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix layout test Created 6 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
« no previous file with comments | « LayoutTests/fast/dom/timer-clear-interval-in-handler-and-generate-error-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/core/v8/custom/V8NodeCustom.cpp
diff --git a/Source/bindings/core/v8/custom/V8NodeCustom.cpp b/Source/bindings/core/v8/custom/V8NodeCustom.cpp
index ab10930bf62ed71c7789c94a111dd555097dd4e6..cdd3cab222ab30541d81aa14281e3f8c3ebf974c 100644
--- a/Source/bindings/core/v8/custom/V8NodeCustom.cpp
+++ b/Source/bindings/core/v8/custom/V8NodeCustom.cpp
@@ -107,16 +107,25 @@ void V8Node::removeChildMethodCustom(const v8::FunctionCallbackInfo<v8::Value>&
void V8Node::appendChildMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- v8::Handle<v8::Object> holder = info.Holder();
- Node* impl = V8Node::toNative(holder);
-
- CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope;
-
ExceptionState exceptionState(ExceptionState::ExecutionContext, "appendChild", "Node", info.Holder(), info.GetIsolate());
- Node* newChild = V8Node::toNativeWithTypeCheck(info.GetIsolate(), info[0]);
+ Node* impl = V8Node::toNative(info.Holder());
+ CustomElementCallbackDispatcher::CallbackDeliveryScope deliveryScope;
+ Node* newChild;
+ {
+ v8::TryCatch block;
+ V8RethrowTryCatchScope rethrow(block);
+ if (info.Length() > 0 && !V8Node::hasInstance(info[0], info.GetIsolate())) {
+ exceptionState.throwTypeError("parameter 1 is not of type 'Node'.");
+ exceptionState.throwIfNeeded();
+ return;
+ }
+ TONATIVE_VOID_INTERNAL(newChild, V8Node::toNativeWithTypeCheck(info.GetIsolate(), info[0]));
+ }
impl->appendChild(newChild, exceptionState);
- if (exceptionState.throwIfNeeded())
+ if (exceptionState.hadException()) {
+ exceptionState.throwIfNeeded();
return;
+ }
v8SetReturnValue(info, info[0]);
}
« no previous file with comments | « LayoutTests/fast/dom/timer-clear-interval-in-handler-and-generate-error-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698