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

Unified Diff: Source/bindings/v8/V8Binding.h

Issue 30673002: More informative error messages for non-Transferables. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: More informative error messages for non-Transferables. Created 7 years, 2 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: Source/bindings/v8/V8Binding.h
diff --git a/Source/bindings/v8/V8Binding.h b/Source/bindings/v8/V8Binding.h
index d00ee43e8b3c5cb55fd7930df88ecd1f23e4280c..9f4a76ff59a5d9002a55e13c41ff338f1f51caba 100644
--- a/Source/bindings/v8/V8Binding.h
+++ b/Source/bindings/v8/V8Binding.h
@@ -75,7 +75,7 @@ namespace WebCore {
v8::ArrayBuffer::Allocator* v8ArrayBufferAllocator();
- v8::Handle<v8::Value> toV8Sequence(v8::Handle<v8::Value>, uint32_t& length, v8::Isolate*);
+ v8::Handle<v8::Value> toV8Sequence(v8::Handle<v8::Value>, uint32_t& length, v8::Isolate*, bool* notASequence = 0);
Mike West 2013/10/22 06:50:40 I think I'd prefer to keep the Isolate as the last
sof 2013/10/22 16:06:56 Done, and dropped the "nicety" of having the extra
inline v8::Handle<v8::Value> argumentOrNull(const v8::FunctionCallbackInfo<v8::Value>& args, int index)
{
@@ -510,7 +510,7 @@ namespace WebCore {
// Validates that the passed object is a sequence type per WebIDL spec
// http://www.w3.org/TR/2012/CR-WebIDL-20120419/#es-sequence
- inline v8::Handle<v8::Value> toV8Sequence(v8::Handle<v8::Value> value, uint32_t& length, v8::Isolate* isolate)
+ inline v8::Handle<v8::Value> toV8Sequence(v8::Handle<v8::Value> value, uint32_t& length, v8::Isolate* isolate, bool* notASequence)
{
// Attempt converting to a sequence if the value is not already an array but is
// any kind of object except for a native Date object or a native RegExp object.
@@ -518,7 +518,11 @@ namespace WebCore {
// FIXME: Do we really need to special case Date and RegExp object?
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=22806
if (!value->IsObject() || value->IsDate() || value->IsRegExp()) {
- throwTypeError(isolate);
+ // Signal that the caller must handle the type error.
+ if (notASequence)
+ *notASequence = true;
+ else
+ throwTypeError(isolate);
Mike West 2013/10/22 06:50:40 I'd be happy to review a subsequent patch that add
sof 2013/10/22 16:06:56 Definitely, I can have a look at improving that.
return v8Undefined();
}
@@ -531,7 +535,11 @@ namespace WebCore {
V8TRYCATCH(v8::Local<v8::Value>, lengthValue, object->Get(v8::String::NewSymbol("length")));
if (lengthValue->IsUndefined() || lengthValue->IsNull()) {
- throwTypeError(isolate);
+ // Signal that the caller must handle the type error.
+ if (notASequence)
+ *notASequence = true;
+ else
+ throwTypeError(isolate);
return v8Undefined();
}

Powered by Google App Engine
This is Rietveld 408576698