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

Side by Side Diff: net/url_request/url_request_unittest.cc

Issue 2099243002: PlzNavigate: properly set the initiator of the navigation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 4 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 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 <memory> 5 #include <memory>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 2744 matching lines...) Expand 10 before | Expand all | Expand 10 after
2755 req->Start(); 2755 req->Start();
2756 base::RunLoop().Run(); 2756 base::RunLoop().Run();
2757 2757
2758 EXPECT_NE(std::string::npos, 2758 EXPECT_NE(std::string::npos,
2759 d.data_received().find("StrictSameSiteCookie=1")); 2759 d.data_received().find("StrictSameSiteCookie=1"));
2760 EXPECT_NE(std::string::npos, d.data_received().find("LaxSameSiteCookie=1")); 2760 EXPECT_NE(std::string::npos, d.data_received().find("LaxSameSiteCookie=1"));
2761 EXPECT_EQ(0, network_delegate.blocked_get_cookies_count()); 2761 EXPECT_EQ(0, network_delegate.blocked_get_cookies_count());
2762 EXPECT_EQ(0, network_delegate.blocked_set_cookie_count()); 2762 EXPECT_EQ(0, network_delegate.blocked_set_cookie_count());
2763 } 2763 }
2764 2764
2765 // Verify that both cookies are sent when the request has no initiator (can
2766 // happen for main frame browser-initiated navigations).
2767 {
2768 TestDelegate d;
2769 std::unique_ptr<URLRequest> req(default_context_.CreateRequest(
2770 test_server.GetURL(kHost, "/echoheader?Cookie"), DEFAULT_PRIORITY, &d));
2771 req->set_first_party_for_cookies(test_server.GetURL(kHost, "/"));
2772 req->Start();
2773 base::RunLoop().Run();
2774
2775 EXPECT_NE(std::string::npos,
2776 d.data_received().find("StrictSameSiteCookie=1"));
2777 EXPECT_NE(std::string::npos, d.data_received().find("LaxSameSiteCookie=1"));
2778 EXPECT_EQ(0, network_delegate.blocked_get_cookies_count());
2779 EXPECT_EQ(0, network_delegate.blocked_set_cookie_count());
2780 }
2781
2765 // Verify that both cookies are sent for same-registrable-domain requests. 2782 // Verify that both cookies are sent for same-registrable-domain requests.
2766 { 2783 {
2767 TestDelegate d; 2784 TestDelegate d;
2768 std::unique_ptr<URLRequest> req(default_context_.CreateRequest( 2785 std::unique_ptr<URLRequest> req(default_context_.CreateRequest(
2769 test_server.GetURL(kHost, "/echoheader?Cookie"), DEFAULT_PRIORITY, &d)); 2786 test_server.GetURL(kHost, "/echoheader?Cookie"), DEFAULT_PRIORITY, &d));
2770 req->set_first_party_for_cookies(test_server.GetURL(kSubHost, "/")); 2787 req->set_first_party_for_cookies(test_server.GetURL(kSubHost, "/"));
2771 req->set_initiator(url::Origin(test_server.GetURL(kSubHost, "/"))); 2788 req->set_initiator(url::Origin(test_server.GetURL(kSubHost, "/")));
2772 req->Start(); 2789 req->Start();
2773 base::RunLoop().Run(); 2790 base::RunLoop().Run();
2774 2791
(...skipping 7859 matching lines...) Expand 10 before | Expand all | Expand 10 after
10634 AddTestInterceptor()->set_main_intercept_job(std::move(job)); 10651 AddTestInterceptor()->set_main_intercept_job(std::move(job));
10635 10652
10636 req->Start(); 10653 req->Start();
10637 req->Cancel(); 10654 req->Cancel();
10638 base::RunLoop().RunUntilIdle(); 10655 base::RunLoop().RunUntilIdle();
10639 EXPECT_EQ(ERR_ABORTED, d.request_status()); 10656 EXPECT_EQ(ERR_ABORTED, d.request_status());
10640 EXPECT_EQ(0, d.received_redirect_count()); 10657 EXPECT_EQ(0, d.received_redirect_count());
10641 } 10658 }
10642 10659
10643 } // namespace net 10660 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698