Commit 2d217373 authored by John Abd-El-Malek's avatar John Abd-El-Malek Committed by Commit Bot

Convert RequestDataResourceDispatcherHostBrowserTest tests to work with network service.

Bug: 729848
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_mojo
Change-Id: I7bafe16cda83030209f357340c6503154e9b55cf
Reviewed-on: https://chromium-review.googlesource.com/1027121Reviewed-by: default avatarMike West <mkwst@chromium.org>
Commit-Queue: John Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553531}
parent ef7a3da7
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "content/public/test/content_browser_test_utils.h" #include "content/public/test/content_browser_test_utils.h"
#include "content/public/test/test_navigation_observer.h" #include "content/public/test/test_navigation_observer.h"
#include "content/public/test/test_utils.h" #include "content/public/test/test_utils.h"
#include "content/public/test/url_loader_interceptor.h"
#include "content/shell/browser/shell.h" #include "content/shell/browser/shell.h"
#include "content/shell/browser/shell_content_browser_client.h" #include "content/shell/browser/shell_content_browser_client.h"
#include "content/shell/browser/shell_network_delegate.h" #include "content/shell/browser/shell_network_delegate.h"
...@@ -841,18 +842,18 @@ IN_PROC_BROWSER_TEST_F(PreviewsStateResourceDispatcherHostBrowserTest, ...@@ -841,18 +842,18 @@ IN_PROC_BROWSER_TEST_F(PreviewsStateResourceDispatcherHostBrowserTest,
namespace { namespace {
struct RequestDataForDelegate { struct RequestData {
const GURL url; const GURL url;
const GURL first_party; const GURL first_party;
const base::Optional<url::Origin> initiator; const base::Optional<url::Origin> initiator;
const int load_flags; const int load_flags;
const std::string referrer; const std::string referrer;
RequestDataForDelegate(const GURL& url, RequestData(const GURL& url,
const GURL& first_party, const GURL& first_party,
const base::Optional<url::Origin>& initiator, const base::Optional<url::Origin>& initiator,
int load_flags, int load_flags,
const std::string& referrer) const std::string& referrer)
: url(url), : url(url),
first_party(first_party), first_party(first_party),
initiator(initiator), initiator(initiator),
...@@ -865,11 +866,10 @@ struct RequestDataForDelegate { ...@@ -865,11 +866,10 @@ struct RequestDataForDelegate {
class RequestDataResourceDispatcherHostDelegate class RequestDataResourceDispatcherHostDelegate
: public ResourceDispatcherHostDelegate { : public ResourceDispatcherHostDelegate {
public: public:
RequestDataResourceDispatcherHostDelegate() {} using RequestCreated = base::RepeatingCallback<void(RequestData)>;
explicit RequestDataResourceDispatcherHostDelegate(
const std::vector<std::unique_ptr<RequestDataForDelegate>>& data() { const RequestCreated& callback)
return requests_; : callback_(callback) {}
}
// ResourceDispatcherHostDelegate implementation: // ResourceDispatcherHostDelegate implementation:
void RequestBeginning( void RequestBeginning(
...@@ -878,16 +878,17 @@ class RequestDataResourceDispatcherHostDelegate ...@@ -878,16 +878,17 @@ class RequestDataResourceDispatcherHostDelegate
AppCacheService* appcache_service, AppCacheService* appcache_service,
ResourceType resource_type, ResourceType resource_type,
std::vector<std::unique_ptr<ResourceThrottle>>* throttles) override { std::vector<std::unique_ptr<ResourceThrottle>>* throttles) override {
requests_.push_back(std::make_unique<RequestDataForDelegate>( if (!IsResourceTypeFrame(resource_type))
request->url(), request->site_for_cookies(), request->initiator(), return;
request->load_flags(), request->referrer())); callback_.Run(RequestData(request->url(), request->site_for_cookies(),
request->initiator(), request->load_flags(),
request->referrer()));
} }
void SetDelegate() { ResourceDispatcherHost::Get()->SetDelegate(this); } void SetDelegate() { ResourceDispatcherHost::Get()->SetDelegate(this); }
private: private:
std::vector<std::unique_ptr<RequestDataForDelegate>> requests_; RequestCreated callback_;
DISALLOW_COPY_AND_ASSIGN(RequestDataResourceDispatcherHostDelegate); DISALLOW_COPY_AND_ASSIGN(RequestDataResourceDispatcherHostDelegate);
}; };
...@@ -895,67 +896,100 @@ const GURL kURLWithUniqueOrigin("data:,"); ...@@ -895,67 +896,100 @@ const GURL kURLWithUniqueOrigin("data:,");
} // namespace } // namespace
class RequestDataResourceDispatcherHostBrowserTest : public ContentBrowserTest { class RequestDataBrowserTest : public ContentBrowserTest {
public: public:
~RequestDataResourceDispatcherHostBrowserTest() override {} RequestDataBrowserTest()
: interceptor_(std::make_unique<content::URLLoaderInterceptor>(
base::BindRepeating(&RequestDataBrowserTest::OnRequest,
base::Unretained(this)))) {}
~RequestDataBrowserTest() override {}
std::vector<RequestData> data() {
base::AutoLock auto_lock(requests_lock_);
auto copy = requests_;
return copy;
}
protected: private:
void SetUpOnMainThread() override { void SetUpOnMainThread() override {
ContentBrowserTest::SetUpOnMainThread(); ContentBrowserTest::SetUpOnMainThread();
ASSERT_TRUE(embedded_test_server()->Start()); ASSERT_TRUE(embedded_test_server()->Start());
delegate_.reset(new RequestDataResourceDispatcherHostDelegate()); if (!base::FeatureList::IsEnabled(network::features::kNetworkService)) {
delegate_.reset(new RequestDataResourceDispatcherHostDelegate(
base::BindRepeating(&RequestDataBrowserTest::RequestCreated,
base::Unretained(this))));
content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE,
base::BindOnce(
&RequestDataResourceDispatcherHostDelegate::SetDelegate,
base::Unretained(delegate_.get())));
}
content::BrowserThread::PostTask(
content::BrowserThread::IO, FROM_HERE,
base::BindOnce(&RequestDataResourceDispatcherHostDelegate::SetDelegate,
base::Unretained(delegate_.get())));
host_resolver()->AddRule("*", "127.0.0.1"); host_resolver()->AddRule("*", "127.0.0.1");
} }
protected: void TearDownOnMainThread() override { interceptor_.reset(); }
bool OnRequest(URLLoaderInterceptor::RequestParams* params) {
RequestCreated(RequestData(
params->url_request.url, params->url_request.site_for_cookies,
params->url_request.request_initiator, params->url_request.load_flags,
params->url_request.referrer.spec()));
return false;
}
void RequestCreated(RequestData data) {
base::AutoLock auto_lock(requests_lock_);
requests_.push_back(data);
}
base::Lock requests_lock_;
std::vector<RequestData> requests_;
std::unique_ptr<URLLoaderInterceptor> interceptor_;
std::unique_ptr<RequestDataResourceDispatcherHostDelegate> delegate_; std::unique_ptr<RequestDataResourceDispatcherHostDelegate> delegate_;
}; };
IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest, Basic) { IN_PROC_BROWSER_TEST_F(RequestDataBrowserTest, Basic) {
GURL top_url(embedded_test_server()->GetURL("/page_with_subresources.html")); GURL top_url(embedded_test_server()->GetURL("/page_with_subresources.html"));
url::Origin top_origin = url::Origin::Create(top_url); url::Origin top_origin = url::Origin::Create(top_url);
NavigateToURLBlockUntilNavigationsComplete(shell(), top_url, 1); NavigateToURLBlockUntilNavigationsComplete(shell(), top_url, 1);
EXPECT_EQ(8u, delegate_->data().size()); auto requests = data();
EXPECT_EQ(8u, requests.size());
// All resources loaded directly by the top-level document should have a // All resources loaded directly by the top-level document should have a
// |first_party| and |initiator| that match the URL of the top-level document. // |first_party| and |initiator| that match the URL of the top-level document.
// The top-level document itself doesn't have an |initiator|. // The top-level document itself doesn't have an |initiator|.
const RequestDataForDelegate* first_request = delegate_->data()[0].get(); const RequestData* first_request = &requests[0];
EXPECT_EQ(top_url, first_request->first_party); EXPECT_EQ(top_url, first_request->first_party);
EXPECT_FALSE(first_request->initiator.has_value()); EXPECT_FALSE(first_request->initiator.has_value());
for (size_t i = 1; i < delegate_->data().size(); i++) { for (size_t i = 1; i < requests.size(); i++) {
const RequestDataForDelegate* request = delegate_->data()[i].get(); const RequestData* request = &requests[i];
EXPECT_EQ(top_url, request->first_party); EXPECT_EQ(top_url, request->first_party);
ASSERT_TRUE(request->initiator.has_value()); ASSERT_TRUE(request->initiator.has_value());
EXPECT_EQ(top_origin, request->initiator); EXPECT_EQ(top_origin, request->initiator);
} }
} }
IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest, IN_PROC_BROWSER_TEST_F(RequestDataBrowserTest, LinkRelPrefetch) {
LinkRelPrefetch) {
GURL top_url(embedded_test_server()->GetURL("/link_rel_prefetch.html")); GURL top_url(embedded_test_server()->GetURL("/link_rel_prefetch.html"));
url::Origin top_origin = url::Origin::Create(top_url); url::Origin top_origin = url::Origin::Create(top_url);
NavigateToURLBlockUntilNavigationsComplete(shell(), top_url, 1); NavigateToURLBlockUntilNavigationsComplete(shell(), top_url, 1);
EXPECT_EQ(2u, delegate_->data().size()); auto requests = data();
auto* request = delegate_->data()[1].get(); EXPECT_EQ(2u, requests.size());
auto* request = &requests[1];
EXPECT_EQ(top_origin, request->initiator); EXPECT_EQ(top_origin, request->initiator);
EXPECT_EQ(top_url, request->referrer); EXPECT_EQ(top_url, request->referrer);
EXPECT_TRUE(request->load_flags & net::LOAD_PREFETCH); EXPECT_TRUE(request->load_flags & net::LOAD_PREFETCH);
} }
IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest, IN_PROC_BROWSER_TEST_F(RequestDataBrowserTest, LinkRelPrefetchReferrerPolicy) {
LinkRelPrefetchReferrerPolicy) {
GURL top_url(embedded_test_server()->GetURL( GURL top_url(embedded_test_server()->GetURL(
"/link_rel_prefetch_referrer_policy.html")); "/link_rel_prefetch_referrer_policy.html"));
GURL img_url(embedded_test_server()->GetURL("/image.jpg")); GURL img_url(embedded_test_server()->GetURL("/image.jpg"));
...@@ -963,9 +997,10 @@ IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest, ...@@ -963,9 +997,10 @@ IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest,
NavigateToURLBlockUntilNavigationsComplete(shell(), top_url, 1); NavigateToURLBlockUntilNavigationsComplete(shell(), top_url, 1);
EXPECT_EQ(2u, delegate_->data().size()); auto requests = data();
auto* main_frame_request = delegate_->data()[0].get(); EXPECT_EQ(2u, requests.size());
auto* image_request = delegate_->data()[1].get(); auto* main_frame_request = &requests[0];
auto* image_request = &requests[1];
// Check the main frame request. // Check the main frame request.
EXPECT_EQ(top_url, main_frame_request->url); EXPECT_EQ(top_url, main_frame_request->url);
...@@ -980,8 +1015,7 @@ IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest, ...@@ -980,8 +1015,7 @@ IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest,
EXPECT_TRUE(image_request->load_flags & net::LOAD_PREFETCH); EXPECT_TRUE(image_request->load_flags & net::LOAD_PREFETCH);
} }
IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest, IN_PROC_BROWSER_TEST_F(RequestDataBrowserTest, BasicCrossSite) {
BasicCrossSite) {
GURL top_url(embedded_test_server()->GetURL( GURL top_url(embedded_test_server()->GetURL(
"a.com", "/nested_page_with_subresources.html")); "a.com", "/nested_page_with_subresources.html"));
GURL nested_url(embedded_test_server()->GetURL( GURL nested_url(embedded_test_server()->GetURL(
...@@ -991,32 +1025,32 @@ IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest, ...@@ -991,32 +1025,32 @@ IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest,
NavigateToURLBlockUntilNavigationsComplete(shell(), top_url, 1); NavigateToURLBlockUntilNavigationsComplete(shell(), top_url, 1);
EXPECT_EQ(9u, delegate_->data().size()); auto requests = data();
EXPECT_EQ(9u, requests.size());
// The first items loaded are the top-level and nested documents. These should // The first items loaded are the top-level and nested documents. These should
// both have a |first_party| that match the URL of the top-level document. // both have a |first_party| that match the URL of the top-level document.
// The top-level document has no initiator and the nested frame is initiated // The top-level document has no initiator and the nested frame is initiated
// by the top-level document. // by the top-level document.
EXPECT_EQ(top_url, delegate_->data()[0]->url); EXPECT_EQ(top_url, requests[0].url);
EXPECT_EQ(top_url, delegate_->data()[0]->first_party); EXPECT_EQ(top_url, requests[0].first_party);
EXPECT_FALSE(delegate_->data()[0]->initiator.has_value()); EXPECT_FALSE(requests[0].initiator.has_value());
EXPECT_EQ(nested_url, delegate_->data()[1]->url); EXPECT_EQ(nested_url, requests[1].url);
EXPECT_EQ(top_url, delegate_->data()[1]->first_party); EXPECT_EQ(top_url, requests[1].first_party);
EXPECT_EQ(top_origin, delegate_->data()[1]->initiator); EXPECT_EQ(top_origin, requests[1].initiator);
// The remaining items are loaded as subresources in the nested document, and // The remaining items are loaded as subresources in the nested document, and
// should have a unique first-party, and an initiator that matches the // should have a unique first-party, and an initiator that matches the
// document in which they're embedded. // document in which they're embedded.
for (size_t i = 2; i < delegate_->data().size(); i++) { for (size_t i = 2; i < requests.size(); i++) {
SCOPED_TRACE(delegate_->data()[i]->url); SCOPED_TRACE(requests[i].url);
EXPECT_EQ(kURLWithUniqueOrigin, delegate_->data()[i]->first_party); EXPECT_EQ(kURLWithUniqueOrigin, requests[i].first_party);
EXPECT_EQ(nested_origin, delegate_->data()[i]->initiator); EXPECT_EQ(nested_origin, requests[i].initiator);
} }
} }
IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest, IN_PROC_BROWSER_TEST_F(RequestDataBrowserTest, SameOriginNested) {
SameOriginNested) {
GURL top_url(embedded_test_server()->GetURL("/page_with_iframe.html")); GURL top_url(embedded_test_server()->GetURL("/page_with_iframe.html"));
GURL image_url(embedded_test_server()->GetURL("/image.jpg")); GURL image_url(embedded_test_server()->GetURL("/image.jpg"));
GURL nested_url(embedded_test_server()->GetURL("/title1.html")); GURL nested_url(embedded_test_server()->GetURL("/title1.html"));
...@@ -1024,30 +1058,30 @@ IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest, ...@@ -1024,30 +1058,30 @@ IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest,
NavigateToURLBlockUntilNavigationsComplete(shell(), top_url, 1); NavigateToURLBlockUntilNavigationsComplete(shell(), top_url, 1);
EXPECT_EQ(3u, delegate_->data().size()); auto requests = data();
EXPECT_EQ(3u, requests.size());
// User-initiated top-level navigations have a first-party that matches the // User-initiated top-level navigations have a first-party that matches the
// URL to which they navigate. The navigation was initiated outside of a // URL to which they navigate. The navigation was initiated outside of a
// document, so there is no |initiator|. // document, so there is no |initiator|.
EXPECT_EQ(top_url, delegate_->data()[0]->url); EXPECT_EQ(top_url, requests[0].url);
EXPECT_EQ(top_url, delegate_->data()[0]->first_party); EXPECT_EQ(top_url, requests[0].first_party);
EXPECT_FALSE(delegate_->data()[0]->initiator.has_value()); EXPECT_FALSE(requests[0].initiator.has_value());
// Subresource requests have a first-party and initiator that matches the // Subresource requests have a first-party and initiator that matches the
// document in which they're embedded. // document in which they're embedded.
EXPECT_EQ(image_url, delegate_->data()[1]->url); EXPECT_EQ(image_url, requests[1].url);
EXPECT_EQ(top_url, delegate_->data()[1]->first_party); EXPECT_EQ(top_url, requests[1].first_party);
EXPECT_EQ(top_origin, delegate_->data()[1]->initiator); EXPECT_EQ(top_origin, requests[1].initiator);
// Same-origin nested frames have a first-party and initiator that matches // Same-origin nested frames have a first-party and initiator that matches
// the document in which they're embedded. // the document in which they're embedded.
EXPECT_EQ(nested_url, delegate_->data()[2]->url); EXPECT_EQ(nested_url, requests[2].url);
EXPECT_EQ(top_url, delegate_->data()[2]->first_party); EXPECT_EQ(top_url, requests[2].first_party);
EXPECT_EQ(top_origin, delegate_->data()[2]->initiator); EXPECT_EQ(top_origin, requests[2].initiator);
} }
IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest, IN_PROC_BROWSER_TEST_F(RequestDataBrowserTest, SameOriginAuxiliary) {
SameOriginAuxiliary) {
GURL top_url(embedded_test_server()->GetURL("/simple_links.html")); GURL top_url(embedded_test_server()->GetURL("/simple_links.html"));
GURL auxiliary_url(embedded_test_server()->GetURL("/title2.html")); GURL auxiliary_url(embedded_test_server()->GetURL("/title2.html"));
url::Origin top_origin = url::Origin::Create(top_url); url::Origin top_origin = url::Origin::Create(top_url);
...@@ -1064,24 +1098,24 @@ IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest, ...@@ -1064,24 +1098,24 @@ IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest,
Shell* new_shell = new_shell_observer.GetShell(); Shell* new_shell = new_shell_observer.GetShell();
WaitForLoadStop(new_shell->web_contents()); WaitForLoadStop(new_shell->web_contents());
EXPECT_EQ(2u, delegate_->data().size()); auto requests = data();
EXPECT_EQ(2u, requests.size());
// User-initiated top-level navigations have a first-party that matches the // User-initiated top-level navigations have a first-party that matches the
// URL to which they navigate, even if they fail to load. The navigation was // URL to which they navigate, even if they fail to load. The navigation was
// initiated outside of a document, so there is no |initiator|. // initiated outside of a document, so there is no |initiator|.
EXPECT_EQ(top_url, delegate_->data()[0]->url); EXPECT_EQ(top_url, requests[0].url);
EXPECT_EQ(top_url, delegate_->data()[0]->first_party); EXPECT_EQ(top_url, requests[0].first_party);
EXPECT_FALSE(delegate_->data()[0]->initiator.has_value()); EXPECT_FALSE(requests[0].initiator.has_value());
// Auxiliary navigations have a first-party that matches the URL to which they // Auxiliary navigations have a first-party that matches the URL to which they
// navigate, and an initiator that matches the document that triggered them. // navigate, and an initiator that matches the document that triggered them.
EXPECT_EQ(auxiliary_url, delegate_->data()[1]->url); EXPECT_EQ(auxiliary_url, requests[1].url);
EXPECT_EQ(auxiliary_url, delegate_->data()[1]->first_party); EXPECT_EQ(auxiliary_url, requests[1].first_party);
EXPECT_EQ(top_origin, delegate_->data()[1]->initiator); EXPECT_EQ(top_origin, requests[1].initiator);
} }
IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest, IN_PROC_BROWSER_TEST_F(RequestDataBrowserTest, CrossOriginAuxiliary) {
CrossOriginAuxiliary) {
GURL top_url(embedded_test_server()->GetURL("/simple_links.html")); GURL top_url(embedded_test_server()->GetURL("/simple_links.html"));
GURL auxiliary_url(embedded_test_server()->GetURL("foo.com", "/title2.html")); GURL auxiliary_url(embedded_test_server()->GetURL("foo.com", "/title2.html"));
url::Origin top_origin = url::Origin::Create(top_url); url::Origin top_origin = url::Origin::Create(top_url);
...@@ -1106,24 +1140,24 @@ IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest, ...@@ -1106,24 +1140,24 @@ IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest,
Shell* new_shell = new_shell_observer.GetShell(); Shell* new_shell = new_shell_observer.GetShell();
WaitForLoadStop(new_shell->web_contents()); WaitForLoadStop(new_shell->web_contents());
EXPECT_EQ(2u, delegate_->data().size()); auto requests = data();
EXPECT_EQ(2u, requests.size());
// User-initiated top-level navigations have a first-party that matches the // User-initiated top-level navigations have a first-party that matches the
// URL to which they navigate, even if they fail to load. The navigation was // URL to which they navigate, even if they fail to load. The navigation was
// initiated outside of a document, so there is no initiator. // initiated outside of a document, so there is no initiator.
EXPECT_EQ(top_url, delegate_->data()[0]->url); EXPECT_EQ(top_url, requests[0].url);
EXPECT_EQ(top_url, delegate_->data()[0]->first_party); EXPECT_EQ(top_url, requests[0].first_party);
EXPECT_FALSE(delegate_->data()[0]->initiator.has_value()); EXPECT_FALSE(requests[0].initiator.has_value());
// Auxiliary navigations have a first-party that matches the URL to which they // Auxiliary navigations have a first-party that matches the URL to which they
// navigate, and an initiator that matches the document that triggered them. // navigate, and an initiator that matches the document that triggered them.
EXPECT_EQ(auxiliary_url, delegate_->data()[1]->url); EXPECT_EQ(auxiliary_url, requests[1].url);
EXPECT_EQ(auxiliary_url, delegate_->data()[1]->first_party); EXPECT_EQ(auxiliary_url, requests[1].first_party);
EXPECT_EQ(top_origin, delegate_->data()[1]->initiator); EXPECT_EQ(top_origin, requests[1].initiator);
} }
IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest, IN_PROC_BROWSER_TEST_F(RequestDataBrowserTest, FailedNavigation) {
FailedNavigation) {
// Navigating to this URL will fail, as we haven't taught the host resolver // Navigating to this URL will fail, as we haven't taught the host resolver
// about 'a.com'. // about 'a.com'.
GURL top_url(embedded_test_server()->GetURL("a.com", "/simple_page.html")); GURL top_url(embedded_test_server()->GetURL("a.com", "/simple_page.html"));
...@@ -1131,18 +1165,18 @@ IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest, ...@@ -1131,18 +1165,18 @@ IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest,
NavigateToURLBlockUntilNavigationsComplete(shell(), top_url, 1); NavigateToURLBlockUntilNavigationsComplete(shell(), top_url, 1);
EXPECT_EQ(1u, delegate_->data().size()); auto requests = data();
EXPECT_EQ(1u, requests.size());
// User-initiated top-level navigations have a first-party that matches the // User-initiated top-level navigations have a first-party that matches the
// URL to which they navigate, even if they fail to load. The navigation was // URL to which they navigate, even if they fail to load. The navigation was
// initiated outside of a document, so there is no initiator. // initiated outside of a document, so there is no initiator.
EXPECT_EQ(top_url, delegate_->data()[0]->url); EXPECT_EQ(top_url, requests[0].url);
EXPECT_EQ(top_url, delegate_->data()[0]->first_party); EXPECT_EQ(top_url, requests[0].first_party);
EXPECT_FALSE(delegate_->data()[0]->initiator.has_value()); EXPECT_FALSE(requests[0].initiator.has_value());
} }
IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest, IN_PROC_BROWSER_TEST_F(RequestDataBrowserTest, CrossOriginNested) {
CrossOriginNested) {
GURL top_url(embedded_test_server()->GetURL( GURL top_url(embedded_test_server()->GetURL(
"a.com", "/cross_site_iframe_factory.html?a(b)")); "a.com", "/cross_site_iframe_factory.html?a(b)"));
GURL top_js_url( GURL top_js_url(
...@@ -1156,29 +1190,30 @@ IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest, ...@@ -1156,29 +1190,30 @@ IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest,
NavigateToURLBlockUntilNavigationsComplete(shell(), top_url, 1); NavigateToURLBlockUntilNavigationsComplete(shell(), top_url, 1);
EXPECT_EQ(4u, delegate_->data().size()); auto requests = data();
EXPECT_EQ(4u, requests.size());
// User-initiated top-level navigations have a |first-party|. The navigation // User-initiated top-level navigations have a |first-party|. The navigation
// was initiated outside of a document, so there are no initiator. // was initiated outside of a document, so there are no initiator.
EXPECT_EQ(top_url, delegate_->data()[0]->url); EXPECT_EQ(top_url, requests[0].url);
EXPECT_EQ(top_url, delegate_->data()[0]->first_party); EXPECT_EQ(top_url, requests[0].first_party);
EXPECT_FALSE(delegate_->data()[0]->initiator.has_value()); EXPECT_FALSE(requests[0].initiator.has_value());
EXPECT_EQ(top_js_url, delegate_->data()[1]->url); EXPECT_EQ(top_js_url, requests[1].url);
EXPECT_EQ(top_url, delegate_->data()[1]->first_party); EXPECT_EQ(top_url, requests[1].first_party);
EXPECT_EQ(top_origin, delegate_->data()[1]->initiator); EXPECT_EQ(top_origin, requests[1].initiator);
// Cross-origin frames have a first-party and initiator that matches the URL // Cross-origin frames have a first-party and initiator that matches the URL
// in which they're embedded. // in which they're embedded.
EXPECT_EQ(nested_url, delegate_->data()[2]->url); EXPECT_EQ(nested_url, requests[2].url);
EXPECT_EQ(top_url, delegate_->data()[2]->first_party); EXPECT_EQ(top_url, requests[2].first_party);
EXPECT_EQ(top_origin, delegate_->data()[2]->initiator); EXPECT_EQ(top_origin, requests[2].initiator);
// Cross-origin subresource requests have a unique first-party, and an // Cross-origin subresource requests have a unique first-party, and an
// initiator that matches the document in which they're embedded. // initiator that matches the document in which they're embedded.
EXPECT_EQ(nested_js_url, delegate_->data()[3]->url); EXPECT_EQ(nested_js_url, requests[3].url);
EXPECT_EQ(kURLWithUniqueOrigin, delegate_->data()[3]->first_party); EXPECT_EQ(kURLWithUniqueOrigin, requests[3].first_party);
EXPECT_EQ(nested_origin, delegate_->data()[3]->initiator); EXPECT_EQ(nested_origin, requests[3].initiator);
} }
// Regression test for https://crbug.com/648608. An attacker could trivially // Regression test for https://crbug.com/648608. An attacker could trivially
......
...@@ -328,3 +328,5 @@ ...@@ -328,3 +328,5 @@
# https://crbug.com/803871 # https://crbug.com/803871
-CertificateTransparencyBrowserTest.ProfileRequest -CertificateTransparencyBrowserTest.ProfileRequest
-CertificateTransparencyBrowserTest.SystemRequest -CertificateTransparencyBrowserTest.SystemRequest
# NOTE: before adding new exclusions, please reach out to network-service-dev@.
...@@ -41,15 +41,6 @@ ...@@ -41,15 +41,6 @@
-PowerMonitorTest.TestRendererProcess -PowerMonitorTest.TestRendererProcess
-PowerMonitorTest.TestUtilityProcess -PowerMonitorTest.TestUtilityProcess
-RenderViewBrowserTest.ConfirmCacheInformationPlumbed -RenderViewBrowserTest.ConfirmCacheInformationPlumbed
-RequestDataResourceDispatcherHostBrowserTest.Basic
-RequestDataResourceDispatcherHostBrowserTest.BasicCrossSite
-RequestDataResourceDispatcherHostBrowserTest.CrossOriginAuxiliary
-RequestDataResourceDispatcherHostBrowserTest.CrossOriginNested
-RequestDataResourceDispatcherHostBrowserTest.FailedNavigation
-RequestDataResourceDispatcherHostBrowserTest.LinkRelPrefetch
-RequestDataResourceDispatcherHostBrowserTest.LinkRelPrefetchReferrerPolicy
-RequestDataResourceDispatcherHostBrowserTest.SameOriginAuxiliary
-RequestDataResourceDispatcherHostBrowserTest.SameOriginNested
-WebContentsImplBrowserTest.DownloadImage_Deny_FileImage -WebContentsImplBrowserTest.DownloadImage_Deny_FileImage
# services/network/url_loader.cc should handle failure in # services/network/url_loader.cc should handle failure in
...@@ -100,3 +91,5 @@ ...@@ -100,3 +91,5 @@
# https://crbug.com/808759 # https://crbug.com/808759
-DownloadContentTest.DownloadAttributeBlobURL -DownloadContentTest.DownloadAttributeBlobURL
# NOTE: before adding new exclusions, please reach out to network-service-dev@.
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment