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

Unified Diff: content/child/web_url_loader_impl_unittest.cc

Issue 1847383003: CREDENTIAL: Rework the integration with Fetch (2/2) Base URL: https://chromium.googlesource.com/chromium/src.git@pass-serialized
Patch Set: unittest Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: content/child/web_url_loader_impl_unittest.cc
diff --git a/content/child/web_url_loader_impl_unittest.cc b/content/child/web_url_loader_impl_unittest.cc
index a85dd049118521032fd0490e46ddc52aeab8b072..a2169494c2310efd1801071b79896c622c06bc5c 100644
--- a/content/child/web_url_loader_impl_unittest.cc
+++ b/content/child/web_url_loader_impl_unittest.cc
@@ -71,6 +71,7 @@ class TestResourceDispatcher : public ResourceDispatcher {
peer_ = std::move(peer);
url_ = request_info.url;
stream_url_ = request_info.resource_body_stream_url;
+ empty_body_in_service_worker_ = request_info.empty_body_in_service_worker;
return 1;
}
@@ -85,12 +86,16 @@ class TestResourceDispatcher : public ResourceDispatcher {
const GURL& url() { return url_; }
const GURL& stream_url() { return stream_url_; }
+ bool empty_body_in_service_worker() const {
+ return empty_body_in_service_worker_;
+ }
private:
scoped_ptr<RequestPeer> peer_;
bool canceled_;
GURL url_;
GURL stream_url_;
+ bool empty_body_in_service_worker_;
DISALLOW_COPY_AND_ASSIGN(TestResourceDispatcher);
};
@@ -598,6 +603,34 @@ TEST_F(WebURLLoaderImplTest, BrowserSideNavigationCommit) {
EXPECT_EQ(kTestData, client()->received_data());
}
+TEST_F(WebURLLoaderImplTest, EmptyBodyInServiceWorkerNoCredential) {
+ // Initialize the request and kick off the load
+ blink::WebURLRequest request;
+ request.initialize();
+ request.setURL(GURL(kTestURL));
+ request.setHTTPMethod("POST");
+ client()->loader()->loadAsynchronously(request, client());
+
+ // No credential body, so the body can be given to the service worker.
+ EXPECT_FALSE(dispatcher()->empty_body_in_service_worker());
+}
+
+TEST_F(WebURLLoaderImplTest, EmptyBodyInServiceWorkerWithCredential) {
+ // Initialize the request and kick off the load
+ blink::WebURLRequest request;
+ request.initialize();
+ request.setHTTPMethod("POST");
+ request.setURL(GURL(kTestURL));
tyoshino (SeeGerritForStatus) 2016/04/12 16:30:25 order these two lines the same as EmptyBodyInServi
+
+ blink::WebHTTPBody body;
+ body.initialize();
+ request.setAttachedCredentialBody(body);
+ client()->loader()->loadAsynchronously(request, client());
+
+ // No credential body, so the body can be given to the service worker.
+ EXPECT_TRUE(dispatcher()->empty_body_in_service_worker());
+}
+
TEST_F(WebURLLoaderImplTest, ResponseIPAddress) {
GURL url("http://example.test/");

Powered by Google App Engine
This is Rietveld 408576698