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

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

Issue 2508973006: Kill vestigial transfer requests (Closed)
Patch Set: test from lukasza 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) {
nasko 2016/11/19 00:16:21 Since this test is specifically targeting transfer
Łukasz Anforowicz 2016/11/19 00:24:59 That might be a good idea. csharrison@ - WDYT? W
Charlie Harrison 2016/11/19 03:32:38 Done.
8572 GURL page_url(embedded_test_server()->GetURL(
8573 "main.com", "/frame_tree/page_with_one_frame.html"));
8574 GURL initial_frame_url(embedded_test_server()->GetURL(
8575 "main.com", "/cross-site/baz.com/title1.html"));
8576
8577 {
8578 // Navigation below is needed to make OpenPopup (next statement) work.
8579 EXPECT_TRUE(
8580 NavigateToURL(shell(), embedded_test_server()->GetURL("/title2.html")));
8581
8582 // Create a separate Shell + WebContents - these will be destroyed during
8583 // the test at a very special moment.
8584 Shell* other_shell = OpenPopup(shell()->web_contents(), GURL(), "popup");
8585
8586 // Load the test page, while monitoring navigations of the frame (to catch
8587 // when the frame navigation will initiate a transfer to another renderer).
8588 TestNavigationManager navigation_manager(other_shell->web_contents(),
8589 initial_frame_url);
8590 other_shell->LoadURL(page_url);
8591
8592 // Wait until |navigation_manager| detects a WillProcessResponse associated
8593 // with the frame navigation.
8594 ASSERT_TRUE(navigation_manager.WaitForResponse());
8595
8596 // At this point we have almost (but not quite) trigerred a transfer request
8597 // - the transfer will be initiated when resuming the navigation. Posting a
8598 // task to destroy the frame being navigated means that the destruction
8599 // won't happen now, but will happen right after initiating the transfer AND
8600 // hopefully before the transfer completes (i.e. before we receive
Charlie Reis 2016/11/19 00:03:14 "Hopefully" sounds flaky to me. :) If so, is it
Łukasz Anforowicz 2016/11/19 00:16:38 Maybe "hopefully" is the wrong way here. The way
Łukasz Anforowicz 2016/11/19 00:24:59 I meant s/wrong way/wrong word/
Charlie Harrison 2016/11/19 03:32:38 Updated the comment to be a bit more specific.
8601 // DidStartProvisionalLoad from the new renderer).
8602 base::SequencedTaskRunnerHandle::Get()->PostTask(
8603 FROM_HERE, base::Bind(&WebContents::Close,
8604 base::Unretained(other_shell->web_contents())));
8605
8606 // Resume the navigation. This will 1) initiate the transfer and 2) shortly
8607 // after destroy the |other_shell| via WebContents::Close task posted above.
8608 // Destroying the NavigationHandle at this special moment used to trigger
8609 // https://crbug.com/657195.
8610 navigation_manager.WaitForNavigationFinished();
8611 }
8612
8613 // Start a URLRequest to the same URL. This should succeed. This would have
8614 // hit the 20 seconds delay before https://crbug.com/657195 was fixed.
nasko 2016/11/19 00:16:21 Why not check actually the time it takes? What if
Łukasz Anforowicz 2016/11/19 00:24:59 Hmmmm... good point. OTOH, I am a bit wary of mak
Charlie Harrison 2016/11/19 03:32:39 I agree, I don't want to add timing to this suite.
8615 EXPECT_TRUE(NavigateToURL(shell(), page_url));
8616 EXPECT_EQ(page_url, shell()->web_contents()->GetLastCommittedURL());
8617 }
8618
8565 } // namespace content 8619 } // 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