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

Side by Side Diff: content/browser/frame_host/navigation_handle_impl_browsertest.cc

Issue 2898763004: PlzNavigateNavigationHandleImplBrowserTest.BlockedRequestAfterWebUI (Closed)
Patch Set: web_contents Created 3 years, 7 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "base/memory/weak_ptr.h" 5 #include "base/memory/weak_ptr.h"
6 #include "content/browser/frame_host/navigation_handle_impl.h" 6 #include "content/browser/frame_host/navigation_handle_impl.h"
7 #include "content/browser/web_contents/web_contents_impl.h" 7 #include "content/browser/web_contents/web_contents_impl.h"
8 #include "content/public/browser/web_contents.h" 8 #include "content/public/browser/web_contents.h"
9 #include "content/public/browser/web_contents_observer.h" 9 #include "content/public/browser/web_contents_observer.h"
10 #include "content/public/common/bindings_policy.h"
10 #include "content/public/common/browser_side_navigation_policy.h" 11 #include "content/public/common/browser_side_navigation_policy.h"
11 #include "content/public/common/content_switches.h" 12 #include "content/public/common/content_switches.h"
12 #include "content/public/common/request_context_type.h" 13 #include "content/public/common/request_context_type.h"
13 #include "content/public/test/browser_test_utils.h" 14 #include "content/public/test/browser_test_utils.h"
14 #include "content/public/test/content_browser_test.h" 15 #include "content/public/test/content_browser_test.h"
15 #include "content/public/test/content_browser_test_utils.h" 16 #include "content/public/test/content_browser_test_utils.h"
16 #include "content/public/test/test_navigation_observer.h" 17 #include "content/public/test/test_navigation_observer.h"
17 #include "content/public/test/test_utils.h" 18 #include "content/public/test/test_utils.h"
18 #include "content/shell/browser/shell.h" 19 #include "content/shell/browser/shell.h"
19 #include "content/test/content_browser_test_utils_internal.h" 20 #include "content/test/content_browser_test_utils_internal.h"
(...skipping 1249 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 { 1270 {
1270 NavigationHandleObserver observer(shell()->web_contents(), error_url); 1271 NavigationHandleObserver observer(shell()->web_contents(), error_url);
1271 EXPECT_FALSE(NavigateToURL(shell(), error_url)); 1272 EXPECT_FALSE(NavigateToURL(shell(), error_url));
1272 EXPECT_TRUE(observer.has_committed()); 1273 EXPECT_TRUE(observer.has_committed());
1273 EXPECT_TRUE(observer.is_error()); 1274 EXPECT_TRUE(observer.is_error());
1274 EXPECT_NE(site_instance, 1275 EXPECT_NE(site_instance,
1275 shell()->web_contents()->GetMainFrame()->GetSiteInstance()); 1276 shell()->web_contents()->GetMainFrame()->GetSiteInstance());
1276 } 1277 }
1277 } 1278 }
1278 1279
1280 // Tests the case where a browser-initiated navigation to a normal webpage is
1281 // blocked (net::ERR_BLOCKED_BY_CLIENT) while departing from a privileged WebUI
1282 // page (chrome://gpu). It is a security risk for the error page to commit in
1283 // the privileged process.
1284 IN_PROC_BROWSER_TEST_F(PlzNavigateNavigationHandleImplBrowserTest,
1285 BlockedRequestAfterWebUI) {
1286 GURL web_ui_url("chrome://gpu");
1287 WebContents* web_contents = shell()->web_contents();
1288
1289 // Navigate to the initial page.
1290 EXPECT_FALSE(web_contents->GetMainFrame()->GetEnabledBindings() &
1291 BINDINGS_POLICY_WEB_UI);
1292 EXPECT_TRUE(NavigateToURL(shell(), web_ui_url));
1293 EXPECT_TRUE(web_contents->GetMainFrame()->GetEnabledBindings() &
1294 BINDINGS_POLICY_WEB_UI);
1295 scoped_refptr<SiteInstance> web_ui_process = web_contents->GetSiteInstance();
nasko 2017/05/23 04:48:53 nit: web_ui_site_instance?
ncarter (slow) 2017/05/24 17:18:07 The name was intentional, to highlight the importa
1296
1297 // Start a new, non-webUI navigation that will be blocked by a
1298 // NavigationThrottle.
1299 GURL blocked_url("http://blocked-by-throttle.example.cc");
1300 TestNavigationThrottleInstaller installer(
1301 web_contents, NavigationThrottle::BLOCK_REQUEST,
1302 NavigationThrottle::PROCEED, NavigationThrottle::PROCEED);
1303 NavigationHandleObserver commit_observer(web_contents, blocked_url);
1304 EXPECT_FALSE(NavigateToURL(shell(), blocked_url));
1305 NavigationEntry* last_committed =
1306 web_contents->GetController().GetLastCommittedEntry();
1307 EXPECT_TRUE(last_committed);
1308 EXPECT_EQ(blocked_url, last_committed->GetVirtualURL());
1309 EXPECT_EQ(PAGE_TYPE_ERROR, last_committed->GetPageType());
1310 EXPECT_NE(web_ui_process.get(), web_contents->GetSiteInstance());
1311 EXPECT_TRUE(commit_observer.has_committed());
1312 EXPECT_TRUE(commit_observer.is_error());
1313 EXPECT_FALSE(commit_observer.is_renderer_initiated());
1314 }
1315
1279 } // namespace content 1316 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698