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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 CompareQueryParamsForTest(expectedBatchOperations[i].matchParams, ba
tchOperations[i].matchParams); | 128 CompareQueryParamsForTest(expectedBatchOperations[i].matchParams, ba
tchOperations[i].matchParams); |
129 } | 129 } |
130 } | 130 } |
131 | 131 |
132 private: | 132 private: |
133 static void CompareQueryParamsForTest(const QueryParams& expectedQueryParams
, const QueryParams& queryParams) | 133 static void CompareQueryParamsForTest(const QueryParams& expectedQueryParams
, const QueryParams& queryParams) |
134 { | 134 { |
135 EXPECT_EQ(expectedQueryParams.ignoreSearch, queryParams.ignoreSearch); | 135 EXPECT_EQ(expectedQueryParams.ignoreSearch, queryParams.ignoreSearch); |
136 EXPECT_EQ(expectedQueryParams.ignoreMethod, queryParams.ignoreMethod); | 136 EXPECT_EQ(expectedQueryParams.ignoreMethod, queryParams.ignoreMethod); |
137 EXPECT_EQ(expectedQueryParams.ignoreVary, queryParams.ignoreVary); | 137 EXPECT_EQ(expectedQueryParams.ignoreVary, queryParams.ignoreVary); |
138 EXPECT_EQ(expectedQueryParams.prefixMatch, queryParams.prefixMatch); | |
139 EXPECT_EQ(expectedQueryParams.cacheName, queryParams.cacheName); | 138 EXPECT_EQ(expectedQueryParams.cacheName, queryParams.cacheName); |
140 } | 139 } |
141 | 140 |
142 const WebServiceWorkerCacheError m_error; | 141 const WebServiceWorkerCacheError m_error; |
143 | 142 |
144 const String* m_expectedUrl; | 143 const String* m_expectedUrl; |
145 const QueryParams* m_expectedQueryParams; | 144 const QueryParams* m_expectedQueryParams; |
146 const WebVector<BatchOperation>* m_expectedBatchOperations; | 145 const WebVector<BatchOperation>* m_expectedBatchOperations; |
147 | 146 |
148 std::string m_lastErrorWebCacheMethodCalled; | 147 std::string m_lastErrorWebCacheMethodCalled; |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 } | 358 } |
360 | 359 |
361 // Tests that arguments are faithfully passed to API calls that degrade to batch
operations. | 360 // Tests that arguments are faithfully passed to API calls that degrade to batch
operations. |
362 TEST_F(ServiceWorkerCacheTest, BatchOperationArguments) | 361 TEST_F(ServiceWorkerCacheTest, BatchOperationArguments) |
363 { | 362 { |
364 ErrorWebCacheForTests* testCache; | 363 ErrorWebCacheForTests* testCache; |
365 Cache* cache = Cache::create(testCache = new NotImplementedErrorCache()); | 364 Cache* cache = Cache::create(testCache = new NotImplementedErrorCache()); |
366 ASSERT(cache); | 365 ASSERT(cache); |
367 | 366 |
368 WebServiceWorkerCache::QueryParams expectedQueryParams; | 367 WebServiceWorkerCache::QueryParams expectedQueryParams; |
369 expectedQueryParams.prefixMatch = true; | |
370 expectedQueryParams.cacheName = "this is another cache name"; | 368 expectedQueryParams.cacheName = "this is another cache name"; |
371 testCache->setExpectedQueryParams(&expectedQueryParams); | 369 testCache->setExpectedQueryParams(&expectedQueryParams); |
372 | 370 |
373 CacheQueryOptions options; | 371 CacheQueryOptions options; |
374 options.setPrefixMatch(1); | |
375 options.setCacheName(expectedQueryParams.cacheName); | 372 options.setCacheName(expectedQueryParams.cacheName); |
376 | 373 |
377 const String url = "http://batch.operations.test/"; | 374 const String url = "http://batch.operations.test/"; |
378 Request* request = newRequestFromUrl(url); | 375 Request* request = newRequestFromUrl(url); |
379 ASSERT(request); | 376 ASSERT(request); |
380 | 377 |
381 WebServiceWorkerResponse webResponse; | 378 WebServiceWorkerResponse webResponse; |
382 webResponse.setURL(KURL(ParsedURLString, url)); | 379 webResponse.setURL(KURL(ParsedURLString, url)); |
383 Response* response = Response::create(executionContext(), webResponse); | 380 Response* response = Response::create(executionContext(), webResponse); |
384 | 381 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 } | 550 } |
554 | 551 |
555 result = cache->deleteFunction(scriptState(), stringToRequestInfo("http://so
me.url/"), options, exceptionState()); | 552 result = cache->deleteFunction(scriptState(), stringToRequestInfo("http://so
me.url/"), options, exceptionState()); |
556 scriptValue = getResolveValue(result); | 553 scriptValue = getResolveValue(result); |
557 EXPECT_TRUE(scriptValue.v8Value()->IsBoolean()); | 554 EXPECT_TRUE(scriptValue.v8Value()->IsBoolean()); |
558 EXPECT_EQ(true, scriptValue.v8Value()->BooleanValue()); | 555 EXPECT_EQ(true, scriptValue.v8Value()->BooleanValue()); |
559 } | 556 } |
560 | 557 |
561 } // namespace | 558 } // namespace |
562 } // namespace blink | 559 } // namespace blink |
OLD | NEW |