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

Side by Side Diff: third_party/WebKit/Source/modules/cachestorage/CacheTest.cpp

Issue 1969333002: [Fetch API] |(new Response(stream)).body| should return |stream| (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
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 "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/FetchFormDataConsumerHandle.h" 19 #include "modules/fetch/FetchFormDataConsumerHandle.h"
19 #include "modules/fetch/GlobalFetch.h" 20 #include "modules/fetch/GlobalFetch.h"
20 #include "modules/fetch/Request.h" 21 #include "modules/fetch/Request.h"
21 #include "modules/fetch/Response.h" 22 #include "modules/fetch/Response.h"
22 #include "modules/fetch/ResponseInit.h" 23 #include "modules/fetch/ResponseInit.h"
23 #include "public/platform/WebURLResponse.h" 24 #include "public/platform/WebURLResponse.h"
24 #include "public/platform/modules/serviceworker/WebServiceWorkerCache.h" 25 #include "public/platform/modules/serviceworker/WebServiceWorkerCache.h"
25 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
26 #include "wtf/OwnPtr.h" 27 #include "wtf/OwnPtr.h"
27 28
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 const String url = "http://www.cacheadd.test/"; 619 const String url = "http://www.cacheadd.test/";
619 const String contentType = "text/plain"; 620 const String contentType = "text/plain";
620 const String content = "hello cache"; 621 const String content = "hello cache";
621 622
622 ErrorWebCacheForTests* testCache; 623 ErrorWebCacheForTests* testCache;
623 Cache* cache = createCache(fetcher, testCache = new NotImplementedErrorCache ()); 624 Cache* cache = createCache(fetcher, testCache = new NotImplementedErrorCache ());
624 625
625 fetcher->setExpectedFetchUrl(&url); 626 fetcher->setExpectedFetchUrl(&url);
626 627
627 Request* request = newRequestFromUrl(url); 628 Request* request = newRequestFromUrl(url);
628 Response* response = Response::create(getScriptState(), FetchFormDataConsume rHandle::create(content), contentType, ResponseInit(), exceptionState()); 629 Response* response = Response::create(getScriptState(), new BodyStreamBuffer (getScriptState(), FetchFormDataConsumerHandle::create(content)), contentType, R esponseInit(), exceptionState());
629 fetcher->setResponse(response); 630 fetcher->setResponse(response);
630 631
631 WebVector<WebServiceWorkerCache::BatchOperation> expectedPutOperations(size_ t(1)); 632 WebVector<WebServiceWorkerCache::BatchOperation> expectedPutOperations(size_ t(1));
632 { 633 {
633 WebServiceWorkerCache::BatchOperation putOperation; 634 WebServiceWorkerCache::BatchOperation putOperation;
634 putOperation.operationType = WebServiceWorkerCache::OperationTypePut; 635 putOperation.operationType = WebServiceWorkerCache::OperationTypePut;
635 request->populateWebServiceWorkerRequest(putOperation.request); 636 request->populateWebServiceWorkerRequest(putOperation.request);
636 response->populateWebServiceWorkerResponse(putOperation.response); 637 response->populateWebServiceWorkerResponse(putOperation.response);
637 expectedPutOperations[0] = putOperation; 638 expectedPutOperations[0] = putOperation;
638 } 639 }
639 testCache->setExpectedBatchOperations(&expectedPutOperations); 640 testCache->setExpectedBatchOperations(&expectedPutOperations);
640 641
641 ScriptPromise addResult = cache->add(getScriptState(), requestToRequestInfo( request), exceptionState()); 642 ScriptPromise addResult = cache->add(getScriptState(), requestToRequestInfo( request), exceptionState());
642 643
643 EXPECT_EQ(kNotImplementedString, getRejectString(addResult)); 644 EXPECT_EQ(kNotImplementedString, getRejectString(addResult));
644 EXPECT_EQ(1, fetcher->fetchCount()); 645 EXPECT_EQ(1, fetcher->fetchCount());
645 EXPECT_EQ("dispatchBatch", testCache->getAndClearLastErrorWebCacheMethodCall ed()); 646 EXPECT_EQ("dispatchBatch", testCache->getAndClearLastErrorWebCacheMethodCall ed());
646 } 647 }
647 648
648 } // namespace 649 } // namespace
649 } // namespace blink 650 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698