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

Side by Side Diff: content/browser/site_per_process_browsertest.cc

Issue 2874163004: Add support in the network service for different contexts. (Closed)
Patch Set: review comment and clang fixes 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
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/browser/site_per_process_browsertest.h" 5 #include "content/browser/site_per_process_browsertest.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 21 matching lines...) Expand all
32 #include "content/browser/frame_host/cross_process_frame_connector.h" 32 #include "content/browser/frame_host/cross_process_frame_connector.h"
33 #include "content/browser/frame_host/frame_navigation_entry.h" 33 #include "content/browser/frame_host/frame_navigation_entry.h"
34 #include "content/browser/frame_host/frame_tree.h" 34 #include "content/browser/frame_host/frame_tree.h"
35 #include "content/browser/frame_host/interstitial_page_impl.h" 35 #include "content/browser/frame_host/interstitial_page_impl.h"
36 #include "content/browser/frame_host/navigation_controller_impl.h" 36 #include "content/browser/frame_host/navigation_controller_impl.h"
37 #include "content/browser/frame_host/navigation_entry_impl.h" 37 #include "content/browser/frame_host/navigation_entry_impl.h"
38 #include "content/browser/frame_host/navigator.h" 38 #include "content/browser/frame_host/navigator.h"
39 #include "content/browser/frame_host/render_frame_proxy_host.h" 39 #include "content/browser/frame_host/render_frame_proxy_host.h"
40 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" 40 #include "content/browser/frame_host/render_widget_host_view_child_frame.h"
41 #include "content/browser/gpu/compositor_util.h" 41 #include "content/browser/gpu/compositor_util.h"
42 #include "content/browser/loader/navigation_url_loader_network_service.h"
43 #include "content/browser/loader/resource_dispatcher_host_impl.h" 42 #include "content/browser/loader/resource_dispatcher_host_impl.h"
44 #include "content/browser/renderer_host/input/input_router_impl.h" 43 #include "content/browser/renderer_host/input/input_router_impl.h"
45 #include "content/browser/renderer_host/input/synthetic_tap_gesture.h" 44 #include "content/browser/renderer_host/input/synthetic_tap_gesture.h"
46 #include "content/browser/renderer_host/render_view_host_impl.h" 45 #include "content/browser/renderer_host/render_view_host_impl.h"
47 #include "content/browser/renderer_host/render_widget_host_input_event_router.h" 46 #include "content/browser/renderer_host/render_widget_host_input_event_router.h"
48 #include "content/browser/renderer_host/render_widget_host_view_aura.h" 47 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
48 #include "content/browser/storage_partition_impl.h"
49 #include "content/browser/url_loader_factory_getter.h"
49 #include "content/browser/web_contents/web_contents_impl.h" 50 #include "content/browser/web_contents/web_contents_impl.h"
50 #include "content/common/child_process_messages.h" 51 #include "content/common/child_process_messages.h"
51 #include "content/common/frame_messages.h" 52 #include "content/common/frame_messages.h"
52 #include "content/common/input/synthetic_tap_gesture_params.h" 53 #include "content/common/input/synthetic_tap_gesture_params.h"
53 #include "content/common/input_messages.h" 54 #include "content/common/input_messages.h"
54 #include "content/common/renderer.mojom.h" 55 #include "content/common/renderer.mojom.h"
55 #include "content/common/view_messages.h" 56 #include "content/common/view_messages.h"
57 #include "content/public/browser/browser_context.h"
56 #include "content/public/browser/browser_thread.h" 58 #include "content/public/browser/browser_thread.h"
57 #include "content/public/browser/interstitial_page_delegate.h" 59 #include "content/public/browser/interstitial_page_delegate.h"
58 #include "content/public/browser/navigation_handle.h" 60 #include "content/public/browser/navigation_handle.h"
59 #include "content/public/browser/notification_observer.h" 61 #include "content/public/browser/notification_observer.h"
60 #include "content/public/browser/notification_service.h" 62 #include "content/public/browser/notification_service.h"
61 #include "content/public/browser/notification_types.h" 63 #include "content/public/browser/notification_types.h"
62 #include "content/public/browser/resource_dispatcher_host.h" 64 #include "content/public/browser/resource_dispatcher_host.h"
63 #include "content/public/common/browser_side_navigation_policy.h" 65 #include "content/public/common/browser_side_navigation_policy.h"
64 #include "content/public/common/content_switches.h" 66 #include "content/public/common/content_switches.h"
65 #include "content/public/common/url_constants.h" 67 #include "content/public/common/url_constants.h"
(...skipping 2367 matching lines...) Expand 10 before | Expand all | Expand 10 after
2433 GURL url_a = child->current_url(); 2435 GURL url_a = child->current_url();
2434 2436
2435 // Disable host resolution in the test server and try to navigate the subframe 2437 // Disable host resolution in the test server and try to navigate the subframe
2436 // cross-site, which will lead to a committed net error. 2438 // cross-site, which will lead to a committed net error.
2437 GURL url_b = embedded_test_server()->GetURL("b.com", "/title3.html"); 2439 GURL url_b = embedded_test_server()->GetURL("b.com", "/title3.html");
2438 bool network_service = base::CommandLine::ForCurrentProcess()->HasSwitch( 2440 bool network_service = base::CommandLine::ForCurrentProcess()->HasSwitch(
2439 switches::kEnableNetworkService); 2441 switches::kEnableNetworkService);
2440 mojom::URLLoaderFactoryPtr failing_factory; 2442 mojom::URLLoaderFactoryPtr failing_factory;
2441 mojo::MakeStrongBinding(base::MakeUnique<FailingLoadFactory>(), 2443 mojo::MakeStrongBinding(base::MakeUnique<FailingLoadFactory>(),
2442 mojo::MakeRequest(&failing_factory)); 2444 mojo::MakeRequest(&failing_factory));
2445 StoragePartitionImpl* storage_partition = nullptr;
2443 if (network_service) { 2446 if (network_service) {
2444 NavigationURLLoaderNetworkService::OverrideURLLoaderFactoryForTesting( 2447 storage_partition = static_cast<StoragePartitionImpl*>(
2448 BrowserContext::GetDefaultStoragePartition(
2449 shell()->web_contents()->GetBrowserContext()));
2450 storage_partition->url_loader_factory_getter()->SetNetworkFactoryForTesting(
2445 std::move(failing_factory)); 2451 std::move(failing_factory));
2446 } else { 2452 } else {
2447 host_resolver()->ClearRules(); 2453 host_resolver()->ClearRules();
2448 } 2454 }
2449 2455
2450 TestNavigationObserver observer(shell()->web_contents()); 2456 TestNavigationObserver observer(shell()->web_contents());
2451 NavigateIframeToURL(shell()->web_contents(), "child-0", url_b); 2457 NavigateIframeToURL(shell()->web_contents(), "child-0", url_b);
2452 EXPECT_FALSE(observer.last_navigation_succeeded()); 2458 EXPECT_FALSE(observer.last_navigation_succeeded());
2453 EXPECT_EQ(url_b, observer.last_navigation_url()); 2459 EXPECT_EQ(url_b, observer.last_navigation_url());
2454 EXPECT_EQ(2, shell()->web_contents()->GetController().GetEntryCount()); 2460 EXPECT_EQ(2, shell()->web_contents()->GetController().GetEntryCount());
(...skipping 18 matching lines...) Expand all
2473 // page). 2479 // page).
2474 if (IsBrowserSideNavigationEnabled()) 2480 if (IsBrowserSideNavigationEnabled())
2475 EXPECT_EQ(GURL(), child->current_frame_host()->last_successful_url()); 2481 EXPECT_EQ(GURL(), child->current_frame_host()->last_successful_url());
2476 else 2482 else
2477 EXPECT_EQ(url_a, child->current_frame_host()->last_successful_url()); 2483 EXPECT_EQ(url_a, child->current_frame_host()->last_successful_url());
2478 EXPECT_EQ(url_b, child->current_url()); 2484 EXPECT_EQ(url_b, child->current_url());
2479 EXPECT_EQ("null", child->current_origin().Serialize()); 2485 EXPECT_EQ("null", child->current_origin().Serialize());
2480 2486
2481 // Try again after re-enabling host resolution. 2487 // Try again after re-enabling host resolution.
2482 if (network_service) { 2488 if (network_service) {
2483 NavigationURLLoaderNetworkService::OverrideURLLoaderFactoryForTesting( 2489 storage_partition->url_loader_factory_getter()->SetNetworkFactoryForTesting(
2484 nullptr); 2490 nullptr);
2485 } else { 2491 } else {
2486 host_resolver()->AddRule("*", "127.0.0.1"); 2492 host_resolver()->AddRule("*", "127.0.0.1");
2487 } 2493 }
2488 2494
2489 NavigateIframeToURL(shell()->web_contents(), "child-0", url_b); 2495 NavigateIframeToURL(shell()->web_contents(), "child-0", url_b);
2490 EXPECT_TRUE(observer.last_navigation_succeeded()); 2496 EXPECT_TRUE(observer.last_navigation_succeeded());
2491 EXPECT_EQ(url_b, observer.last_navigation_url()); 2497 EXPECT_EQ(url_b, observer.last_navigation_url());
2492 2498
2493 // The FrameTreeNode should have updated its URL and origin. 2499 // The FrameTreeNode should have updated its URL and origin.
(...skipping 7584 matching lines...) Expand 10 before | Expand all | Expand 10 after
10078 names.insert(root->children[0]->frame_entry->frame_unique_name()); 10084 names.insert(root->children[0]->frame_entry->frame_unique_name());
10079 } 10085 }
10080 10086
10081 // More than one entry in the set means that the subframe frame navigation 10087 // More than one entry in the set means that the subframe frame navigation
10082 // entries didn't have a consistent unique name. This will break history 10088 // entries didn't have a consistent unique name. This will break history
10083 // navigations =( 10089 // navigations =(
10084 EXPECT_THAT(names, SizeIs(1)) << "Mismatched names for subframe!"; 10090 EXPECT_THAT(names, SizeIs(1)) << "Mismatched names for subframe!";
10085 } 10091 }
10086 10092
10087 } // namespace content 10093 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_process_host_impl.cc ('k') | content/browser/storage_partition_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698