OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 v8::Local<v8::Object> creation_context, | 66 v8::Local<v8::Object> creation_context, |
67 v8::Isolate* isolate) { | 67 v8::Isolate* isolate) { |
68 switch (value.GetType()) { | 68 switch (value.GetType()) { |
69 case IDBKeyPath::kNullType: | 69 case IDBKeyPath::kNullType: |
70 return v8::Null(isolate); | 70 return v8::Null(isolate); |
71 case IDBKeyPath::kStringType: | 71 case IDBKeyPath::kStringType: |
72 return V8String(isolate, value.GetString()); | 72 return V8String(isolate, value.GetString()); |
73 case IDBKeyPath::kArrayType: | 73 case IDBKeyPath::kArrayType: |
74 return ToV8(value.Array(), creation_context, isolate); | 74 return ToV8(value.Array(), creation_context, isolate); |
75 } | 75 } |
76 ASSERT_NOT_REACHED(); | 76 NOTREACHED(); |
77 return v8::Undefined(isolate); | 77 return v8::Undefined(isolate); |
78 } | 78 } |
79 | 79 |
80 v8::Local<v8::Value> ToV8(const IDBKey* key, | 80 v8::Local<v8::Value> ToV8(const IDBKey* key, |
81 v8::Local<v8::Object> creation_context, | 81 v8::Local<v8::Object> creation_context, |
82 v8::Isolate* isolate) { | 82 v8::Isolate* isolate) { |
83 if (!key) { | 83 if (!key) { |
84 // The IndexedDB spec requires that absent keys appear as attribute | 84 // The IndexedDB spec requires that absent keys appear as attribute |
85 // values as undefined, rather than the more typical (for DOM) null. | 85 // values as undefined, rather than the more typical (for DOM) null. |
86 // This appears on the |upper| and |lower| attributes of IDBKeyRange. | 86 // This appears on the |upper| and |lower| attributes of IDBKeyRange. |
(...skipping 27 matching lines...) Expand all Loading... |
114 ToV8(key->Array()[i].Get(), creation_context, isolate); | 114 ToV8(key->Array()[i].Get(), creation_context, isolate); |
115 if (value.IsEmpty()) | 115 if (value.IsEmpty()) |
116 value = v8::Undefined(isolate); | 116 value = v8::Undefined(isolate); |
117 if (!V8CallBoolean(array->CreateDataProperty(context, i, value))) | 117 if (!V8CallBoolean(array->CreateDataProperty(context, i, value))) |
118 return V8Undefined(); | 118 return V8Undefined(); |
119 } | 119 } |
120 return array; | 120 return array; |
121 } | 121 } |
122 } | 122 } |
123 | 123 |
124 ASSERT_NOT_REACHED(); | 124 NOTREACHED(); |
125 return V8Undefined(); | 125 return V8Undefined(); |
126 } | 126 } |
127 | 127 |
128 // IDBAny is a variant type used to hold the values produced by the |result| | 128 // IDBAny is a variant type used to hold the values produced by the |result| |
129 // attribute of IDBRequest and (as a convenience) the |source| attribute of | 129 // attribute of IDBRequest and (as a convenience) the |source| attribute of |
130 // IDBRequest and IDBCursor. | 130 // IDBRequest and IDBCursor. |
131 // TODO(jsbell): Replace the use of IDBAny for |source| attributes (which are | 131 // TODO(jsbell): Replace the use of IDBAny for |source| attributes (which are |
132 // ScriptWrappable types) using unions per IDL. | 132 // ScriptWrappable types) using unions per IDL. |
133 v8::Local<v8::Value> ToV8(const IDBAny* impl, | 133 v8::Local<v8::Value> ToV8(const IDBAny* impl, |
134 v8::Local<v8::Object> creation_context, | 134 v8::Local<v8::Object> creation_context, |
(...skipping 22 matching lines...) Expand all Loading... |
157 return DeserializeIDBValue(isolate, creation_context, impl->Value()); | 157 return DeserializeIDBValue(isolate, creation_context, impl->Value()); |
158 case IDBAny::kIDBValueArrayType: | 158 case IDBAny::kIDBValueArrayType: |
159 return DeserializeIDBValueArray(isolate, creation_context, | 159 return DeserializeIDBValueArray(isolate, creation_context, |
160 impl->Values()); | 160 impl->Values()); |
161 case IDBAny::kIntegerType: | 161 case IDBAny::kIntegerType: |
162 return v8::Number::New(isolate, impl->Integer()); | 162 return v8::Number::New(isolate, impl->Integer()); |
163 case IDBAny::kKeyType: | 163 case IDBAny::kKeyType: |
164 return ToV8(impl->Key(), creation_context, isolate); | 164 return ToV8(impl->Key(), creation_context, isolate); |
165 } | 165 } |
166 | 166 |
167 ASSERT_NOT_REACHED(); | 167 NOTREACHED(); |
168 return v8::Undefined(isolate); | 168 return v8::Undefined(isolate); |
169 } | 169 } |
170 | 170 |
171 static const size_t kMaximumDepth = 2000; | 171 static const size_t kMaximumDepth = 2000; |
172 | 172 |
173 static IDBKey* CreateIDBKeyFromValue(v8::Isolate* isolate, | 173 static IDBKey* CreateIDBKeyFromValue(v8::Isolate* isolate, |
174 v8::Local<v8::Value> value, | 174 v8::Local<v8::Value> value, |
175 Vector<v8::Local<v8::Array>>& stack, | 175 Vector<v8::Local<v8::Array>>& stack, |
176 ExceptionState& exception_state) { | 176 ExceptionState& exception_state) { |
177 if (value->IsNumber() && !std::isnan(value.As<v8::Number>()->Value())) | 177 if (value->IsNumber() && !std::isnan(value.As<v8::Number>()->Value())) |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 return name == "name" || name == "lastModified" || | 265 return name == "name" || name == "lastModified" || |
266 name == "lastModifiedDate"; | 266 name == "lastModifiedDate"; |
267 return false; | 267 return false; |
268 } | 268 } |
269 | 269 |
270 // Assumes a valid key path. | 270 // Assumes a valid key path. |
271 static Vector<String> ParseKeyPath(const String& key_path) { | 271 static Vector<String> ParseKeyPath(const String& key_path) { |
272 Vector<String> elements; | 272 Vector<String> elements; |
273 IDBKeyPathParseError error; | 273 IDBKeyPathParseError error; |
274 IDBParseKeyPath(key_path, elements, error); | 274 IDBParseKeyPath(key_path, elements, error); |
275 ASSERT(error == kIDBKeyPathParseErrorNone); | 275 DCHECK_EQ(error, kIDBKeyPathParseErrorNone); |
276 return elements; | 276 return elements; |
277 } | 277 } |
278 | 278 |
279 static IDBKey* CreateIDBKeyFromValueAndKeyPath( | 279 static IDBKey* CreateIDBKeyFromValueAndKeyPath( |
280 v8::Isolate* isolate, | 280 v8::Isolate* isolate, |
281 v8::Local<v8::Value> v8_value, | 281 v8::Local<v8::Value> v8_value, |
282 const String& key_path, | 282 const String& key_path, |
283 ExceptionState& exception_state) { | 283 ExceptionState& exception_state) { |
284 Vector<String> key_path_elements = ParseKeyPath(key_path); | 284 Vector<String> key_path_elements = ParseKeyPath(key_path); |
285 ASSERT(isolate->InContext()); | 285 DCHECK(isolate->InContext()); |
286 | 286 |
287 v8::HandleScope handle_scope(isolate); | 287 v8::HandleScope handle_scope(isolate); |
288 v8::Local<v8::Context> context = isolate->GetCurrentContext(); | 288 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
289 v8::TryCatch block(isolate); | 289 v8::TryCatch block(isolate); |
290 for (size_t i = 0; i < key_path_elements.size(); ++i) { | 290 for (size_t i = 0; i < key_path_elements.size(); ++i) { |
291 const String& element = key_path_elements[i]; | 291 const String& element = key_path_elements[i]; |
292 | 292 |
293 // Special cases from https://w3c.github.io/IndexedDB/#key-path-construct | 293 // Special cases from https://w3c.github.io/IndexedDB/#key-path-construct |
294 // These access special or non-own properties directly, to avoid side | 294 // These access special or non-own properties directly, to avoid side |
295 // effects. | 295 // effects. |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 } | 349 } |
350 } | 350 } |
351 return CreateIDBKeyFromValue(isolate, v8_value, exception_state); | 351 return CreateIDBKeyFromValue(isolate, v8_value, exception_state); |
352 } | 352 } |
353 | 353 |
354 static IDBKey* CreateIDBKeyFromValueAndKeyPath( | 354 static IDBKey* CreateIDBKeyFromValueAndKeyPath( |
355 v8::Isolate* isolate, | 355 v8::Isolate* isolate, |
356 v8::Local<v8::Value> value, | 356 v8::Local<v8::Value> value, |
357 const IDBKeyPath& key_path, | 357 const IDBKeyPath& key_path, |
358 ExceptionState& exception_state) { | 358 ExceptionState& exception_state) { |
359 ASSERT(!key_path.IsNull()); | 359 DCHECK(!key_path.IsNull()); |
360 v8::HandleScope handle_scope(isolate); | 360 v8::HandleScope handle_scope(isolate); |
361 if (key_path.GetType() == IDBKeyPath::kArrayType) { | 361 if (key_path.GetType() == IDBKeyPath::kArrayType) { |
362 IDBKey::KeyArray result; | 362 IDBKey::KeyArray result; |
363 const Vector<String>& array = key_path.Array(); | 363 const Vector<String>& array = key_path.Array(); |
364 for (size_t i = 0; i < array.size(); ++i) { | 364 for (size_t i = 0; i < array.size(); ++i) { |
365 IDBKey* key = CreateIDBKeyFromValueAndKeyPath(isolate, value, array[i], | 365 IDBKey* key = CreateIDBKeyFromValueAndKeyPath(isolate, value, array[i], |
366 exception_state); | 366 exception_state); |
367 if (!key) | 367 if (!key) |
368 return nullptr; | 368 return nullptr; |
369 result.push_back(key); | 369 result.push_back(key); |
370 } | 370 } |
371 return IDBKey::CreateArray(result); | 371 return IDBKey::CreateArray(result); |
372 } | 372 } |
373 | 373 |
374 ASSERT(key_path.GetType() == IDBKeyPath::kStringType); | 374 DCHECK_EQ(key_path.GetType(), IDBKeyPath::kStringType); |
375 return CreateIDBKeyFromValueAndKeyPath(isolate, value, key_path.GetString(), | 375 return CreateIDBKeyFromValueAndKeyPath(isolate, value, key_path.GetString(), |
376 exception_state); | 376 exception_state); |
377 } | 377 } |
378 | 378 |
379 // Deserialize just the value data & blobInfo from the given IDBValue. | 379 // Deserialize just the value data & blobInfo from the given IDBValue. |
380 // | 380 // |
381 // Primary key injection is performed in deserializeIDBValue() below. | 381 // Primary key injection is performed in deserializeIDBValue() below. |
382 static v8::Local<v8::Value> DeserializeIDBValueData(v8::Isolate* isolate, | 382 static v8::Local<v8::Value> DeserializeIDBValueData(v8::Isolate* isolate, |
383 const IDBValue* value) { | 383 const IDBValue* value) { |
384 ASSERT(isolate->InContext()); | 384 DCHECK(isolate->InContext()); |
385 if (!value || value->IsNull()) | 385 if (!value || value->IsNull()) |
386 return v8::Null(isolate); | 386 return v8::Null(isolate); |
387 | 387 |
388 RefPtr<SerializedScriptValue> serialized_value = | 388 RefPtr<SerializedScriptValue> serialized_value = |
389 value->CreateSerializedValue(); | 389 value->CreateSerializedValue(); |
390 SerializedScriptValue::DeserializeOptions options; | 390 SerializedScriptValue::DeserializeOptions options; |
391 options.blob_info = value->BlobInfo(); | 391 options.blob_info = value->BlobInfo(); |
392 options.read_wasm_from_stream = true; | 392 options.read_wasm_from_stream = true; |
393 | 393 |
394 // deserialize() returns null when serialization fails. This is sub-optimal | 394 // deserialize() returns null when serialization fails. This is sub-optimal |
395 // because IndexedDB values can be null, so an application cannot distinguish | 395 // because IndexedDB values can be null, so an application cannot distinguish |
396 // between a de-serialization failure and a legitimately stored null value. | 396 // between a de-serialization failure and a legitimately stored null value. |
397 // | 397 // |
398 // TODO(crbug.com/703704): Ideally, SerializedScriptValue should return an | 398 // TODO(crbug.com/703704): Ideally, SerializedScriptValue should return an |
399 // empty handle on serialization errors, which should be handled by higher | 399 // empty handle on serialization errors, which should be handled by higher |
400 // layers. For example, IndexedDB could throw an exception, abort the | 400 // layers. For example, IndexedDB could throw an exception, abort the |
401 // transaction, or close the database connection. | 401 // transaction, or close the database connection. |
402 return serialized_value->Deserialize(isolate, options); | 402 return serialized_value->Deserialize(isolate, options); |
403 } | 403 } |
404 | 404 |
405 // Deserialize the entire IDBValue. | 405 // Deserialize the entire IDBValue. |
406 // | 406 // |
407 // On top of deserializeIDBValueData(), this handles the special case of having | 407 // On top of deserializeIDBValueData(), this handles the special case of having |
408 // to inject a key into the de-serialized value. See injectV8KeyIntoV8Value() | 408 // to inject a key into the de-serialized value. See injectV8KeyIntoV8Value() |
409 // for details. | 409 // for details. |
410 v8::Local<v8::Value> DeserializeIDBValue(v8::Isolate* isolate, | 410 v8::Local<v8::Value> DeserializeIDBValue(v8::Isolate* isolate, |
411 v8::Local<v8::Object> creation_context, | 411 v8::Local<v8::Object> creation_context, |
412 const IDBValue* value) { | 412 const IDBValue* value) { |
413 ASSERT(isolate->InContext()); | 413 DCHECK(isolate->InContext()); |
414 if (!value || value->IsNull()) | 414 if (!value || value->IsNull()) |
415 return v8::Null(isolate); | 415 return v8::Null(isolate); |
416 | 416 |
417 v8::Local<v8::Value> v8_value = DeserializeIDBValueData(isolate, value); | 417 v8::Local<v8::Value> v8_value = DeserializeIDBValueData(isolate, value); |
418 if (value->PrimaryKey()) { | 418 if (value->PrimaryKey()) { |
419 v8::Local<v8::Value> key = | 419 v8::Local<v8::Value> key = |
420 ToV8(value->PrimaryKey(), creation_context, isolate); | 420 ToV8(value->PrimaryKey(), creation_context, isolate); |
421 if (key.IsEmpty()) | 421 if (key.IsEmpty()) |
422 return v8::Local<v8::Value>(); | 422 return v8::Local<v8::Value>(); |
423 | 423 |
424 InjectV8KeyIntoV8Value(isolate, key, v8_value, value->KeyPath()); | 424 InjectV8KeyIntoV8Value(isolate, key, v8_value, value->KeyPath()); |
425 | 425 |
426 // TODO(crbug.com/703704): Throw an error here or at a higher layer if | 426 // TODO(crbug.com/703704): Throw an error here or at a higher layer if |
427 // injectV8KeyIntoV8Value() returns false, which means that the serialized | 427 // injectV8KeyIntoV8Value() returns false, which means that the serialized |
428 // value got corrupted while on disk. | 428 // value got corrupted while on disk. |
429 } | 429 } |
430 | 430 |
431 return v8_value; | 431 return v8_value; |
432 } | 432 } |
433 | 433 |
434 static v8::Local<v8::Value> DeserializeIDBValueArray( | 434 static v8::Local<v8::Value> DeserializeIDBValueArray( |
435 v8::Isolate* isolate, | 435 v8::Isolate* isolate, |
436 v8::Local<v8::Object> creation_context, | 436 v8::Local<v8::Object> creation_context, |
437 const Vector<RefPtr<IDBValue>>* values) { | 437 const Vector<RefPtr<IDBValue>>* values) { |
438 ASSERT(isolate->InContext()); | 438 DCHECK(isolate->InContext()); |
439 | 439 |
440 v8::Local<v8::Context> context = isolate->GetCurrentContext(); | 440 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
441 v8::Local<v8::Array> array = v8::Array::New(isolate, values->size()); | 441 v8::Local<v8::Array> array = v8::Array::New(isolate, values->size()); |
442 for (size_t i = 0; i < values->size(); ++i) { | 442 for (size_t i = 0; i < values->size(); ++i) { |
443 v8::Local<v8::Value> v8_value = | 443 v8::Local<v8::Value> v8_value = |
444 DeserializeIDBValue(isolate, creation_context, values->at(i).Get()); | 444 DeserializeIDBValue(isolate, creation_context, values->at(i).Get()); |
445 if (v8_value.IsEmpty()) | 445 if (v8_value.IsEmpty()) |
446 v8_value = v8::Undefined(isolate); | 446 v8_value = v8::Undefined(isolate); |
447 if (!V8CallBoolean(array->CreateDataProperty(context, i, v8_value))) | 447 if (!V8CallBoolean(array->CreateDataProperty(context, i, v8_value))) |
448 return V8Undefined(); | 448 return V8Undefined(); |
(...skipping 17 matching lines...) Expand all Loading... |
466 // because this type of code is a likely victim to security exploits. | 466 // because this type of code is a likely victim to security exploits. |
467 // | 467 // |
468 // We handle this special case by serializing and writing values without the | 468 // We handle this special case by serializing and writing values without the |
469 // corresponding keys. At read time, we obtain the keys and the values | 469 // corresponding keys. At read time, we obtain the keys and the values |
470 // separately, and we inject the keys into values. | 470 // separately, and we inject the keys into values. |
471 bool InjectV8KeyIntoV8Value(v8::Isolate* isolate, | 471 bool InjectV8KeyIntoV8Value(v8::Isolate* isolate, |
472 v8::Local<v8::Value> key, | 472 v8::Local<v8::Value> key, |
473 v8::Local<v8::Value> value, | 473 v8::Local<v8::Value> value, |
474 const IDBKeyPath& key_path) { | 474 const IDBKeyPath& key_path) { |
475 IDB_TRACE("injectIDBV8KeyIntoV8Value"); | 475 IDB_TRACE("injectIDBV8KeyIntoV8Value"); |
476 ASSERT(isolate->InContext()); | 476 DCHECK(isolate->InContext()); |
477 | 477 |
478 ASSERT(key_path.GetType() == IDBKeyPath::kStringType); | 478 DCHECK_EQ(key_path.GetType(), IDBKeyPath::kStringType); |
479 Vector<String> key_path_elements = ParseKeyPath(key_path.GetString()); | 479 Vector<String> key_path_elements = ParseKeyPath(key_path.GetString()); |
480 | 480 |
481 // The conbination of a key generator and an empty key path is forbidden by | 481 // The conbination of a key generator and an empty key path is forbidden by |
482 // spec. | 482 // spec. |
483 if (!key_path_elements.size()) { | 483 if (!key_path_elements.size()) { |
484 ASSERT_NOT_REACHED(); | 484 NOTREACHED(); |
485 return false; | 485 return false; |
486 } | 486 } |
487 | 487 |
488 v8::HandleScope handle_scope(isolate); | 488 v8::HandleScope handle_scope(isolate); |
489 v8::Local<v8::Context> context = isolate->GetCurrentContext(); | 489 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
490 | 490 |
491 // For an object o = {} which should have keypath 'a.b.c' and key k, this | 491 // For an object o = {} which should have keypath 'a.b.c' and key k, this |
492 // populates o to be {a:{b:{}}}. This is only applied to deserialized | 492 // populates o to be {a:{b:{}}}. This is only applied to deserialized |
493 // values, so we can assume that there are no getters/setters on the | 493 // values, so we can assume that there are no getters/setters on the |
494 // object itself (though there might be on the prototype chain). | 494 // object itself (though there might be on the prototype chain). |
(...skipping 16 matching lines...) Expand all Loading... |
511 // | 511 // |
512 // (2) Bugs that write a value which is incompatible with the primary key | 512 // (2) Bugs that write a value which is incompatible with the primary key |
513 // injection required by the object store. The simplest example is writing | 513 // injection required by the object store. The simplest example is writing |
514 // numbers or booleans to an object store with an auto-incrementing primary | 514 // numbers or booleans to an object store with an auto-incrementing primary |
515 // keys. | 515 // keys. |
516 for (size_t i = 0; i < key_path_elements.size() - 1; ++i) { | 516 for (size_t i = 0; i < key_path_elements.size() - 1; ++i) { |
517 if (!value->IsObject()) | 517 if (!value->IsObject()) |
518 return false; | 518 return false; |
519 | 519 |
520 const String& key_path_element = key_path_elements[i]; | 520 const String& key_path_element = key_path_elements[i]; |
521 ASSERT(!IsImplicitProperty(isolate, value, key_path_element)); | 521 DCHECK(!IsImplicitProperty(isolate, value, key_path_element)); |
522 v8::Local<v8::Object> object = value.As<v8::Object>(); | 522 v8::Local<v8::Object> object = value.As<v8::Object>(); |
523 v8::Local<v8::String> property = V8String(isolate, key_path_element); | 523 v8::Local<v8::String> property = V8String(isolate, key_path_element); |
524 bool has_own_property; | 524 bool has_own_property; |
525 if (!V8Call(object->HasOwnProperty(context, property), has_own_property)) | 525 if (!V8Call(object->HasOwnProperty(context, property), has_own_property)) |
526 return false; | 526 return false; |
527 if (has_own_property) { | 527 if (has_own_property) { |
528 if (!object->Get(context, property).ToLocal(&value)) | 528 if (!object->Get(context, property).ToLocal(&value)) |
529 return false; | 529 return false; |
530 } else { | 530 } else { |
531 value = v8::Object::New(isolate); | 531 value = v8::Object::New(isolate); |
(...skipping 22 matching lines...) Expand all Loading... |
554 return true; | 554 return true; |
555 } | 555 } |
556 | 556 |
557 // Verify that an value can have an generated key inserted at the location | 557 // Verify that an value can have an generated key inserted at the location |
558 // specified by the key path (by injectV8KeyIntoV8Value) when the object is | 558 // specified by the key path (by injectV8KeyIntoV8Value) when the object is |
559 // later deserialized. | 559 // later deserialized. |
560 bool CanInjectIDBKeyIntoScriptValue(v8::Isolate* isolate, | 560 bool CanInjectIDBKeyIntoScriptValue(v8::Isolate* isolate, |
561 const ScriptValue& script_value, | 561 const ScriptValue& script_value, |
562 const IDBKeyPath& key_path) { | 562 const IDBKeyPath& key_path) { |
563 IDB_TRACE("canInjectIDBKeyIntoScriptValue"); | 563 IDB_TRACE("canInjectIDBKeyIntoScriptValue"); |
564 ASSERT(key_path.GetType() == IDBKeyPath::kStringType); | 564 DCHECK_EQ(key_path.GetType(), IDBKeyPath::kStringType); |
565 Vector<String> key_path_elements = ParseKeyPath(key_path.GetString()); | 565 Vector<String> key_path_elements = ParseKeyPath(key_path.GetString()); |
566 | 566 |
567 if (!key_path_elements.size()) | 567 if (!key_path_elements.size()) |
568 return false; | 568 return false; |
569 | 569 |
570 v8::Local<v8::Value> current(script_value.V8Value()); | 570 v8::Local<v8::Value> current(script_value.V8Value()); |
571 if (!current->IsObject()) | 571 if (!current->IsObject()) |
572 return false; | 572 return false; |
573 | 573 |
574 v8::Local<v8::Context> context = isolate->GetCurrentContext(); | 574 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 const IDBValue* value) { | 656 const IDBValue* value) { |
657 ScriptState::Scope scope(script_state); | 657 ScriptState::Scope scope(script_state); |
658 v8::Isolate* isolate = script_state->GetIsolate(); | 658 v8::Isolate* isolate = script_state->GetIsolate(); |
659 ScriptValue key_value = ScriptValue::From(script_state, value->PrimaryKey()); | 659 ScriptValue key_value = ScriptValue::From(script_state, value->PrimaryKey()); |
660 ScriptValue script_value(script_state, | 660 ScriptValue script_value(script_state, |
661 DeserializeIDBValueData(isolate, value)); | 661 DeserializeIDBValueData(isolate, value)); |
662 | 662 |
663 DummyExceptionStateForTesting exception_state; | 663 DummyExceptionStateForTesting exception_state; |
664 IDBKey* expected_key = CreateIDBKeyFromValueAndKeyPath( | 664 IDBKey* expected_key = CreateIDBKeyFromValueAndKeyPath( |
665 isolate, script_value.V8Value(), value->KeyPath(), exception_state); | 665 isolate, script_value.V8Value(), value->KeyPath(), exception_state); |
666 ASSERT(!exception_state.HadException()); | 666 DCHECK(!exception_state.HadException()); |
667 if (expected_key && expected_key->IsEqual(value->PrimaryKey())) | 667 if (expected_key && expected_key->IsEqual(value->PrimaryKey())) |
668 return; | 668 return; |
669 | 669 |
670 bool injected = InjectV8KeyIntoV8Value( | 670 bool injected = InjectV8KeyIntoV8Value( |
671 isolate, key_value.V8Value(), script_value.V8Value(), value->KeyPath()); | 671 isolate, key_value.V8Value(), script_value.V8Value(), value->KeyPath()); |
672 DCHECK(injected); | 672 DCHECK(injected); |
673 } | 673 } |
674 #endif | 674 #endif |
675 | 675 |
676 } // namespace blink | 676 } // namespace blink |
OLD | NEW |