| 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 "modules/cachestorage/Cache.h" | 5 #include "modules/cachestorage/Cache.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
| 8 #include "bindings/core/v8/ScriptFunction.h" | 8 #include "bindings/core/v8/ScriptFunction.h" |
| 9 #include "bindings/core/v8/ScriptPromise.h" | 9 #include "bindings/core/v8/ScriptPromise.h" |
| 10 #include "bindings/core/v8/ScriptPromiseResolver.h" | 10 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 11 #include "bindings/core/v8/ScriptValue.h" | 11 #include "bindings/core/v8/ScriptValue.h" |
| 12 #include "bindings/core/v8/V8Binding.h" | 12 #include "bindings/core/v8/V8Binding.h" |
| 13 #include "bindings/modules/v8/V8Request.h" | 13 #include "bindings/modules/v8/V8Request.h" |
| 14 #include "bindings/modules/v8/V8Response.h" | 14 #include "bindings/modules/v8/V8Response.h" |
| 15 #include "core/dom/Document.h" | 15 #include "core/dom/Document.h" |
| 16 #include "core/frame/Frame.h" | 16 #include "core/frame/Frame.h" |
| 17 #include "core/testing/DummyPageHolder.h" | 17 #include "core/testing/DummyPageHolder.h" |
| 18 #include "modules/fetch/BodyStreamBuffer.h" | 18 #include "modules/fetch/BodyStreamBuffer.h" |
| 19 #include "modules/fetch/FetchFormDataConsumerHandle.h" | 19 #include "modules/fetch/FormDataBytesConsumer.h" |
| 20 #include "modules/fetch/GlobalFetch.h" | 20 #include "modules/fetch/GlobalFetch.h" |
| 21 #include "modules/fetch/Request.h" | 21 #include "modules/fetch/Request.h" |
| 22 #include "modules/fetch/Response.h" | 22 #include "modules/fetch/Response.h" |
| 23 #include "modules/fetch/ResponseInit.h" | 23 #include "modules/fetch/ResponseInit.h" |
| 24 #include "public/platform/WebURLResponse.h" | 24 #include "public/platform/WebURLResponse.h" |
| 25 #include "public/platform/modules/serviceworker/WebServiceWorkerCache.h" | 25 #include "public/platform/modules/serviceworker/WebServiceWorkerCache.h" |
| 26 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
| 27 #include "wtf/PtrUtil.h" | 27 #include "wtf/PtrUtil.h" |
| 28 #include <algorithm> | 28 #include <algorithm> |
| 29 #include <memory> | 29 #include <memory> |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 const String url = "http://www.cacheadd.test/"; | 619 const String url = "http://www.cacheadd.test/"; |
| 620 const String contentType = "text/plain"; | 620 const String contentType = "text/plain"; |
| 621 const String content = "hello cache"; | 621 const String content = "hello cache"; |
| 622 | 622 |
| 623 ErrorWebCacheForTests* testCache; | 623 ErrorWebCacheForTests* testCache; |
| 624 Cache* cache = createCache(fetcher, testCache = new NotImplementedErrorCache
()); | 624 Cache* cache = createCache(fetcher, testCache = new NotImplementedErrorCache
()); |
| 625 | 625 |
| 626 fetcher->setExpectedFetchUrl(&url); | 626 fetcher->setExpectedFetchUrl(&url); |
| 627 | 627 |
| 628 Request* request = newRequestFromUrl(url); | 628 Request* request = newRequestFromUrl(url); |
| 629 Response* response = Response::create(getScriptState(), new BodyStreamBuffer
(getScriptState(), FetchFormDataConsumerHandle::create(content)), contentType, R
esponseInit(), exceptionState); | 629 Response* response = Response::create(getScriptState(), new BodyStreamBuffer
(getScriptState(), new FormDataBytesConsumer(content)), contentType, ResponseIni
t(), exceptionState); |
| 630 fetcher->setResponse(response); | 630 fetcher->setResponse(response); |
| 631 | 631 |
| 632 WebVector<WebServiceWorkerCache::BatchOperation> expectedPutOperations(size_
t(1)); | 632 WebVector<WebServiceWorkerCache::BatchOperation> expectedPutOperations(size_
t(1)); |
| 633 { | 633 { |
| 634 WebServiceWorkerCache::BatchOperation putOperation; | 634 WebServiceWorkerCache::BatchOperation putOperation; |
| 635 putOperation.operationType = WebServiceWorkerCache::OperationTypePut; | 635 putOperation.operationType = WebServiceWorkerCache::OperationTypePut; |
| 636 request->populateWebServiceWorkerRequest(putOperation.request); | 636 request->populateWebServiceWorkerRequest(putOperation.request); |
| 637 response->populateWebServiceWorkerResponse(putOperation.response); | 637 response->populateWebServiceWorkerResponse(putOperation.response); |
| 638 expectedPutOperations[0] = putOperation; | 638 expectedPutOperations[0] = putOperation; |
| 639 } | 639 } |
| 640 testCache->setExpectedBatchOperations(&expectedPutOperations); | 640 testCache->setExpectedBatchOperations(&expectedPutOperations); |
| 641 | 641 |
| 642 ScriptPromise addResult = cache->add(getScriptState(), requestToRequestInfo(
request), exceptionState); | 642 ScriptPromise addResult = cache->add(getScriptState(), requestToRequestInfo(
request), exceptionState); |
| 643 | 643 |
| 644 EXPECT_EQ(kNotImplementedString, getRejectString(addResult)); | 644 EXPECT_EQ(kNotImplementedString, getRejectString(addResult)); |
| 645 EXPECT_EQ(1, fetcher->fetchCount()); | 645 EXPECT_EQ(1, fetcher->fetchCount()); |
| 646 EXPECT_EQ("dispatchBatch", testCache->getAndClearLastErrorWebCacheMethodCall
ed()); | 646 EXPECT_EQ("dispatchBatch", testCache->getAndClearLastErrorWebCacheMethodCall
ed()); |
| 647 } | 647 } |
| 648 | 648 |
| 649 } // namespace | 649 } // namespace |
| 650 | 650 |
| 651 } // namespace blink | 651 } // namespace blink |
| OLD | NEW |