| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "modules/serviceworkers/Cache.h" | 6 #include "modules/serviceworkers/Cache.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/ExceptionState.h" | 8 #include "bindings/core/v8/ExceptionState.h" |
| 9 #include "bindings/core/v8/ScriptFunction.h" | 9 #include "bindings/core/v8/ScriptFunction.h" |
| 10 #include "bindings/core/v8/ScriptPromise.h" | 10 #include "bindings/core/v8/ScriptPromise.h" |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 isolate()->RunMicrotasks(); | 192 isolate()->RunMicrotasks(); |
| 193 return onResolve; | 193 return onResolve; |
| 194 } | 194 } |
| 195 | 195 |
| 196 std::string getResolveString(ScriptPromise& promise) | 196 std::string getResolveString(ScriptPromise& promise) |
| 197 { | 197 { |
| 198 ScriptValue onResolve = getResolveValue(promise); | 198 ScriptValue onResolve = getResolveValue(promise); |
| 199 return toCoreString(onResolve.v8Value()->ToString()).ascii().data(); | 199 return toCoreString(onResolve.v8Value()->ToString()).ascii().data(); |
| 200 } | 200 } |
| 201 | 201 |
| 202 ExceptionState& exceptionState() |
| 203 { |
| 204 return m_exceptionState; |
| 205 } |
| 206 |
| 202 private: | 207 private: |
| 203 // A ScriptFunction that creates a test failure if it is ever called. | 208 // A ScriptFunction that creates a test failure if it is ever called. |
| 204 class UnreachableFunction : public ScriptFunction { | 209 class UnreachableFunction : public ScriptFunction { |
| 205 public: | 210 public: |
| 206 static v8::Handle<v8::Function> create(ScriptState* scriptState) | 211 static v8::Handle<v8::Function> create(ScriptState* scriptState) |
| 207 { | 212 { |
| 208 UnreachableFunction* self = new UnreachableFunction(scriptState); | 213 UnreachableFunction* self = new UnreachableFunction(scriptState); |
| 209 return self->bindToV8Function(); | 214 return self->bindToV8Function(); |
| 210 } | 215 } |
| 211 | 216 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 virtual void TearDown() override | 256 virtual void TearDown() override |
| 252 { | 257 { |
| 253 m_scriptScope = 0; | 258 m_scriptScope = 0; |
| 254 } | 259 } |
| 255 | 260 |
| 256 // Lifetime is that of the text fixture. | 261 // Lifetime is that of the text fixture. |
| 257 OwnPtr<DummyPageHolder> m_page; | 262 OwnPtr<DummyPageHolder> m_page; |
| 258 | 263 |
| 259 // Lifetime is per test instance. | 264 // Lifetime is per test instance. |
| 260 OwnPtr<ScriptState::Scope> m_scriptScope; | 265 OwnPtr<ScriptState::Scope> m_scriptScope; |
| 266 |
| 267 NonThrowableExceptionState m_exceptionState; |
| 261 }; | 268 }; |
| 262 | 269 |
| 263 TEST_F(ServiceWorkerCacheTest, Basics) | 270 TEST_F(ServiceWorkerCacheTest, Basics) |
| 264 { | 271 { |
| 265 ErrorWebCacheForTests* testCache; | 272 ErrorWebCacheForTests* testCache; |
| 266 Cache* cache = Cache::create(testCache = new NotImplementedErrorCache()); | 273 Cache* cache = Cache::create(testCache = new NotImplementedErrorCache()); |
| 267 ASSERT(cache); | 274 ASSERT(cache); |
| 268 | 275 |
| 269 const String url = "http://www.cachetest.org/"; | 276 const String url = "http://www.cachetest.org/"; |
| 270 | 277 |
| 271 CacheQueryOptions options; | 278 CacheQueryOptions options; |
| 272 ScriptPromise matchPromise = cache->match(scriptState(), url, options); | 279 ScriptPromise matchPromise = cache->match(scriptState(), url, options, excep
tionState()); |
| 273 EXPECT_EQ(kNotImplementedString, getRejectString(matchPromise)); | 280 EXPECT_EQ(kNotImplementedString, getRejectString(matchPromise)); |
| 274 | 281 |
| 275 cache = Cache::create(testCache = new ErrorWebCacheForTests(WebServiceWorker
CacheErrorNotFound)); | 282 cache = Cache::create(testCache = new ErrorWebCacheForTests(WebServiceWorker
CacheErrorNotFound)); |
| 276 matchPromise = cache->match(scriptState(), url, options); | 283 matchPromise = cache->match(scriptState(), url, options, exceptionState()); |
| 277 ScriptValue scriptValue = getResolveValue(matchPromise); | 284 ScriptValue scriptValue = getResolveValue(matchPromise); |
| 278 EXPECT_TRUE(scriptValue.isUndefined()); | 285 EXPECT_TRUE(scriptValue.isUndefined()); |
| 279 | 286 |
| 280 cache = Cache::create(testCache = new ErrorWebCacheForTests(WebServiceWorker
CacheErrorExists)); | 287 cache = Cache::create(testCache = new ErrorWebCacheForTests(WebServiceWorker
CacheErrorExists)); |
| 281 matchPromise = cache->match(scriptState(), url, options); | 288 matchPromise = cache->match(scriptState(), url, options, exceptionState()); |
| 282 EXPECT_EQ("InvalidAccessError: Entry already exists.", getRejectString(match
Promise)); | 289 EXPECT_EQ("InvalidAccessError: Entry already exists.", getRejectString(match
Promise)); |
| 283 } | 290 } |
| 284 | 291 |
| 285 // Tests that arguments are faithfully passed on calls to Cache methods, except
for methods which use batch operations, | 292 // Tests that arguments are faithfully passed on calls to Cache methods, except
for methods which use batch operations, |
| 286 // which are tested later. | 293 // which are tested later. |
| 287 TEST_F(ServiceWorkerCacheTest, BasicArguments) | 294 TEST_F(ServiceWorkerCacheTest, BasicArguments) |
| 288 { | 295 { |
| 289 ErrorWebCacheForTests* testCache; | 296 ErrorWebCacheForTests* testCache; |
| 290 Cache* cache = Cache::create(testCache = new NotImplementedErrorCache()); | 297 Cache* cache = Cache::create(testCache = new NotImplementedErrorCache()); |
| 291 ASSERT(cache); | 298 ASSERT(cache); |
| 292 | 299 |
| 293 const String url = "http://www.cache.arguments.test/"; | 300 const String url = "http://www.cache.arguments.test/"; |
| 294 testCache->setExpectedUrl(&url); | 301 testCache->setExpectedUrl(&url); |
| 295 | 302 |
| 296 WebServiceWorkerCache::QueryParams expectedQueryParams; | 303 WebServiceWorkerCache::QueryParams expectedQueryParams; |
| 297 expectedQueryParams.ignoreVary = true; | 304 expectedQueryParams.ignoreVary = true; |
| 298 expectedQueryParams.cacheName = "this is a cache name"; | 305 expectedQueryParams.cacheName = "this is a cache name"; |
| 299 testCache->setExpectedQueryParams(&expectedQueryParams); | 306 testCache->setExpectedQueryParams(&expectedQueryParams); |
| 300 | 307 |
| 301 CacheQueryOptions options; | 308 CacheQueryOptions options; |
| 302 options.setIgnoreVary(1); | 309 options.setIgnoreVary(1); |
| 303 options.setCacheName(expectedQueryParams.cacheName); | 310 options.setCacheName(expectedQueryParams.cacheName); |
| 304 | 311 |
| 305 Request* request = newRequestFromUrl(url); | 312 Request* request = newRequestFromUrl(url); |
| 306 ASSERT(request); | 313 ASSERT(request); |
| 307 ScriptPromise matchResult = cache->match(scriptState(), request, options); | 314 ScriptPromise matchResult = cache->match(scriptState(), request, options); |
| 308 EXPECT_EQ("dispatchMatch", testCache->getAndClearLastErrorWebCacheMethodCall
ed()); | 315 EXPECT_EQ("dispatchMatch", testCache->getAndClearLastErrorWebCacheMethodCall
ed()); |
| 309 EXPECT_EQ(kNotImplementedString, getRejectString(matchResult)); | 316 EXPECT_EQ(kNotImplementedString, getRejectString(matchResult)); |
| 310 | 317 |
| 311 ScriptPromise stringMatchResult = cache->match(scriptState(), url, options); | 318 ScriptPromise stringMatchResult = cache->match(scriptState(), url, options,
exceptionState()); |
| 312 EXPECT_EQ("dispatchMatch", testCache->getAndClearLastErrorWebCacheMethodCall
ed()); | 319 EXPECT_EQ("dispatchMatch", testCache->getAndClearLastErrorWebCacheMethodCall
ed()); |
| 313 EXPECT_EQ(kNotImplementedString, getRejectString(stringMatchResult)); | 320 EXPECT_EQ(kNotImplementedString, getRejectString(stringMatchResult)); |
| 314 | 321 |
| 315 request = newRequestFromUrl(url); | 322 request = newRequestFromUrl(url); |
| 316 ASSERT(request); | 323 ASSERT(request); |
| 317 ScriptPromise matchAllResult = cache->matchAll(scriptState(), request, optio
ns); | 324 ScriptPromise matchAllResult = cache->matchAll(scriptState(), request, optio
ns); |
| 318 EXPECT_EQ("dispatchMatchAll", testCache->getAndClearLastErrorWebCacheMethodC
alled()); | 325 EXPECT_EQ("dispatchMatchAll", testCache->getAndClearLastErrorWebCacheMethodC
alled()); |
| 319 EXPECT_EQ(kNotImplementedString, getRejectString(matchAllResult)); | 326 EXPECT_EQ(kNotImplementedString, getRejectString(matchAllResult)); |
| 320 | 327 |
| 321 ScriptPromise stringMatchAllResult = cache->matchAll(scriptState(), url, opt
ions); | 328 ScriptPromise stringMatchAllResult = cache->matchAll(scriptState(), url, opt
ions, exceptionState()); |
| 322 EXPECT_EQ("dispatchMatchAll", testCache->getAndClearLastErrorWebCacheMethodC
alled()); | 329 EXPECT_EQ("dispatchMatchAll", testCache->getAndClearLastErrorWebCacheMethodC
alled()); |
| 323 EXPECT_EQ(kNotImplementedString, getRejectString(stringMatchAllResult)); | 330 EXPECT_EQ(kNotImplementedString, getRejectString(stringMatchAllResult)); |
| 324 | 331 |
| 325 ScriptPromise keysResult1 = cache->keys(scriptState()); | 332 ScriptPromise keysResult1 = cache->keys(scriptState()); |
| 326 EXPECT_EQ("dispatchKeys", testCache->getAndClearLastErrorWebCacheMethodCalle
d()); | 333 EXPECT_EQ("dispatchKeys", testCache->getAndClearLastErrorWebCacheMethodCalle
d()); |
| 327 EXPECT_EQ(kNotImplementedString, getRejectString(keysResult1)); | 334 EXPECT_EQ(kNotImplementedString, getRejectString(keysResult1)); |
| 328 | 335 |
| 329 request = newRequestFromUrl(url); | 336 request = newRequestFromUrl(url); |
| 330 ASSERT(request); | 337 ASSERT(request); |
| 331 ScriptPromise keysResult2 = cache->keys(scriptState(), request, options); | 338 ScriptPromise keysResult2 = cache->keys(scriptState(), request, options); |
| 332 EXPECT_EQ("dispatchKeys", testCache->getAndClearLastErrorWebCacheMethodCalle
d()); | 339 EXPECT_EQ("dispatchKeys", testCache->getAndClearLastErrorWebCacheMethodCalle
d()); |
| 333 EXPECT_EQ(kNotImplementedString, getRejectString(keysResult2)); | 340 EXPECT_EQ(kNotImplementedString, getRejectString(keysResult2)); |
| 334 | 341 |
| 335 ScriptPromise stringKeysResult2 = cache->keys(scriptState(), url, options); | 342 ScriptPromise stringKeysResult2 = cache->keys(scriptState(), url, options, e
xceptionState()); |
| 336 EXPECT_EQ("dispatchKeys", testCache->getAndClearLastErrorWebCacheMethodCalle
d()); | 343 EXPECT_EQ("dispatchKeys", testCache->getAndClearLastErrorWebCacheMethodCalle
d()); |
| 337 EXPECT_EQ(kNotImplementedString, getRejectString(stringKeysResult2)); | 344 EXPECT_EQ(kNotImplementedString, getRejectString(stringKeysResult2)); |
| 338 } | 345 } |
| 339 | 346 |
| 340 // Tests that arguments are faithfully passed to API calls that degrade to batch
operations. | 347 // Tests that arguments are faithfully passed to API calls that degrade to batch
operations. |
| 341 TEST_F(ServiceWorkerCacheTest, BatchOperationArguments) | 348 TEST_F(ServiceWorkerCacheTest, BatchOperationArguments) |
| 342 { | 349 { |
| 343 ErrorWebCacheForTests* testCache; | 350 ErrorWebCacheForTests* testCache; |
| 344 Cache* cache = Cache::create(testCache = new NotImplementedErrorCache()); | 351 Cache* cache = Cache::create(testCache = new NotImplementedErrorCache()); |
| 345 ASSERT(cache); | 352 ASSERT(cache); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 368 request->populateWebServiceWorkerRequest(deleteOperation.request); | 375 request->populateWebServiceWorkerRequest(deleteOperation.request); |
| 369 deleteOperation.matchParams = expectedQueryParams; | 376 deleteOperation.matchParams = expectedQueryParams; |
| 370 expectedDeleteOperations[0] = deleteOperation; | 377 expectedDeleteOperations[0] = deleteOperation; |
| 371 } | 378 } |
| 372 testCache->setExpectedBatchOperations(&expectedDeleteOperations); | 379 testCache->setExpectedBatchOperations(&expectedDeleteOperations); |
| 373 | 380 |
| 374 ScriptPromise deleteResult = cache->deleteFunction(scriptState(), request, o
ptions); | 381 ScriptPromise deleteResult = cache->deleteFunction(scriptState(), request, o
ptions); |
| 375 EXPECT_EQ("dispatchBatch", testCache->getAndClearLastErrorWebCacheMethodCall
ed()); | 382 EXPECT_EQ("dispatchBatch", testCache->getAndClearLastErrorWebCacheMethodCall
ed()); |
| 376 EXPECT_EQ(kNotImplementedString, getRejectString(deleteResult)); | 383 EXPECT_EQ(kNotImplementedString, getRejectString(deleteResult)); |
| 377 | 384 |
| 378 ScriptPromise stringDeleteResult = cache->deleteFunction(scriptState(), url,
options); | 385 ScriptPromise stringDeleteResult = cache->deleteFunction(scriptState(), url,
options, exceptionState()); |
| 379 EXPECT_EQ("dispatchBatch", testCache->getAndClearLastErrorWebCacheMethodCall
ed()); | 386 EXPECT_EQ("dispatchBatch", testCache->getAndClearLastErrorWebCacheMethodCall
ed()); |
| 380 EXPECT_EQ(kNotImplementedString, getRejectString(stringDeleteResult)); | 387 EXPECT_EQ(kNotImplementedString, getRejectString(stringDeleteResult)); |
| 381 | 388 |
| 382 WebVector<WebServiceWorkerCache::BatchOperation> expectedPutOperations(size_
t(1)); | 389 WebVector<WebServiceWorkerCache::BatchOperation> expectedPutOperations(size_
t(1)); |
| 383 { | 390 { |
| 384 WebServiceWorkerCache::BatchOperation putOperation; | 391 WebServiceWorkerCache::BatchOperation putOperation; |
| 385 putOperation.operationType = WebServiceWorkerCache::OperationTypePut; | 392 putOperation.operationType = WebServiceWorkerCache::OperationTypePut; |
| 386 request->populateWebServiceWorkerRequest(putOperation.request); | 393 request->populateWebServiceWorkerRequest(putOperation.request); |
| 387 response->populateWebServiceWorkerResponse(putOperation.response); | 394 response->populateWebServiceWorkerResponse(putOperation.response); |
| 388 expectedPutOperations[0] = putOperation; | 395 expectedPutOperations[0] = putOperation; |
| 389 } | 396 } |
| 390 testCache->setExpectedBatchOperations(&expectedPutOperations); | 397 testCache->setExpectedBatchOperations(&expectedPutOperations); |
| 391 | 398 |
| 392 request = newRequestFromUrl(url); | 399 request = newRequestFromUrl(url); |
| 393 ASSERT(request); | 400 ASSERT(request); |
| 394 ScriptPromise putResult = cache->put(scriptState(), request, response); | 401 ScriptPromise putResult = cache->put(scriptState(), request, response); |
| 395 EXPECT_EQ("dispatchBatch", testCache->getAndClearLastErrorWebCacheMethodCall
ed()); | 402 EXPECT_EQ("dispatchBatch", testCache->getAndClearLastErrorWebCacheMethodCall
ed()); |
| 396 EXPECT_EQ(kNotImplementedString, getRejectString(putResult)); | 403 EXPECT_EQ(kNotImplementedString, getRejectString(putResult)); |
| 397 | 404 |
| 398 ScriptPromise stringPutResult = cache->put(scriptState(), url, response); | 405 ScriptPromise stringPutResult = cache->put(scriptState(), url, response, exc
eptionState()); |
| 399 EXPECT_EQ("dispatchBatch", testCache->getAndClearLastErrorWebCacheMethodCall
ed()); | 406 EXPECT_EQ("dispatchBatch", testCache->getAndClearLastErrorWebCacheMethodCall
ed()); |
| 400 EXPECT_EQ(kNotImplementedString, getRejectString(stringPutResult)); | 407 EXPECT_EQ(kNotImplementedString, getRejectString(stringPutResult)); |
| 401 | 408 |
| 402 // FIXME: test add & addAll. | 409 // FIXME: test add & addAll. |
| 403 } | 410 } |
| 404 | 411 |
| 405 class MatchTestCache : public NotImplementedErrorCache { | 412 class MatchTestCache : public NotImplementedErrorCache { |
| 406 public: | 413 public: |
| 407 MatchTestCache(WebServiceWorkerResponse& response) | 414 MatchTestCache(WebServiceWorkerResponse& response) |
| 408 : m_response(response) { } | 415 : m_response(response) { } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 423 const String requestUrl = "http://request.url/"; | 430 const String requestUrl = "http://request.url/"; |
| 424 const String responseUrl = "http://match.response.test/"; | 431 const String responseUrl = "http://match.response.test/"; |
| 425 | 432 |
| 426 WebServiceWorkerResponse webResponse; | 433 WebServiceWorkerResponse webResponse; |
| 427 webResponse.setURL(KURL(ParsedURLString, responseUrl)); | 434 webResponse.setURL(KURL(ParsedURLString, responseUrl)); |
| 428 webResponse.setResponseType(WebServiceWorkerResponseTypeDefault); | 435 webResponse.setResponseType(WebServiceWorkerResponseTypeDefault); |
| 429 | 436 |
| 430 Cache* cache = Cache::create(new MatchTestCache(webResponse)); | 437 Cache* cache = Cache::create(new MatchTestCache(webResponse)); |
| 431 CacheQueryOptions options; | 438 CacheQueryOptions options; |
| 432 | 439 |
| 433 ScriptPromise result = cache->match(scriptState(), requestUrl, options); | 440 ScriptPromise result = cache->match(scriptState(), requestUrl, options, exce
ptionState()); |
| 434 ScriptValue scriptValue = getResolveValue(result); | 441 ScriptValue scriptValue = getResolveValue(result); |
| 435 Response* response = V8Response::toImplWithTypeCheck(isolate(), scriptValue.
v8Value()); | 442 Response* response = V8Response::toImplWithTypeCheck(isolate(), scriptValue.
v8Value()); |
| 436 ASSERT_TRUE(response); | 443 ASSERT_TRUE(response); |
| 437 EXPECT_EQ(responseUrl, response->url()); | 444 EXPECT_EQ(responseUrl, response->url()); |
| 438 } | 445 } |
| 439 | 446 |
| 440 class KeysTestCache : public NotImplementedErrorCache { | 447 class KeysTestCache : public NotImplementedErrorCache { |
| 441 public: | 448 public: |
| 442 KeysTestCache(WebVector<WebServiceWorkerRequest>& requests) | 449 KeysTestCache(WebVector<WebServiceWorkerRequest>& requests) |
| 443 : m_requests(requests) { } | 450 : m_requests(requests) { } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 463 | 470 |
| 464 WebVector<WebServiceWorkerRequest> webRequests(size_t(2)); | 471 WebVector<WebServiceWorkerRequest> webRequests(size_t(2)); |
| 465 webRequests[0].setURL(KURL(ParsedURLString, url1)); | 472 webRequests[0].setURL(KURL(ParsedURLString, url1)); |
| 466 webRequests[1].setURL(KURL(ParsedURLString, url2)); | 473 webRequests[1].setURL(KURL(ParsedURLString, url2)); |
| 467 | 474 |
| 468 Cache* cache = Cache::create(new KeysTestCache(webRequests)); | 475 Cache* cache = Cache::create(new KeysTestCache(webRequests)); |
| 469 | 476 |
| 470 ScriptPromise result = cache->keys(scriptState()); | 477 ScriptPromise result = cache->keys(scriptState()); |
| 471 ScriptValue scriptValue = getResolveValue(result); | 478 ScriptValue scriptValue = getResolveValue(result); |
| 472 | 479 |
| 473 NonThrowableExceptionState exceptionState; | 480 Vector<v8::Handle<v8::Value> > requests = toImplArray<v8::Handle<v8::Value>
>(scriptValue.v8Value(), 0, isolate(), exceptionState()); |
| 474 Vector<v8::Handle<v8::Value> > requests = toImplArray<v8::Handle<v8::Value>
>(scriptValue.v8Value(), 0, isolate(), exceptionState); | |
| 475 EXPECT_EQ(expectedUrls.size(), requests.size()); | 481 EXPECT_EQ(expectedUrls.size(), requests.size()); |
| 476 for (int i = 0, minsize = std::min(expectedUrls.size(), requests.size()); i
< minsize; ++i) { | 482 for (int i = 0, minsize = std::min(expectedUrls.size(), requests.size()); i
< minsize; ++i) { |
| 477 Request* request = V8Request::toImplWithTypeCheck(isolate(), requests[i]
); | 483 Request* request = V8Request::toImplWithTypeCheck(isolate(), requests[i]
); |
| 478 EXPECT_TRUE(request); | 484 EXPECT_TRUE(request); |
| 479 if (request) | 485 if (request) |
| 480 EXPECT_EQ(expectedUrls[i], request->url()); | 486 EXPECT_EQ(expectedUrls[i], request->url()); |
| 481 } | 487 } |
| 482 } | 488 } |
| 483 | 489 |
| 484 class MatchAllAndBatchTestCache : public NotImplementedErrorCache { | 490 class MatchAllAndBatchTestCache : public NotImplementedErrorCache { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 513 | 519 |
| 514 WebVector<WebServiceWorkerResponse> webResponses(size_t(2)); | 520 WebVector<WebServiceWorkerResponse> webResponses(size_t(2)); |
| 515 webResponses[0].setURL(KURL(ParsedURLString, url1)); | 521 webResponses[0].setURL(KURL(ParsedURLString, url1)); |
| 516 webResponses[0].setResponseType(WebServiceWorkerResponseTypeDefault); | 522 webResponses[0].setResponseType(WebServiceWorkerResponseTypeDefault); |
| 517 webResponses[1].setURL(KURL(ParsedURLString, url2)); | 523 webResponses[1].setURL(KURL(ParsedURLString, url2)); |
| 518 webResponses[1].setResponseType(WebServiceWorkerResponseTypeDefault); | 524 webResponses[1].setResponseType(WebServiceWorkerResponseTypeDefault); |
| 519 | 525 |
| 520 Cache* cache = Cache::create(new MatchAllAndBatchTestCache(webResponses)); | 526 Cache* cache = Cache::create(new MatchAllAndBatchTestCache(webResponses)); |
| 521 | 527 |
| 522 CacheQueryOptions options; | 528 CacheQueryOptions options; |
| 523 ScriptPromise result = cache->matchAll(scriptState(), "http://some.url/", op
tions); | 529 ScriptPromise result = cache->matchAll(scriptState(), "http://some.url/", op
tions, exceptionState()); |
| 524 ScriptValue scriptValue = getResolveValue(result); | 530 ScriptValue scriptValue = getResolveValue(result); |
| 525 | 531 |
| 526 NonThrowableExceptionState exceptionState; | 532 Vector<v8::Handle<v8::Value> > responses = toImplArray<v8::Handle<v8::Value>
>(scriptValue.v8Value(), 0, isolate(), exceptionState()); |
| 527 Vector<v8::Handle<v8::Value> > responses = toImplArray<v8::Handle<v8::Value>
>(scriptValue.v8Value(), 0, isolate(), exceptionState); | |
| 528 EXPECT_EQ(expectedUrls.size(), responses.size()); | 533 EXPECT_EQ(expectedUrls.size(), responses.size()); |
| 529 for (int i = 0, minsize = std::min(expectedUrls.size(), responses.size()); i
< minsize; ++i) { | 534 for (int i = 0, minsize = std::min(expectedUrls.size(), responses.size()); i
< minsize; ++i) { |
| 530 Response* response = V8Response::toImplWithTypeCheck(isolate(), response
s[i]); | 535 Response* response = V8Response::toImplWithTypeCheck(isolate(), response
s[i]); |
| 531 EXPECT_TRUE(response); | 536 EXPECT_TRUE(response); |
| 532 if (response) | 537 if (response) |
| 533 EXPECT_EQ(expectedUrls[i], response->url()); | 538 EXPECT_EQ(expectedUrls[i], response->url()); |
| 534 } | 539 } |
| 535 | 540 |
| 536 result = cache->deleteFunction(scriptState(), "http://some.url/", options); | 541 result = cache->deleteFunction(scriptState(), "http://some.url/", options, e
xceptionState()); |
| 537 scriptValue = getResolveValue(result); | 542 scriptValue = getResolveValue(result); |
| 538 EXPECT_TRUE(scriptValue.v8Value()->IsBoolean()); | 543 EXPECT_TRUE(scriptValue.v8Value()->IsBoolean()); |
| 539 EXPECT_EQ(true, scriptValue.v8Value()->BooleanValue()); | 544 EXPECT_EQ(true, scriptValue.v8Value()->BooleanValue()); |
| 540 } | 545 } |
| 541 | 546 |
| 542 } // namespace | 547 } // namespace |
| 543 } // namespace blink | 548 } // namespace blink |
| OLD | NEW |