Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/json/json_string_value_serializer.h" | 9 #include "base/json/json_string_value_serializer.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 376 | 376 |
| 377 // Second navigation to content with an img. | 377 // Second navigation to content with an img. |
| 378 std::string img_content = | 378 std::string img_content = |
| 379 "<img src=\"" + preconnect_url.spec() + "test.gif\">"; | 379 "<img src=\"" + preconnect_url.spec() + "test.gif\">"; |
| 380 NavigateToDataURLWithContent(img_content); | 380 NavigateToDataURLWithContent(img_content); |
| 381 connection_listener_->WaitUntilFirstConnectionRead(); | 381 connection_listener_->WaitUntilFirstConnectionRead(); |
| 382 EXPECT_EQ(1u, connection_listener_->GetAcceptedSocketCount()); | 382 EXPECT_EQ(1u, connection_listener_->GetAcceptedSocketCount()); |
| 383 EXPECT_EQ(1u, connection_listener_->GetReadSocketCount()); | 383 EXPECT_EQ(1u, connection_listener_->GetReadSocketCount()); |
| 384 } | 384 } |
| 385 | 385 |
| 386 // Tests that preconnect warms up a crossorigin socket connection to a test | |
| 387 // server, | |
| 388 // and that that socket is later used when fetching an anonymous resource. | |
|
mmenke
2015/07/09 15:55:56
nit: Fix line wrap (Weird to wrap at a comma, and
Yoav Weiss
2015/07/09 16:19:39
fixed
| |
| 389 // Note: This test uses a data URI to serve the preconnect hint, to make sure | |
| 390 // that the network stack doesn't just re-use its connection to the test server. | |
| 391 IN_PROC_BROWSER_TEST_F(PredictorBrowserTest, PreconnectAndUseAnonymous) { | |
| 392 GURL preconnect_url = embedded_test_server()->base_url(); | |
| 393 // First navigation to content with a preconnect hint. | |
| 394 std::string preconnect_content = "<link rel=\"preconnect\" href=\"" + | |
| 395 preconnect_url.spec() + "\" crossorigin>"; | |
| 396 NavigateToDataURLWithContent(preconnect_content); | |
| 397 connection_listener_->WaitUntilFirstConnectionAccepted(); | |
| 398 EXPECT_EQ(1u, connection_listener_->GetAcceptedSocketCount()); | |
| 399 EXPECT_EQ(0u, connection_listener_->GetReadSocketCount()); | |
| 400 | |
| 401 // Second navigation to content with an img. | |
| 402 std::string font_content = "<script>var font = new FontFace('FontA', 'url(" + | |
| 403 preconnect_url.spec() + | |
| 404 "test.woff2)');font.load();</script>"; | |
|
mmenke
2015/07/09 15:55:56
Why would this test fail without the crossorigin o
Yoav Weiss
2015/07/09 16:19:39
Since this is a request for a font resource, which
mmenke
2015/07/09 16:31:30
So how does one request make it to the PM pool, an
| |
| 405 NavigateToDataURLWithContent(font_content); | |
| 406 connection_listener_->WaitUntilFirstConnectionRead(); | |
| 407 EXPECT_EQ(1u, connection_listener_->GetAcceptedSocketCount()); | |
| 408 EXPECT_EQ(1u, connection_listener_->GetReadSocketCount()); | |
| 409 } | |
| 386 } // namespace chrome_browser_net | 410 } // namespace chrome_browser_net |
|
mmenke
2015/07/09 15:55:56
nit: Blank line before end of namespace.
Yoav Weiss
2015/07/09 16:19:39
added
| |
| 387 | 411 |
| OLD | NEW |