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 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 | 484 |
485 WebVector<WebServiceWorkerRequest> webRequests(size_t(2)); | 485 WebVector<WebServiceWorkerRequest> webRequests(size_t(2)); |
486 webRequests[0].setURL(KURL(ParsedURLString, url1)); | 486 webRequests[0].setURL(KURL(ParsedURLString, url1)); |
487 webRequests[1].setURL(KURL(ParsedURLString, url2)); | 487 webRequests[1].setURL(KURL(ParsedURLString, url2)); |
488 | 488 |
489 Cache* cache = Cache::create(new KeysTestCache(webRequests)); | 489 Cache* cache = Cache::create(new KeysTestCache(webRequests)); |
490 | 490 |
491 ScriptPromise result = cache->keys(scriptState(), exceptionState()); | 491 ScriptPromise result = cache->keys(scriptState(), exceptionState()); |
492 ScriptValue scriptValue = getResolveValue(result); | 492 ScriptValue scriptValue = getResolveValue(result); |
493 | 493 |
494 Vector<v8::Handle<v8::Value> > requests = toImplArray<v8::Handle<v8::Value>
>(scriptValue.v8Value(), 0, isolate(), exceptionState()); | 494 Vector<v8::Local<v8::Value> > requests = toImplArray<v8::Local<v8::Value> >(
scriptValue.v8Value(), 0, isolate(), exceptionState()); |
495 EXPECT_EQ(expectedUrls.size(), requests.size()); | 495 EXPECT_EQ(expectedUrls.size(), requests.size()); |
496 for (int i = 0, minsize = std::min(expectedUrls.size(), requests.size()); i
< minsize; ++i) { | 496 for (int i = 0, minsize = std::min(expectedUrls.size(), requests.size()); i
< minsize; ++i) { |
497 Request* request = V8Request::toImplWithTypeCheck(isolate(), requests[i]
); | 497 Request* request = V8Request::toImplWithTypeCheck(isolate(), requests[i]
); |
498 EXPECT_TRUE(request); | 498 EXPECT_TRUE(request); |
499 if (request) | 499 if (request) |
500 EXPECT_EQ(expectedUrls[i], request->url()); | 500 EXPECT_EQ(expectedUrls[i], request->url()); |
501 } | 501 } |
502 } | 502 } |
503 | 503 |
504 class MatchAllAndBatchTestCache : public NotImplementedErrorCache { | 504 class MatchAllAndBatchTestCache : public NotImplementedErrorCache { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 webResponses[0].setResponseType(WebServiceWorkerResponseTypeDefault); | 536 webResponses[0].setResponseType(WebServiceWorkerResponseTypeDefault); |
537 webResponses[1].setURL(KURL(ParsedURLString, url2)); | 537 webResponses[1].setURL(KURL(ParsedURLString, url2)); |
538 webResponses[1].setResponseType(WebServiceWorkerResponseTypeDefault); | 538 webResponses[1].setResponseType(WebServiceWorkerResponseTypeDefault); |
539 | 539 |
540 Cache* cache = Cache::create(new MatchAllAndBatchTestCache(webResponses)); | 540 Cache* cache = Cache::create(new MatchAllAndBatchTestCache(webResponses)); |
541 | 541 |
542 CacheQueryOptions options; | 542 CacheQueryOptions options; |
543 ScriptPromise result = cache->matchAll(scriptState(), stringToRequestInfo("h
ttp://some.url/"), options, exceptionState()); | 543 ScriptPromise result = cache->matchAll(scriptState(), stringToRequestInfo("h
ttp://some.url/"), options, exceptionState()); |
544 ScriptValue scriptValue = getResolveValue(result); | 544 ScriptValue scriptValue = getResolveValue(result); |
545 | 545 |
546 Vector<v8::Handle<v8::Value> > responses = toImplArray<v8::Handle<v8::Value>
>(scriptValue.v8Value(), 0, isolate(), exceptionState()); | 546 Vector<v8::Local<v8::Value> > responses = toImplArray<v8::Local<v8::Value> >
(scriptValue.v8Value(), 0, isolate(), exceptionState()); |
547 EXPECT_EQ(expectedUrls.size(), responses.size()); | 547 EXPECT_EQ(expectedUrls.size(), responses.size()); |
548 for (int i = 0, minsize = std::min(expectedUrls.size(), responses.size()); i
< minsize; ++i) { | 548 for (int i = 0, minsize = std::min(expectedUrls.size(), responses.size()); i
< minsize; ++i) { |
549 Response* response = V8Response::toImplWithTypeCheck(isolate(), response
s[i]); | 549 Response* response = V8Response::toImplWithTypeCheck(isolate(), response
s[i]); |
550 EXPECT_TRUE(response); | 550 EXPECT_TRUE(response); |
551 if (response) | 551 if (response) |
552 EXPECT_EQ(expectedUrls[i], response->url()); | 552 EXPECT_EQ(expectedUrls[i], response->url()); |
553 } | 553 } |
554 | 554 |
555 result = cache->deleteFunction(scriptState(), stringToRequestInfo("http://so
me.url/"), options, exceptionState()); | 555 result = cache->deleteFunction(scriptState(), stringToRequestInfo("http://so
me.url/"), options, exceptionState()); |
556 scriptValue = getResolveValue(result); | 556 scriptValue = getResolveValue(result); |
557 EXPECT_TRUE(scriptValue.v8Value()->IsBoolean()); | 557 EXPECT_TRUE(scriptValue.v8Value()->IsBoolean()); |
558 EXPECT_EQ(true, scriptValue.v8Value()->BooleanValue()); | 558 EXPECT_EQ(true, scriptValue.v8Value()->BooleanValue()); |
559 } | 559 } |
560 | 560 |
561 } // namespace | 561 } // namespace |
562 } // namespace blink | 562 } // namespace blink |
OLD | NEW |