| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "content/browser/web_contents/web_contents_impl.h" | 9 #include "content/browser/web_contents/web_contents_impl.h" |
| 10 #include "content/common/site_isolation_policy.h" |
| 10 #include "content/public/browser/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
| 11 #include "content/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
| 12 #include "content/public/test/browser_test_utils.h" | 13 #include "content/public/test/browser_test_utils.h" |
| 13 #include "content/public/test/content_browser_test.h" | 14 #include "content/public/test/content_browser_test.h" |
| 14 #include "content/public/test/content_browser_test_utils.h" | 15 #include "content/public/test/content_browser_test_utils.h" |
| 15 #include "content/public/test/test_navigation_observer.h" | 16 #include "content/public/test/test_navigation_observer.h" |
| 16 #include "content/shell/browser/shell.h" | 17 #include "content/shell/browser/shell.h" |
| 17 #include "net/dns/mock_host_resolver.h" | 18 #include "net/dns/mock_host_resolver.h" |
| 18 #include "net/test/embedded_test_server/embedded_test_server.h" | 19 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 19 #include "net/test/url_request/url_request_failed_job.h" | 20 #include "net/test/url_request/url_request_failed_job.h" |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 EXPECT_TRUE(ExecuteScriptAndExtractBool( | 150 EXPECT_TRUE(ExecuteScriptAndExtractBool( |
| 150 shell()->web_contents(), | 151 shell()->web_contents(), |
| 151 "window.domAutomationController.send(clickCrossSiteLink());", | 152 "window.domAutomationController.send(clickCrossSiteLink());", |
| 152 &success)); | 153 &success)); |
| 153 EXPECT_TRUE(success); | 154 EXPECT_TRUE(success); |
| 154 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 155 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 155 EXPECT_EQ(url, observer.last_navigation_url()); | 156 EXPECT_EQ(url, observer.last_navigation_url()); |
| 156 EXPECT_TRUE(observer.last_navigation_succeeded()); | 157 EXPECT_TRUE(observer.last_navigation_succeeded()); |
| 157 } | 158 } |
| 158 | 159 |
| 159 // The RenderFrameHost should not have changed. | 160 // The RenderFrameHost should not have changed unless site-per-process is |
| 160 EXPECT_EQ(initial_rfh, static_cast<WebContentsImpl*>(shell()->web_contents()) | 161 // enabled. |
| 161 ->GetFrameTree()->root()->current_frame_host()); | 162 if (SiteIsolationPolicy::AreCrossProcessFramesPossible()) { |
| 163 EXPECT_NE(initial_rfh, |
| 164 static_cast<WebContentsImpl*>(shell()->web_contents()) |
| 165 ->GetFrameTree() |
| 166 ->root() |
| 167 ->current_frame_host()); |
| 168 } else { |
| 169 EXPECT_EQ(initial_rfh, |
| 170 static_cast<WebContentsImpl*>(shell()->web_contents()) |
| 171 ->GetFrameTree() |
| 172 ->root() |
| 173 ->current_frame_host()); |
| 174 } |
| 162 } | 175 } |
| 163 | 176 |
| 164 // Ensure that browser side navigation handles navigation failures. | 177 // Ensure that browser side navigation handles navigation failures. |
| 165 IN_PROC_BROWSER_TEST_F(BrowserSideNavigationBrowserTest, FailedNavigation) { | 178 IN_PROC_BROWSER_TEST_F(BrowserSideNavigationBrowserTest, FailedNavigation) { |
| 166 // Perform a navigation with no live renderer. | 179 // Perform a navigation with no live renderer. |
| 167 { | 180 { |
| 168 TestNavigationObserver observer(shell()->web_contents()); | 181 TestNavigationObserver observer(shell()->web_contents()); |
| 169 GURL url(embedded_test_server()->GetURL("/title1.html")); | 182 GURL url(embedded_test_server()->GetURL("/title1.html")); |
| 170 NavigateToURL(shell(), url); | 183 NavigateToURL(shell(), url); |
| 171 EXPECT_EQ(url, observer.last_navigation_url()); | 184 EXPECT_EQ(url, observer.last_navigation_url()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 182 base::Bind(&net::URLRequestFailedJob::AddUrlHandler)); | 195 base::Bind(&net::URLRequestFailedJob::AddUrlHandler)); |
| 183 NavigateToURL(shell(), error_url); | 196 NavigateToURL(shell(), error_url); |
| 184 EXPECT_EQ(error_url, observer.last_navigation_url()); | 197 EXPECT_EQ(error_url, observer.last_navigation_url()); |
| 185 NavigationEntry* entry = | 198 NavigationEntry* entry = |
| 186 shell()->web_contents()->GetController().GetLastCommittedEntry(); | 199 shell()->web_contents()->GetController().GetLastCommittedEntry(); |
| 187 EXPECT_EQ(PAGE_TYPE_ERROR, entry->GetPageType()); | 200 EXPECT_EQ(PAGE_TYPE_ERROR, entry->GetPageType()); |
| 188 } | 201 } |
| 189 } | 202 } |
| 190 | 203 |
| 191 } // namespace content | 204 } // namespace content |
| OLD | NEW |