Chromium Code Reviews| Index: content/browser/loader/resource_dispatcher_host_browsertest.cc |
| diff --git a/content/browser/loader/resource_dispatcher_host_browsertest.cc b/content/browser/loader/resource_dispatcher_host_browsertest.cc |
| index 92d0d9ec815ad80afaaed953fb01b1ecdeb0160d..86c1d9fe57d20f328c9d9eceb3b95ab007fe50ff 100644 |
| --- a/content/browser/loader/resource_dispatcher_host_browsertest.cc |
| +++ b/content/browser/loader/resource_dispatcher_host_browsertest.cc |
| @@ -22,6 +22,7 @@ |
| #include "content/public/browser/resource_dispatcher_host_delegate.h" |
| #include "content/public/browser/resource_request_info.h" |
| #include "content/public/browser/web_contents.h" |
| +#include "content/public/common/browser_side_navigation_policy.h" |
| #include "content/public/common/url_constants.h" |
| #include "content/public/test/browser_test_utils.h" |
| #include "content/public/test/content_browser_test.h" |
| @@ -828,10 +829,23 @@ IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest, Basic) { |
| // All resources loaded directly by the top-level document (including the |
| // top-level document itself) should have a |first_party| and |initiator| |
| // that match the URL of the top-level document. |
| - for (auto* request : delegate_->data()) { |
| - SCOPED_TRACE(request->url); |
| - EXPECT_EQ(top_url, request->first_party); |
| - EXPECT_EQ(top_origin, request->initiator); |
| + // PlzNavigate: the document itself should have an empty initiator. |
| + if (IsBrowserSideNavigationEnabled()) { |
|
clamy
2016/11/14 13:42:04
Currently we always set an initiator for requests,
|
| + const RequestDataForDelegate* first_request = delegate_->data()[0]; |
| + EXPECT_EQ(top_url, first_request->first_party); |
| + EXPECT_FALSE(first_request->initiator.has_value()); |
| + for (size_t i = 1; i < delegate_->data().size(); i++) { |
| + const RequestDataForDelegate* request = delegate_->data()[i]; |
| + EXPECT_EQ(top_url, request->first_party); |
| + ASSERT_TRUE(request->initiator.has_value()); |
| + EXPECT_EQ(top_origin, request->initiator); |
| + } |
| + } else { |
| + for (auto* request : delegate_->data()) { |
| + SCOPED_TRACE(request->url); |
| + EXPECT_EQ(top_url, request->first_party); |
| + EXPECT_EQ(top_origin, request->initiator); |
| + } |
| } |
| } |
| @@ -851,10 +865,16 @@ IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest, |
| // The first items loaded are the top-level and nested documents. These should |
| // both have a |first_party| and |initiator| that match the URL of the |
| - // top-level document: |
| + // top-level document. |
| + // PlzNavigate: the top-level initiator is null. |
| EXPECT_EQ(top_url, delegate_->data()[0]->url); |
| EXPECT_EQ(top_url, delegate_->data()[0]->first_party); |
| - EXPECT_EQ(top_origin, delegate_->data()[0]->initiator); |
| + if (IsBrowserSideNavigationEnabled()) { |
| + EXPECT_FALSE(delegate_->data()[0]->initiator.has_value()); |
| + } else { |
| + ASSERT_TRUE(delegate_->data()[0]->initiator.has_value()); |
| + EXPECT_EQ(top_origin, delegate_->data()[0]->initiator); |
| + } |
| EXPECT_EQ(nested_url, delegate_->data()[1]->url); |
| EXPECT_EQ(top_url, delegate_->data()[1]->first_party); |
| @@ -883,9 +903,15 @@ IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest, |
| // User-initiated top-level navigations have a first-party and initiator that |
| // matches the URL to which they navigate. |
| + // PlzNavigate: the top-level initiator is null. |
| EXPECT_EQ(top_url, delegate_->data()[0]->url); |
| EXPECT_EQ(top_url, delegate_->data()[0]->first_party); |
| - EXPECT_EQ(top_origin, delegate_->data()[0]->initiator); |
| + if (IsBrowserSideNavigationEnabled()) { |
| + EXPECT_FALSE(delegate_->data()[0]->initiator.has_value()); |
| + } else { |
| + ASSERT_TRUE(delegate_->data()[0]->initiator.has_value()); |
| + EXPECT_EQ(top_origin, delegate_->data()[0]->initiator); |
| + } |
| // Subresource requests have a first-party and initiator that matches the |
| // document in which they're embedded. |
| @@ -922,9 +948,15 @@ IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest, |
| // User-initiated top-level navigations have a first-party and initiator that |
| // matches the URL to which they navigate, even if they fail to load. |
| + // PlzNavigate: the top-level initiator is null. |
| EXPECT_EQ(top_url, delegate_->data()[0]->url); |
| EXPECT_EQ(top_url, delegate_->data()[0]->first_party); |
| - EXPECT_EQ(top_origin, delegate_->data()[0]->initiator); |
| + if (IsBrowserSideNavigationEnabled()) { |
| + EXPECT_FALSE(delegate_->data()[0]->initiator.has_value()); |
| + } else { |
| + ASSERT_TRUE(delegate_->data()[0]->initiator.has_value()); |
| + EXPECT_EQ(top_origin, delegate_->data()[0]->initiator); |
| + } |
| // Auxiliary navigations have a first-party that matches the URL to which they |
| // navigate, and an initiator that matches the document that triggered them. |
| @@ -963,9 +995,15 @@ IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest, |
| // User-initiated top-level navigations have a first-party and initiator that |
| // matches the URL to which they navigate, even if they fail to load. |
| + // PlzNavigate: the top-level initiator is null. |
| EXPECT_EQ(top_url, delegate_->data()[0]->url); |
| EXPECT_EQ(top_url, delegate_->data()[0]->first_party); |
| - EXPECT_EQ(top_origin, delegate_->data()[0]->initiator); |
| + if (IsBrowserSideNavigationEnabled()) { |
| + EXPECT_FALSE(delegate_->data()[0]->initiator.has_value()); |
| + } else { |
| + ASSERT_TRUE(delegate_->data()[0]->initiator.has_value()); |
| + EXPECT_EQ(top_origin, delegate_->data()[0]->initiator); |
| + } |
| // Auxiliary navigations have a first-party that matches the URL to which they |
| // navigate, and an initiator that matches the document that triggered them. |
| @@ -987,9 +1025,15 @@ IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest, |
| // User-initiated top-level navigations have a first-party and initiator that |
| // matches the URL to which they navigate, even if they fail to load. |
| + // PlzNavigate: the top-level initiator is null. |
| EXPECT_EQ(top_url, delegate_->data()[0]->url); |
| EXPECT_EQ(top_url, delegate_->data()[0]->first_party); |
| - EXPECT_EQ(top_origin, delegate_->data()[0]->initiator); |
| + if (IsBrowserSideNavigationEnabled()) { |
| + EXPECT_FALSE(delegate_->data()[0]->initiator.has_value()); |
| + } else { |
| + ASSERT_TRUE(delegate_->data()[0]->initiator.has_value()); |
| + EXPECT_EQ(top_origin, delegate_->data()[0]->initiator); |
| + } |
| } |
| IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest, |
| @@ -1012,9 +1056,15 @@ IN_PROC_BROWSER_TEST_F(RequestDataResourceDispatcherHostBrowserTest, |
| // User-initiated top-level navigations have a first-party and initiator that |
| // matches the URL to which they navigate. |
| + // PlzNavigate: the top-level initiator is null. |
| EXPECT_EQ(top_url, delegate_->data()[0]->url); |
| EXPECT_EQ(top_url, delegate_->data()[0]->first_party); |
| - EXPECT_EQ(top_origin, delegate_->data()[0]->initiator); |
| + if (IsBrowserSideNavigationEnabled()) { |
| + EXPECT_FALSE(delegate_->data()[0]->initiator.has_value()); |
| + } else { |
| + ASSERT_TRUE(delegate_->data()[0]->initiator.has_value()); |
| + EXPECT_EQ(top_origin, delegate_->data()[0]->initiator); |
| + } |
| EXPECT_EQ(top_js_url, delegate_->data()[1]->url); |
| EXPECT_EQ(top_url, delegate_->data()[1]->first_party); |