Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(157)

Side by Side Diff: Source/modules/serviceworkers/CacheTest.cpp

Issue 617003003: Make WebServiceWorkerResponse support ResponseType (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Put WebServiceWorkerResponseType enum in its own file (so browser can load it) Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/modules/modules.gypi ('k') | Source/modules/serviceworkers/FetchResponseData.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 WebServiceWorkerResponse& m_response; 417 WebServiceWorkerResponse& m_response;
418 }; 418 };
419 419
420 TEST_F(ServiceWorkerCacheTest, MatchResponseTest) 420 TEST_F(ServiceWorkerCacheTest, MatchResponseTest)
421 { 421 {
422 const String requestUrl = "http://request.url/"; 422 const String requestUrl = "http://request.url/";
423 const String responseUrl = "http://match.response.test/"; 423 const String responseUrl = "http://match.response.test/";
424 424
425 WebServiceWorkerResponse webResponse; 425 WebServiceWorkerResponse webResponse;
426 webResponse.setURL(KURL(ParsedURLString, responseUrl)); 426 webResponse.setURL(KURL(ParsedURLString, responseUrl));
427 webResponse.setResponseType(WebServiceWorkerResponseTypeDefault);
427 428
428 Cache* cache = Cache::create(new MatchTestCache(webResponse)); 429 Cache* cache = Cache::create(new MatchTestCache(webResponse));
429 CacheQueryOptions* options = CacheQueryOptions::create(); 430 CacheQueryOptions* options = CacheQueryOptions::create();
430 431
431 ScriptPromise result = cache->match(scriptState(), requestUrl, *options); 432 ScriptPromise result = cache->match(scriptState(), requestUrl, *options);
432 ScriptValue scriptValue = getResolveValue(result); 433 ScriptValue scriptValue = getResolveValue(result);
433 Response* response = V8Response::toImplWithTypeCheck(isolate(), scriptValue. v8Value()); 434 Response* response = V8Response::toImplWithTypeCheck(isolate(), scriptValue. v8Value());
434 ASSERT_TRUE(response); 435 ASSERT_TRUE(response);
435 EXPECT_EQ(responseUrl, response->url()); 436 EXPECT_EQ(responseUrl, response->url());
436 } 437 }
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 { 505 {
505 const String url1 = "http://first.response/"; 506 const String url1 = "http://first.response/";
506 const String url2 = "http://second.response/"; 507 const String url2 = "http://second.response/";
507 508
508 Vector<String> expectedUrls(size_t(2)); 509 Vector<String> expectedUrls(size_t(2));
509 expectedUrls[0] = url1; 510 expectedUrls[0] = url1;
510 expectedUrls[1] = url2; 511 expectedUrls[1] = url2;
511 512
512 WebVector<WebServiceWorkerResponse> webResponses(size_t(2)); 513 WebVector<WebServiceWorkerResponse> webResponses(size_t(2));
513 webResponses[0].setURL(KURL(ParsedURLString, url1)); 514 webResponses[0].setURL(KURL(ParsedURLString, url1));
515 webResponses[0].setResponseType(WebServiceWorkerResponseTypeDefault);
514 webResponses[1].setURL(KURL(ParsedURLString, url2)); 516 webResponses[1].setURL(KURL(ParsedURLString, url2));
517 webResponses[1].setResponseType(WebServiceWorkerResponseTypeDefault);
515 518
516 Cache* cache = Cache::create(new MatchAllAndBatchTestCache(webResponses)); 519 Cache* cache = Cache::create(new MatchAllAndBatchTestCache(webResponses));
517 520
518 CacheQueryOptions* options = CacheQueryOptions::create(); 521 CacheQueryOptions* options = CacheQueryOptions::create();
519 ScriptPromise result = cache->matchAll(scriptState(), "http://some.url/", *o ptions); 522 ScriptPromise result = cache->matchAll(scriptState(), "http://some.url/", *o ptions);
520 ScriptValue scriptValue = getResolveValue(result); 523 ScriptValue scriptValue = getResolveValue(result);
521 524
522 NonThrowableExceptionState exceptionState; 525 NonThrowableExceptionState exceptionState;
523 Vector<v8::Handle<v8::Value> > responses = toImplArray<v8::Handle<v8::Value> >(scriptValue.v8Value(), 0, isolate(), exceptionState); 526 Vector<v8::Handle<v8::Value> > responses = toImplArray<v8::Handle<v8::Value> >(scriptValue.v8Value(), 0, isolate(), exceptionState);
524 EXPECT_EQ(expectedUrls.size(), responses.size()); 527 EXPECT_EQ(expectedUrls.size(), responses.size());
(...skipping 11 matching lines...) Expand all
536 for (int i = 0, minsize = std::min(expectedUrls.size(), responses.size()); i < minsize; ++i) { 539 for (int i = 0, minsize = std::min(expectedUrls.size(), responses.size()); i < minsize; ++i) {
537 Response* response = V8Response::toImplWithTypeCheck(isolate(), response s[i]); 540 Response* response = V8Response::toImplWithTypeCheck(isolate(), response s[i]);
538 EXPECT_TRUE(response); 541 EXPECT_TRUE(response);
539 if (response) 542 if (response)
540 EXPECT_EQ(expectedUrls[i], response->url()); 543 EXPECT_EQ(expectedUrls[i], response->url());
541 } 544 }
542 } 545 }
543 546
544 } // namespace 547 } // namespace
545 } // namespace blink 548 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/modules.gypi ('k') | Source/modules/serviceworkers/FetchResponseData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698