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

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

Issue 2802223002: bindings: Throw a type error if converting an interface or callback function fails. (Closed)
Patch Set: Add |callback_function_name| to the callback function template Created 3 years, 8 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 | « no previous file | third_party/WebKit/Source/bindings/scripts/v8_callback_function.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImplTest.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImplTest.cpp b/third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImplTest.cpp
index 3e2e56ce433177b5b90a03ed9ba6b1117f852ecc..d9d8c3938923b55a0a903150b8a82afa47464dfb 100644
--- a/third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImplTest.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/NativeValueTraitsImplTest.cpp
@@ -7,8 +7,10 @@
#include <utility>
#include "bindings/core/v8/ExceptionState.h"
#include "bindings/core/v8/IDLTypes.h"
+#include "bindings/core/v8/TestSequenceCallback.h"
#include "bindings/core/v8/ToV8.h"
#include "bindings/core/v8/V8BindingForTesting.h"
+#include "bindings/core/v8/V8Internals.h"
#include "platform/wtf/Vector.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -21,6 +23,29 @@ v8::Local<v8::Value> ToV8(V8TestingScope* scope, T value) {
return blink::ToV8(value, scope->context()->Global(), scope->isolate());
}
+TEST(NativeValueTraitsImplTest, IDLInterface) {
+ V8TestingScope scope;
+ {
+ DummyExceptionStateForTesting exceptionState;
+ Internals* internals = NativeValueTraits<Internals>::nativeValue(
+ scope.isolate(), v8::Number::New(scope.isolate(), 42), exceptionState);
+ EXPECT_TRUE(exceptionState.hadException());
+ EXPECT_EQ("Unable to convert value to Internals.",
+ exceptionState.message());
+ EXPECT_EQ(nullptr, internals);
+ }
+ {
+ DummyExceptionStateForTesting exceptionState;
+ TestSequenceCallback* callbackFunction =
+ NativeValueTraits<TestSequenceCallback>::nativeValue(
+ scope.isolate(), v8::Undefined(scope.isolate()), exceptionState);
+ EXPECT_TRUE(exceptionState.hadException());
+ EXPECT_EQ("Unable to convert value to TestSequenceCallback.",
+ exceptionState.message());
+ EXPECT_EQ(nullptr, callbackFunction);
+ }
+}
+
void ThrowException(v8::Local<v8::Name>,
const v8::PropertyCallbackInfo<v8::Value>& info) {
info.GetIsolate()->ThrowException(v8String(info.GetIsolate(), "bogus!"));
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/scripts/v8_callback_function.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698