OLD | NEW |
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 7902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7913 // it's become pending deletion. | 7913 // it's become pending deletion. |
7914 child_rfh->OnDispatchLoad(); | 7914 child_rfh->OnDispatchLoad(); |
7915 | 7915 |
7916 // In the bug, OnDispatchLoad killed the b.com renderer. Ensure that this is | 7916 // In the bug, OnDispatchLoad killed the b.com renderer. Ensure that this is |
7917 // not the case. Note that the process kill doesn't happen immediately, so | 7917 // not the case. Note that the process kill doesn't happen immediately, so |
7918 // IsRenderFrameLive() can't be checked here (yet). Instead, check that | 7918 // IsRenderFrameLive() can't be checked here (yet). Instead, check that |
7919 // JavaScript can still execute in b.com using the popup. | 7919 // JavaScript can still execute in b.com using the popup. |
7920 EXPECT_TRUE(ExecuteScript(popup_shell->web_contents(), "true")); | 7920 EXPECT_TRUE(ExecuteScript(popup_shell->web_contents(), "true")); |
7921 } | 7921 } |
7922 | 7922 |
| 7923 // Tests that trying to navigate in the unload handler doesn't crash the |
| 7924 // browser. |
| 7925 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, NavigateInUnloadHandler) { |
| 7926 GURL main_url(embedded_test_server()->GetURL( |
| 7927 "a.com", "/cross_site_iframe_factory.html?a(b(b))")); |
| 7928 NavigateToURL(shell(), main_url); |
| 7929 |
| 7930 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| 7931 ->GetFrameTree() |
| 7932 ->root(); |
| 7933 |
| 7934 EXPECT_EQ( |
| 7935 " Site A ------------ proxies for B\n" |
| 7936 " +--Site B ------- proxies for A\n" |
| 7937 " +--Site B -- proxies for A\n" |
| 7938 "Where A = http://a.com/\n" |
| 7939 " B = http://b.com/", |
| 7940 DepictFrameTree(root)); |
| 7941 |
| 7942 int child_count = 0; |
| 7943 EXPECT_TRUE(ExecuteScriptAndExtractInt( |
| 7944 root->child_at(0)->current_frame_host(), |
| 7945 "window.domAutomationController.send(frames.length);", &child_count)); |
| 7946 EXPECT_EQ(1, child_count); |
| 7947 |
| 7948 // Add an unload handler to B's subframe. |
| 7949 EXPECT_TRUE( |
| 7950 ExecuteScript(root->child_at(0)->child_at(0)->current_frame_host(), |
| 7951 "window.onunload=function(e){\n" |
| 7952 " window.location = '#navigate';\n" |
| 7953 "};\n")); |
| 7954 |
| 7955 // Navigate B's subframe to a cross-site C. |
| 7956 std::string script = |
| 7957 std::string("window.document.getElementById('child-0').src = \"") + |
| 7958 embedded_test_server() |
| 7959 ->GetURL("c.com", "/cross_site_iframe_factory.html") |
| 7960 .spec() + |
| 7961 "\""; |
| 7962 EXPECT_TRUE( |
| 7963 ExecuteScript(root->child_at(0)->current_frame_host(), script.c_str())); |
| 7964 |
| 7965 // Wait until B's subframe RenderFrameHost is destroyed. |
| 7966 RenderFrameDeletedObserver deleted_observer( |
| 7967 root->child_at(0)->child_at(0)->current_frame_host()); |
| 7968 deleted_observer.WaitUntilDeleted(); |
| 7969 |
| 7970 // Check that C's subframe is alive and the navigation in the unload handler |
| 7971 // was ignored. |
| 7972 EXPECT_TRUE(ExecuteScriptAndExtractInt( |
| 7973 root->child_at(0)->child_at(0)->current_frame_host(), |
| 7974 "window.domAutomationController.send(frames.length);", &child_count)); |
| 7975 EXPECT_EQ(0, child_count); |
| 7976 |
| 7977 EXPECT_EQ( |
| 7978 " Site A ------------ proxies for B C\n" |
| 7979 " +--Site B ------- proxies for A C\n" |
| 7980 " +--Site C -- proxies for A B\n" |
| 7981 "Where A = http://a.com/\n" |
| 7982 " B = http://b.com/\n" |
| 7983 " C = http://c.com/", |
| 7984 DepictFrameTree(root)); |
| 7985 } |
| 7986 |
7923 } // namespace content | 7987 } // namespace content |
OLD | NEW |