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

Side by Side Diff: content/browser/loader/resource_dispatcher_host_browsertest.cc

Issue 2147473002: Set 'ResourceRequest::requestorOrigin' in Blink for more request types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: jochen Created 4 years, 5 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
« no previous file with comments | « no previous file | content/renderer/render_frame_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/public/browser/resource_dispatcher_host.h" 5 #include "content/public/browser/resource_dispatcher_host.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 content::BrowserThread::IO, FROM_HERE, 811 content::BrowserThread::IO, FROM_HERE,
812 base::Bind(&RequestDataResourceDispatcherHostDelegate::SetDelegate, 812 base::Bind(&RequestDataResourceDispatcherHostDelegate::SetDelegate,
813 base::Unretained(delegate_.get()))); 813 base::Unretained(delegate_.get())));
814 } 814 }
815 815
816 protected: 816 protected:
817 std::unique_ptr<RequestDataResourceDispatcherHostDelegate> delegate_; 817 std::unique_ptr<RequestDataResourceDispatcherHostDelegate> delegate_;
818 }; 818 };
819 819
820 IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest, Basic) { 820 IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest, Basic) {
821 GURL top_url(embedded_test_server()->GetURL("/simple_page.html")); 821 GURL top_url(embedded_test_server()->GetURL("/page_with_subresources.html"));
822 url::Origin top_origin(top_url); 822 url::Origin top_origin(top_url);
823 823
824 NavigateToURLBlockUntilNavigationsComplete(shell(), top_url, 1); 824 NavigateToURLBlockUntilNavigationsComplete(shell(), top_url, 1);
825 825
826 EXPECT_EQ(1u, delegate_->data().size()); 826 EXPECT_EQ(8u, delegate_->data().size());
827 827
828 // User-initiated top-level navigations have a first-party and initiator that 828 // All resources loaded directly by the top-level document (including the
829 // matches the URL to which they navigate. 829 // top-level document itself) should have a |first_party| and |initiator|
830 // that match the URL of the top-level document.
831 for (const auto& request : delegate_->data()) {
832 SCOPED_TRACE(request->url);
833 EXPECT_EQ(top_url, request->first_party);
834 EXPECT_EQ(top_origin, request->initiator);
835 }
836 }
837
838 IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest,
839 BasicCrossSite) {
840 host_resolver()->AddRule("*", "127.0.0.1");
841 GURL top_url(embedded_test_server()->GetURL(
842 "a.com", "/nested_page_with_subresources.html"));
843 GURL nested_url(embedded_test_server()->GetURL(
844 "not-a.com", "/page_with_subresources.html"));
845 url::Origin top_origin(top_url);
846 url::Origin nested_origin(nested_url);
847
848 NavigateToURLBlockUntilNavigationsComplete(shell(), top_url, 1);
849
850 EXPECT_EQ(9u, delegate_->data().size());
851
852 // The first items loaded are the top-level and nested documents. These should
853 // both have a |first_party| and |initiator| that match the URL of the
854 // top-level document:
830 EXPECT_EQ(top_url, delegate_->data()[0]->url); 855 EXPECT_EQ(top_url, delegate_->data()[0]->url);
831 EXPECT_EQ(top_url, delegate_->data()[0]->first_party); 856 EXPECT_EQ(top_url, delegate_->data()[0]->first_party);
832 EXPECT_EQ(top_origin, delegate_->data()[0]->initiator); 857 EXPECT_EQ(top_origin, delegate_->data()[0]->initiator);
858
859 EXPECT_EQ(nested_url, delegate_->data()[1]->url);
860 EXPECT_EQ(top_url, delegate_->data()[1]->first_party);
861 EXPECT_EQ(top_origin, delegate_->data()[1]->initiator);
862
863 // The remaining items are loaded as subresources in the nested document, and
864 // should have a unique first-party, and an initiator that matches the
865 // document in which they're embedded.
866 for (size_t i = 2; i < delegate_->data().size(); i++) {
867 SCOPED_TRACE(delegate_->data()[i]->url);
868 EXPECT_EQ(kURLWithUniqueOrigin, delegate_->data()[i]->first_party);
869 EXPECT_EQ(nested_origin, delegate_->data()[i]->initiator);
870 }
833 } 871 }
834 872
835 IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest, 873 IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest,
836 SameOriginNested) { 874 SameOriginNested) {
837 GURL top_url(embedded_test_server()->GetURL("/page_with_iframe.html")); 875 GURL top_url(embedded_test_server()->GetURL("/page_with_iframe.html"));
838 GURL image_url(embedded_test_server()->GetURL("/image.jpg")); 876 GURL image_url(embedded_test_server()->GetURL("/image.jpg"));
839 GURL nested_url(embedded_test_server()->GetURL("/title1.html")); 877 GURL nested_url(embedded_test_server()->GetURL("/title1.html"));
840 url::Origin top_origin(top_url); 878 url::Origin top_origin(top_url);
841 879
842 NavigateToURLBlockUntilNavigationsComplete(shell(), top_url, 1); 880 NavigateToURLBlockUntilNavigationsComplete(shell(), top_url, 1);
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 EXPECT_EQ(top_origin, delegate_->data()[2]->initiator); 1027 EXPECT_EQ(top_origin, delegate_->data()[2]->initiator);
990 1028
991 // Cross-origin subresource requests have a unique first-party, and an 1029 // Cross-origin subresource requests have a unique first-party, and an
992 // initiator that matches the document in which they're embedded. 1030 // initiator that matches the document in which they're embedded.
993 EXPECT_EQ(nested_js_url, delegate_->data()[3]->url); 1031 EXPECT_EQ(nested_js_url, delegate_->data()[3]->url);
994 EXPECT_EQ(kURLWithUniqueOrigin, delegate_->data()[3]->first_party); 1032 EXPECT_EQ(kURLWithUniqueOrigin, delegate_->data()[3]->first_party);
995 EXPECT_EQ(nested_origin, delegate_->data()[3]->initiator); 1033 EXPECT_EQ(nested_origin, delegate_->data()[3]->initiator);
996 } 1034 }
997 1035
998 } // namespace content 1036 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/render_frame_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698