Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1213 bool is_opener_defined = false; | 1213 bool is_opener_defined = false; |
| 1214 EXPECT_TRUE(ExecuteScriptAndExtractBool( | 1214 EXPECT_TRUE(ExecuteScriptAndExtractBool( |
| 1215 popup, "window.domAutomationController.send(!!window.opener)", | 1215 popup, "window.domAutomationController.send(!!window.opener)", |
| 1216 &is_opener_defined)); | 1216 &is_opener_defined)); |
| 1217 EXPECT_TRUE(is_opener_defined); | 1217 EXPECT_TRUE(is_opener_defined); |
| 1218 | 1218 |
| 1219 // Verify that postMessage to window.opener works. | 1219 // Verify that postMessage to window.opener works. |
| 1220 VerifyPostMessageToOpener(popup->GetMainFrame(), extension_frame); | 1220 VerifyPostMessageToOpener(popup->GetMainFrame(), extension_frame); |
| 1221 } | 1221 } |
| 1222 | 1222 |
| 1223 // Test that when a web site has an extension iframe, navigating that iframe to | |
| 1224 // a different web site without --site-per-process will place it in the parent | |
| 1225 // frame's process. See https://crbug.com/711006. | |
| 1226 IN_PROC_BROWSER_TEST_F(ProcessManagerBrowserTest, | |
|
Charlie Reis
2017/04/14 16:57:05
Yep, makes sense to put this here for now, since I
alexmos
2017/04/17 17:36:02
Acknowledged, and in fact I've already got that te
| |
| 1227 ExtensionFrameNavigatesToParentSiteInstance) { | |
| 1228 // This test matters only *without* --site-per-process. | |
| 1229 if (content::AreAllSitesIsolatedForTesting()) | |
| 1230 return; | |
| 1231 | |
| 1232 host_resolver()->AddRule("*", "127.0.0.1"); | |
| 1233 | |
| 1234 // Create a simple extension without a background page. | |
| 1235 const Extension* extension = CreateExtension("Extension", false); | |
| 1236 embedded_test_server()->ServeFilesFromDirectory(extension->path()); | |
| 1237 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 1238 | |
| 1239 // Navigate main tab to a web page with a blank iframe. There should be no | |
| 1240 // extension frames yet. | |
| 1241 NavigateToURL(embedded_test_server()->GetURL("a.com", "/blank_iframe.html")); | |
| 1242 ProcessManager* pm = ProcessManager::Get(profile()); | |
| 1243 EXPECT_EQ(0u, pm->GetAllFrames().size()); | |
| 1244 EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(extension->id()).size()); | |
| 1245 | |
| 1246 content::WebContents* tab = | |
| 1247 browser()->tab_strip_model()->GetActiveWebContents(); | |
| 1248 | |
| 1249 // Navigate subframe to an extension URL. This should go into a new | |
| 1250 // extension process. | |
| 1251 const GURL extension_url(extension->url().Resolve("empty.html")); | |
| 1252 EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame0", extension_url)); | |
| 1253 EXPECT_EQ(1u, pm->GetRenderFrameHostsForExtension(extension->id()).size()); | |
| 1254 EXPECT_EQ(1u, pm->GetAllFrames().size()); | |
| 1255 | |
| 1256 content::RenderFrameHost* main_frame = tab->GetMainFrame(); | |
| 1257 { | |
| 1258 content::RenderFrameHost* subframe = ChildFrameAt(main_frame, 0); | |
| 1259 EXPECT_NE(subframe->GetProcess(), main_frame->GetProcess()); | |
| 1260 EXPECT_NE(subframe->GetSiteInstance(), main_frame->GetSiteInstance()); | |
| 1261 } | |
| 1262 | |
| 1263 // Navigate subframe to b.com. This should be brought back to the parent | |
| 1264 // frame's (a.com) process. | |
| 1265 GURL b_url(embedded_test_server()->GetURL("b.com", "/empty.html")); | |
| 1266 EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame0", b_url)); | |
| 1267 { | |
| 1268 content::RenderFrameHost* subframe = ChildFrameAt(main_frame, 0); | |
| 1269 EXPECT_EQ(subframe->GetProcess(), main_frame->GetProcess()); | |
| 1270 EXPECT_EQ(subframe->GetSiteInstance(), main_frame->GetSiteInstance()); | |
| 1271 } | |
| 1272 } | |
| 1273 | |
| 1223 } // namespace extensions | 1274 } // namespace extensions |
| OLD | NEW |