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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 | 268 |
269 static IDBKey* createIDBKeyFromValueAndKeyPath(v8::Isolate* isolate, v8::Local<v
8::Value> v8Value, const String& keyPath, ExceptionState& exceptionState, bool a
llowExperimentalTypes) | 269 static IDBKey* createIDBKeyFromValueAndKeyPath(v8::Isolate* isolate, v8::Local<v
8::Value> v8Value, const String& keyPath, ExceptionState& exceptionState, bool a
llowExperimentalTypes) |
270 { | 270 { |
271 Vector<String> keyPathElements = parseKeyPath(keyPath); | 271 Vector<String> keyPathElements = parseKeyPath(keyPath); |
272 ASSERT(isolate->InContext()); | 272 ASSERT(isolate->InContext()); |
273 | 273 |
274 v8::HandleScope handleScope(isolate); | 274 v8::HandleScope handleScope(isolate); |
275 v8::Local<v8::Context> context = isolate->GetCurrentContext(); | 275 v8::Local<v8::Context> context = isolate->GetCurrentContext(); |
276 v8::TryCatch block(isolate); | 276 v8::TryCatch block(isolate); |
277 for (size_t i = 0; i < keyPathElements.size(); ++i) { | 277 for (size_t i = 0; i < keyPathElements.size(); ++i) { |
278 if (v8Value->IsString() && keyPathElements[i] == "length") { | 278 const String& element = keyPathElements[i]; |
| 279 |
| 280 // Special cases from https://w3c.github.io/IndexedDB/#key-path-construc
t |
| 281 // These access special or non-own properties directly, to avoid side |
| 282 // effects. |
| 283 |
| 284 if (v8Value->IsString() && element == "length") { |
279 int32_t length = v8Value.As<v8::String>()->Length(); | 285 int32_t length = v8Value.As<v8::String>()->Length(); |
280 v8Value = v8::Number::New(isolate, length); | 286 v8Value = v8::Number::New(isolate, length); |
281 } else if (!v8Value->IsObject()) { | 287 continue; |
| 288 } |
| 289 |
| 290 if (v8Value->IsArray() && element == "length") { |
| 291 int32_t length = v8Value.As<v8::Array>()->Length(); |
| 292 v8Value = v8::Number::New(isolate, length); |
| 293 continue; |
| 294 } |
| 295 |
| 296 if (!v8Value->IsObject()) |
282 return nullptr; | 297 return nullptr; |
283 } else { | 298 v8::Local<v8::Object> object = v8Value.As<v8::Object>(); |
284 v8::Local<v8::Object> object = v8Value.As<v8::Object>(); | 299 |
285 v8::Local<v8::String> key = v8String(isolate, keyPathElements[i]); | 300 if (V8Blob::hasInstance(object, isolate)) { |
286 if (!v8CallBoolean(object->Has(context, key))) | 301 if (element == "size") { |
287 return nullptr; | 302 v8Value = v8::Number::New(isolate, V8Blob::toImpl(object)->size(
)); |
288 if (!v8Call(object->Get(context, key), v8Value, block)) { | 303 continue; |
289 exceptionState.rethrowV8Exception(block.Exception()); | |
290 return nullptr; | |
291 } | 304 } |
| 305 if (element == "type") { |
| 306 v8Value = v8String(isolate, V8Blob::toImpl(object)->type()); |
| 307 continue; |
| 308 } |
| 309 // Fall through. |
| 310 } |
| 311 |
| 312 if (V8File::hasInstance(object, isolate)) { |
| 313 if (element == "name") { |
| 314 v8Value = v8String(isolate, V8File::toImpl(object)->name()); |
| 315 continue; |
| 316 } |
| 317 if (element == "lastModified") { |
| 318 v8Value = v8::Number::New(isolate, V8File::toImpl(object)->lastM
odified()); |
| 319 continue; |
| 320 } |
| 321 if (element == "lastModifiedDate") { |
| 322 v8Value = v8::Date::New(isolate, V8File::toImpl(object)->lastMod
ifiedDate()); |
| 323 continue; |
| 324 } |
| 325 // Fall through. |
| 326 } |
| 327 |
| 328 v8::Local<v8::String> key = v8String(isolate, element); |
| 329 if (!v8CallBoolean(object->HasOwnProperty(context, key))) |
| 330 return nullptr; |
| 331 if (!v8Call(object->Get(context, key), v8Value, block)) { |
| 332 exceptionState.rethrowV8Exception(block.Exception()); |
| 333 return nullptr; |
292 } | 334 } |
293 } | 335 } |
294 return createIDBKeyFromValue(isolate, v8Value, exceptionState, allowExperime
ntalTypes); | 336 return createIDBKeyFromValue(isolate, v8Value, exceptionState, allowExperime
ntalTypes); |
295 } | 337 } |
296 | 338 |
297 static IDBKey* createIDBKeyFromValueAndKeyPath(v8::Isolate* isolate, v8::Local<v
8::Value> value, const IDBKeyPath& keyPath, ExceptionState& exceptionState, bool
allowExperimentalTypes = false) | 339 static IDBKey* createIDBKeyFromValueAndKeyPath(v8::Isolate* isolate, v8::Local<v
8::Value> value, const IDBKeyPath& keyPath, ExceptionState& exceptionState, bool
allowExperimentalTypes = false) |
298 { | 340 { |
299 ASSERT(!keyPath.isNull()); | 341 ASSERT(!keyPath.isNull()); |
300 v8::HandleScope handleScope(isolate); | 342 v8::HandleScope handleScope(isolate); |
301 if (keyPath.getType() == IDBKeyPath::ArrayType) { | 343 if (keyPath.getType() == IDBKeyPath::ArrayType) { |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 V8ServiceWorkerGlobalScope::installForeignFetch(scriptState, global)
; | 616 V8ServiceWorkerGlobalScope::installForeignFetch(scriptState, global)
; |
575 } | 617 } |
576 } | 618 } |
577 } | 619 } |
578 | 620 |
579 void registerInstallOriginTrialsForModules() | 621 void registerInstallOriginTrialsForModules() |
580 { | 622 { |
581 s_originalInstallOriginTrialsFunction = setInstallOriginTrialsFunction(&inst
allOriginTrialsForModules); | 623 s_originalInstallOriginTrialsFunction = setInstallOriginTrialsFunction(&inst
allOriginTrialsForModules); |
582 } | 624 } |
583 } // namespace blink | 625 } // namespace blink |
OLD | NEW |