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

Unified Diff: content/child/web_url_loader_impl_unittest.cc

Issue 1754713006: CORS-RFC1918: Introduce the 'addressSpace' IDL attributes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: philip Created 4 years, 10 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 db13cdc70fc81e038744969f9b618a9736bb8dbb..b8bc24005fba5ce4eef6d54815db853b0ad2c95b 100644
--- a/content/child/web_url_loader_impl_unittest.cc
+++ b/content/child/web_url_loader_impl_unittest.cc
@@ -26,6 +26,7 @@
#include "content/public/child/request_peer.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/resource_response_info.h"
+#include "net/base/host_port_pair.h"
#include "net/base/net_errors.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_util.h"
@@ -710,5 +711,32 @@ TEST_F(WebURLLoaderImplTest, BrowserSideNavigationCommit) {
EXPECT_EQ(kTestData, client()->received_data());
}
+TEST_F(WebURLLoaderImplTest, ResponseIPAddress) {
+ GURL url("http://example.test/");
+
+ struct TestCase {
+ const char* ip;
+ const char* expected;
+ } cases[] = {
+ {"127.0.0.1", "127.0.0.1"},
+ {"123.123.123.123", "123.123.123.123"},
+ {"::1", "[::1]"},
+ {"2001:0db8:85a3:0000:0000:8a2e:0370:7334",
+ "[2001:0db8:85a3:0000:0000:8a2e:0370:7334]"},
+ {"2001:db8:85a3:0:0:8a2e:370:7334", "[2001:db8:85a3:0:0:8a2e:370:7334]"},
+ {"2001:db8:85a3::8a2e:370:7334", "[2001:db8:85a3::8a2e:370:7334]"},
+ {"::ffff:192.0.2.128", "[::ffff:192.0.2.128]"}};
+
+ for (const auto& test : cases) {
+ SCOPED_TRACE(test.ip);
+ content::ResourceResponseInfo info;
+ info.socket_address = net::HostPortPair(test.ip, 443);
+ blink::WebURLResponse response;
+ response.initialize();
+ WebURLLoaderImpl::PopulateURLResponse(url, info, &response, true);
+ EXPECT_EQ(test.expected, response.remoteIPAddress().utf8());
+ };
+}
+
} // namespace
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698