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

Side by Side Diff: chrome/browser/net/predictor_browsertest.cc

Issue 1131293004: Add cross origin to Blink-driven preconnect (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added test and switch to a boolean Created 5 years, 7 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 unified diff | Download patch
OLDNEW
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 "base/base64.h" 5 #include "base/base64.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/json/json_string_value_serializer.h" 7 #include "base/json/json_string_value_serializer.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/net/chrome_net_log.h" 10 #include "chrome/browser/net/chrome_net_log.h"
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 net::HostPortPair host_port_pair = net::HostPortPair::FromURL(preconnect_url); 302 net::HostPortPair host_port_pair = net::HostPortPair::FromURL(preconnect_url);
303 ConnectNetLogObserver net_log_observer(host_port_pair.ToString()); 303 ConnectNetLogObserver net_log_observer(host_port_pair.ToString());
304 net_log_observer.Attach(); 304 net_log_observer.Attach();
305 305
306 ui_test_utils::NavigateToURL(browser(), GURL(data_uri)); 306 ui_test_utils::NavigateToURL(browser(), GURL(data_uri));
307 307
308 net_log_observer.WaitForConnect(); 308 net_log_observer.WaitForConnect();
309 net_log_observer.Detach(); 309 net_log_observer.Detach();
310 } 310 }
311 311
312 IN_PROC_BROWSER_TEST_F(PredictorBrowserTest, PreconnectAnonymous) {
313 ASSERT_TRUE(test_server()->Start());
314
315 // Create a HTML preconnect reference to the local server in the form
316 // <link rel="preconnect" href="http://test-server/">
317 // and navigate to it as a data URI.
318 GURL preconnect_url = test_server()->GetURL("");
319 std::string preconnect_content =
320 "<link rel=\"preconnect\" crossorigin href=\""
321 + preconnect_url.spec() + "\">";
322 std::string encoded;
323 base::Base64Encode(preconnect_content, &encoded);
324 std::string data_uri = "data:text/html;base64," + encoded;
325
326 net::HostPortPair host_port_pair = net::HostPortPair::FromURL(preconnect_url);
327 ConnectNetLogObserver net_log_observer("pm/" + host_port_pair.ToString());
328 net_log_observer.Attach();
Ryan Sleevi 2015/05/12 15:49:43 As far as tests go, I would have a hard time appro
329
330 ui_test_utils::NavigateToURL(browser(), GURL(data_uri));
331
332 net_log_observer.WaitForConnect();
333 net_log_observer.Detach();
334 }
335
312 } // namespace chrome_browser_net 336 } // namespace chrome_browser_net
313 337
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698