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

Unified Diff: content/child/web_url_loader_impl_unittest.cc

Issue 771593006: Properly handle defers loading in WebURLLoaderImpl for data uris (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « content/child/web_url_loader_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 e44a000797ed81a2a40f48445e7124e61c2db6dc..d82401c2ddd58b9e5cd6fa9f3431dbb1981f9870 100644
--- a/content/child/web_url_loader_impl_unittest.cc
+++ b/content/child/web_url_loader_impl_unittest.cc
@@ -507,7 +507,7 @@ TEST_F(WebURLLoaderImplTest, DataURLDeleteOnReceiveData) {
EXPECT_FALSE(bridge());
}
-TEST_F(WebURLLoaderImplTest, DataURLDeleteOnFinisha) {
+TEST_F(WebURLLoaderImplTest, DataURLDeleteOnFinish) {
blink::WebURLRequest request;
request.initialize();
request.setURL(GURL("data:text/html;charset=utf-8,blah!"));
@@ -520,6 +520,44 @@ TEST_F(WebURLLoaderImplTest, DataURLDeleteOnFinisha) {
EXPECT_FALSE(bridge());
}
+TEST_F(WebURLLoaderImplTest, DataURLDefersLoading) {
+ blink::WebURLRequest request;
+ request.initialize();
+ request.setURL(GURL("data:text/html;charset=utf-8,blah!"));
+ client()->loader()->loadAsynchronously(request, client());
+
+ // setDefersLoading() might be called with either false or true in no
+ // specific order. The user of the API will not have sufficient information
+ // about the WebURLLoader's internal state, so the latter gracefully needs to
+ // handle calling setDefersLoading any number of times with any values from
+ // any point in time.
+
+ client()->loader()->setDefersLoading(false);
+ client()->loader()->setDefersLoading(true);
+ client()->loader()->setDefersLoading(true);
+ message_loop()->RunUntilIdle();
+ EXPECT_FALSE(client()->did_finish());
+
+ client()->loader()->setDefersLoading(false);
+ client()->loader()->setDefersLoading(true);
+ message_loop()->RunUntilIdle();
+ EXPECT_FALSE(client()->did_finish());
+
+ client()->loader()->setDefersLoading(false);
+ message_loop()->RunUntilIdle();
+ EXPECT_TRUE(client()->did_finish());
+
+ client()->loader()->setDefersLoading(true);
+ client()->loader()->setDefersLoading(false);
+ client()->loader()->setDefersLoading(false);
+ message_loop()->RunUntilIdle();
+ EXPECT_TRUE(client()->did_finish());
+
+ EXPECT_EQ("blah!", client()->received_data());
+ EXPECT_EQ(net::OK, client()->error().reason);
+ EXPECT_EQ("", client()->error().domain.utf8());
+}
+
// FTP integration tests. These are focused more on safe deletion than correct
// parsing of FTP responses.
« no previous file with comments | « content/child/web_url_loader_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698