Index: third_party/WebKit/Source/bindings/modules/v8/V8BindingForModules.cpp |
diff --git a/third_party/WebKit/Source/bindings/modules/v8/V8BindingForModules.cpp b/third_party/WebKit/Source/bindings/modules/v8/V8BindingForModules.cpp |
index aa8877c95d1639df5c10f447eaa832765ef66e77..b0d854ce7b81ab03baa67496542bf16bfc8cfefb 100644 |
--- a/third_party/WebKit/Source/bindings/modules/v8/V8BindingForModules.cpp |
+++ b/third_party/WebKit/Source/bindings/modules/v8/V8BindingForModules.cpp |
@@ -96,9 +96,16 @@ v8::Local<v8::Value> toV8(const IDBKey* key, v8::Local<v8::Object> creationConte |
case IDBKey::StringType: |
return v8String(isolate, key->string()); |
case IDBKey::BinaryType: |
- // Experimental feature: binary keys |
- // https://w3c.github.io/IndexedDB/#steps-to-convert-a-key-to-a-value |
- return toV8(DOMArrayBuffer::create(reinterpret_cast<const unsigned char*>(key->binary()->data()), key->binary()->size()), creationContext, isolate); |
+ { |
+ // Experimental feature: binary keys |
+ // https://w3c.github.io/IndexedDB/#steps-to-convert-a-key-to-a-value |
+ RefPtr<DOMArrayBuffer> buffer = DOMArrayBuffer::createOrNull(reinterpret_cast<const unsigned char*>(key->binary()->data()), key->binary()->size()); |
+ if (!buffer) { |
+ isolate->ThrowException(v8::Exception::RangeError(v8::String::NewFromUtf8(isolate, "Out of memory. Failed to allocate ArrayBuffer."))); |
jsbell
2015/10/16 22:12:24
This is going to be weird behavior! The scenario w
jsbell
2015/10/16 22:16:26
Hrm, I'm an idiot... this *also* applies to *value
Justin Novosad
2015/10/19 16:42:52
For this initial CL, I want to stay clear of anyth
|
+ return v8Undefined(); |
+ } |
+ return toV8(buffer, creationContext, isolate); |
+ } |
case IDBKey::DateType: |
return v8::Date::New(context, key->date()).ToLocalChecked(); |
case IDBKey::ArrayType: |
@@ -185,7 +192,12 @@ static IDBKey* createIDBKeyFromValue(v8::Isolate* isolate, v8::Local<v8::Value> |
} |
if (value->IsArrayBufferView()) { |
DOMArrayBufferView* view = V8ArrayBufferView::toImpl(value.As<v8::Object>()); |
- if (view->buffer()->isNeutered()) { |
+ RefPtr<DOMArrayBuffer> buffer = view->bufferOrNull(); |
+ if (!buffer) { |
jsbell
2015/10/16 22:12:24
The usage here is that script has passed a view in
Justin Novosad
2015/10/19 16:42:52
Acknowledged.
|
+ exceptionState.throwRangeError("Out of Momory."); |
binji
2015/10/16 22:12:39
sp: memory
Justin Novosad
2015/10/19 16:42:52
Acknowledged.
|
+ return nullptr; |
+ } |
+ if (buffer->isNeutered()) { |
exceptionState.throwTypeError("The viewed ArrayBuffer is neutered."); |
return nullptr; |
} |