| Index: chrome/browser/net/predictor_browsertest.cc
|
| diff --git a/chrome/browser/net/predictor_browsertest.cc b/chrome/browser/net/predictor_browsertest.cc
|
| index c4ebc559fd76ea783fa357a164c99dbea33be3f7..0aaa4a3b63af7c5beb2b844c8fea3b86391f27d4 100644
|
| --- a/chrome/browser/net/predictor_browsertest.cc
|
| +++ b/chrome/browser/net/predictor_browsertest.cc
|
| @@ -383,5 +383,30 @@ IN_PROC_BROWSER_TEST_F(PredictorBrowserTest, PreconnectAndUse) {
|
| EXPECT_EQ(1u, connection_listener_->GetReadSocketCount());
|
| }
|
|
|
| +// Tests that preconnect warms up a crossorigin socket connection to a test
|
| +// server, and that that socket is later used when fetching an anonymous
|
| +// resource.
|
| +// Note: This test uses a data URI to serve the preconnect hint, to make sure
|
| +// that the network stack doesn't just re-use its connection to the test server.
|
| +IN_PROC_BROWSER_TEST_F(PredictorBrowserTest, PreconnectAndUseAnonymous) {
|
| + GURL preconnect_url = embedded_test_server()->base_url();
|
| + // First navigation to content with a preconnect hint.
|
| + std::string preconnect_content = "<link rel=\"preconnect\" href=\"" +
|
| + preconnect_url.spec() + "\" crossorigin>";
|
| + NavigateToDataURLWithContent(preconnect_content);
|
| + connection_listener_->WaitUntilFirstConnectionAccepted();
|
| + EXPECT_EQ(1u, connection_listener_->GetAcceptedSocketCount());
|
| + EXPECT_EQ(0u, connection_listener_->GetReadSocketCount());
|
| +
|
| + // Second navigation to content with a font.
|
| + std::string font_content = "<script>var font = new FontFace('FontA', 'url(" +
|
| + preconnect_url.spec() +
|
| + "test.woff2)');font.load();</script>";
|
| + NavigateToDataURLWithContent(font_content);
|
| + connection_listener_->WaitUntilFirstConnectionRead();
|
| + EXPECT_EQ(1u, connection_listener_->GetAcceptedSocketCount());
|
| + EXPECT_EQ(1u, connection_listener_->GetReadSocketCount());
|
| +}
|
| +
|
| } // namespace chrome_browser_net
|
|
|
|
|