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

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

Issue 2508973006: Kill vestigial transfer requests (Closed)
Patch Set: comments Created 4 years, 1 month 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 | « content/browser/frame_host/render_frame_host_manager.cc ('k') | 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 (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>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/location.h" 14 #include "base/location.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/path_service.h" 16 #include "base/path_service.h"
17 #include "base/sequenced_task_runner.h"
17 #include "base/single_thread_task_runner.h" 18 #include "base/single_thread_task_runner.h"
18 #include "base/strings/pattern.h" 19 #include "base/strings/pattern.h"
19 #include "base/strings/stringprintf.h" 20 #include "base/strings/stringprintf.h"
20 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
21 #include "base/test/test_timeouts.h" 22 #include "base/test/test_timeouts.h"
23 #include "base/threading/sequenced_task_runner_handle.h"
22 #include "base/threading/thread_task_runner_handle.h" 24 #include "base/threading/thread_task_runner_handle.h"
23 #include "build/build_config.h" 25 #include "build/build_config.h"
24 #include "content/browser/frame_host/cross_process_frame_connector.h" 26 #include "content/browser/frame_host/cross_process_frame_connector.h"
25 #include "content/browser/frame_host/frame_tree.h" 27 #include "content/browser/frame_host/frame_tree.h"
26 #include "content/browser/frame_host/interstitial_page_impl.h" 28 #include "content/browser/frame_host/interstitial_page_impl.h"
27 #include "content/browser/frame_host/navigator.h" 29 #include "content/browser/frame_host/navigator.h"
28 #include "content/browser/frame_host/render_frame_proxy_host.h" 30 #include "content/browser/frame_host/render_frame_proxy_host.h"
29 #include "content/browser/frame_host/render_widget_host_view_child_frame.h" 31 #include "content/browser/frame_host/render_widget_host_view_child_frame.h"
30 #include "content/browser/gpu/compositor_util.h" 32 #include "content/browser/gpu/compositor_util.h"
31 #include "content/browser/loader/resource_dispatcher_host_impl.h" 33 #include "content/browser/loader/resource_dispatcher_host_impl.h"
(...skipping 15 matching lines...) Expand all
47 #include "content/public/browser/notification_types.h" 49 #include "content/public/browser/notification_types.h"
48 #include "content/public/browser/resource_dispatcher_host.h" 50 #include "content/public/browser/resource_dispatcher_host.h"
49 #include "content/public/common/browser_side_navigation_policy.h" 51 #include "content/public/common/browser_side_navigation_policy.h"
50 #include "content/public/common/content_switches.h" 52 #include "content/public/common/content_switches.h"
51 #include "content/public/common/url_constants.h" 53 #include "content/public/common/url_constants.h"
52 #include "content/public/test/browser_test_utils.h" 54 #include "content/public/test/browser_test_utils.h"
53 #include "content/public/test/content_browser_test_utils.h" 55 #include "content/public/test/content_browser_test_utils.h"
54 #include "content/public/test/test_frame_navigation_observer.h" 56 #include "content/public/test/test_frame_navigation_observer.h"
55 #include "content/public/test/test_navigation_observer.h" 57 #include "content/public/test/test_navigation_observer.h"
56 #include "content/public/test/test_utils.h" 58 #include "content/public/test/test_utils.h"
59 #include "content/shell/browser/shell.h"
57 #include "content/test/content_browser_test_utils_internal.h" 60 #include "content/test/content_browser_test_utils_internal.h"
58 #include "ipc/ipc.mojom.h" 61 #include "ipc/ipc.mojom.h"
59 #include "ipc/ipc_security_test_util.h" 62 #include "ipc/ipc_security_test_util.h"
60 #include "net/dns/mock_host_resolver.h" 63 #include "net/dns/mock_host_resolver.h"
61 #include "net/test/embedded_test_server/embedded_test_server.h" 64 #include "net/test/embedded_test_server/embedded_test_server.h"
62 #include "testing/gtest/include/gtest/gtest.h" 65 #include "testing/gtest/include/gtest/gtest.h"
63 #include "third_party/WebKit/public/platform/WebInputEvent.h" 66 #include "third_party/WebKit/public/platform/WebInputEvent.h"
64 #include "third_party/WebKit/public/platform/WebInsecureRequestPolicy.h" 67 #include "third_party/WebKit/public/platform/WebInsecureRequestPolicy.h"
65 #include "third_party/WebKit/public/web/WebSandboxFlags.h" 68 #include "third_party/WebKit/public/web/WebSandboxFlags.h"
66 #include "ui/display/display_switches.h" 69 #include "ui/display/display_switches.h"
(...skipping 8488 matching lines...) Expand 10 before | Expand all | Expand 10 after
8555 // |popup2|. This is allowed since the main tab is |popup2|'s opener. 8558 // |popup2|. This is allowed since the main tab is |popup2|'s opener.
8556 EXPECT_TRUE(NavigateToURL(shell(), b_url)); 8559 EXPECT_TRUE(NavigateToURL(shell(), b_url));
8557 8560
8558 base::string16 expected_title(base::UTF8ToUTF16("foo")); 8561 base::string16 expected_title(base::UTF8ToUTF16("foo"));
8559 TitleWatcher title_watcher(popup2->web_contents(), expected_title); 8562 TitleWatcher title_watcher(popup2->web_contents(), expected_title);
8560 EXPECT_TRUE(ExecuteScript( 8563 EXPECT_TRUE(ExecuteScript(
8561 shell(), "window.open('','popup2').postMessage('foo', '*');")); 8564 shell(), "window.open('','popup2').postMessage('foo', '*');"));
8562 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle()); 8565 EXPECT_EQ(expected_title, title_watcher.WaitAndGetTitle());
8563 } 8566 }
8564 8567
8568 // Checks that everything is cleaned up even when the frame tree is destroyed
8569 // during a transfer. See also https://crbug.com/657195.
8570 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
8571 FrameTreeDestroyedInMiddleOfTransfer) {
8572 // Transfer navigations don't occur with PlzNavigate.
8573 if (IsBrowserSideNavigationEnabled())
8574 return;
8575 GURL page_url(embedded_test_server()->GetURL(
8576 "main.com", "/frame_tree/page_with_one_frame.html"));
8577 GURL initial_frame_url(embedded_test_server()->GetURL(
8578 "main.com", "/cross-site/baz.com/title1.html"));
8579
8580 {
8581 // Navigation below is needed to make OpenPopup (next statement) work.
8582 EXPECT_TRUE(
8583 NavigateToURL(shell(), embedded_test_server()->GetURL("/title2.html")));
8584
8585 // Create a separate Shell + WebContents - these will be destroyed during
8586 // the test at a very special moment.
8587 Shell* other_shell = OpenPopup(shell()->web_contents(), GURL(), "popup");
8588
8589 // Load the test page, while monitoring navigations of the frame (to catch
8590 // when the frame navigation will initiate a transfer to another renderer).
8591 TestNavigationManager navigation_manager(other_shell->web_contents(),
8592 initial_frame_url);
8593 other_shell->LoadURL(page_url);
8594
8595 // Wait until |navigation_manager| detects a WillProcessResponse associated
8596 // with the frame navigation.
8597 ASSERT_TRUE(navigation_manager.WaitForResponse());
8598
8599 // At this point we have almost (but not quite) triggered a transfer
8600 // request. The transfer will be initiated when resuming the navigation.
8601 // Posting a task to destroy the frame being navigated means that the
8602 // destruction won't happen now, but will happen right after initiating the
8603 // transfer AND before the transfer completes. i.e. This task will be
8604 // executed on the message queue before the task to process the
8605 // DidStartProvisionalLoad IPC from the renderer.
8606 base::SequencedTaskRunnerHandle::Get()->PostTask(
8607 FROM_HERE, base::Bind(&WebContents::Close,
8608 base::Unretained(other_shell->web_contents())));
8609
8610 // Resume the navigation. This will 1) initiate the transfer and 2) shortly
8611 // after destroy the |other_shell| via WebContents::Close task posted above.
8612 // Destroying the NavigationHandle at this special moment used to trigger
8613 // https://crbug.com/657195.
8614 navigation_manager.WaitForNavigationFinished();
8615 }
8616
8617 // Start a URLRequest to the same URL. This should succeed. This would have
8618 // hit the 20 seconds delay before https://crbug.com/657195 was fixed.
8619 EXPECT_TRUE(NavigateToURL(shell(), page_url));
8620 EXPECT_EQ(page_url, shell()->web_contents()->GetLastCommittedURL());
8621
8622 // Note: even if the test fails and for some reason, the test has not timed
8623 // out by this point, the test teardown code will still hit a DCHECK when it
8624 // calls AssertNoURLRequests() in the shell's URLRequestContext destructor.
8625 }
8626
8565 } // namespace content 8627 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698