| 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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 host_resolver()->AddRule(aliased_host, "127.0.0.1"); | 274 host_resolver()->AddRule(aliased_host, "127.0.0.1"); |
| 275 ASSERT_TRUE(embedded_test_server()->Start()); | 275 ASSERT_TRUE(embedded_test_server()->Start()); |
| 276 GURL url = | 276 GURL url = |
| 277 embedded_test_server()->GetURL("/extensions/test_file_with_body.html"); | 277 embedded_test_server()->GetURL("/extensions/test_file_with_body.html"); |
| 278 GURL::Replacements replace_host; | 278 GURL::Replacements replace_host; |
| 279 replace_host.SetHostStr(aliased_host); | 279 replace_host.SetHostStr(aliased_host); |
| 280 url = url.ReplaceComponents(replace_host); | 280 url = url.ReplaceComponents(replace_host); |
| 281 | 281 |
| 282 // Load a page from the test host in a new tab. | 282 // Load a page from the test host in a new tab. |
| 283 ui_test_utils::NavigateToURLWithDisposition( | 283 ui_test_utils::NavigateToURLWithDisposition( |
| 284 browser(), | 284 browser(), url, WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 285 url, | |
| 286 NEW_FOREGROUND_TAB, | |
| 287 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 285 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 288 | 286 |
| 289 // Sanity check that there's no bleeding between the extension and the tab. | 287 // Sanity check that there's no bleeding between the extension and the tab. |
| 290 content::WebContents* tab_web_contents = | 288 content::WebContents* tab_web_contents = |
| 291 browser()->tab_strip_model()->GetActiveWebContents(); | 289 browser()->tab_strip_model()->GetActiveWebContents(); |
| 292 EXPECT_EQ(url, tab_web_contents->GetVisibleURL()); | 290 EXPECT_EQ(url, tab_web_contents->GetVisibleURL()); |
| 293 EXPECT_FALSE(pm->GetExtensionForWebContents(tab_web_contents)) | 291 EXPECT_FALSE(pm->GetExtensionForWebContents(tab_web_contents)) |
| 294 << "Non-extension content must not have an associated extension"; | 292 << "Non-extension content must not have an associated extension"; |
| 295 ASSERT_EQ(1u, pm->GetRenderFrameHostsForExtension(extension->id()).size()); | 293 ASSERT_EQ(1u, pm->GetRenderFrameHostsForExtension(extension->id()).size()); |
| 296 content::WebContents* extension_web_contents = | 294 content::WebContents* extension_web_contents = |
| (...skipping 24 matching lines...) Expand all Loading... |
| 321 EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(extension->id()).size()); | 319 EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(extension->id()).size()); |
| 322 | 320 |
| 323 const GURL extension_url = extension->url().Resolve("manifest.json"); | 321 const GURL extension_url = extension->url().Resolve("manifest.json"); |
| 324 NavigateToURL(extension_url); | 322 NavigateToURL(extension_url); |
| 325 EXPECT_EQ(1u, pm->GetRenderFrameHostsForExtension(extension->id()).size()); | 323 EXPECT_EQ(1u, pm->GetRenderFrameHostsForExtension(extension->id()).size()); |
| 326 | 324 |
| 327 NavigateToURL(GURL("about:blank")); | 325 NavigateToURL(GURL("about:blank")); |
| 328 EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(extension->id()).size()); | 326 EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(extension->id()).size()); |
| 329 | 327 |
| 330 ui_test_utils::NavigateToURLWithDisposition( | 328 ui_test_utils::NavigateToURLWithDisposition( |
| 331 browser(), extension_url, NEW_FOREGROUND_TAB, | 329 browser(), extension_url, WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 332 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 330 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 333 EXPECT_EQ(1u, pm->GetRenderFrameHostsForExtension(extension->id()).size()); | 331 EXPECT_EQ(1u, pm->GetRenderFrameHostsForExtension(extension->id()).size()); |
| 334 } | 332 } |
| 335 | 333 |
| 336 // Tests whether frames are correctly classified. Non-extension frames should | 334 // Tests whether frames are correctly classified. Non-extension frames should |
| 337 // never appear in the list. Top-level extension frames should always appear. | 335 // never appear in the list. Top-level extension frames should always appear. |
| 338 // Child extension frames should only appear if it is hosted in an extension | 336 // Child extension frames should only appear if it is hosted in an extension |
| 339 // process (i.e. if the top-level frame is an extension page, or if OOP frames | 337 // process (i.e. if the top-level frame is an extension page, or if OOP frames |
| 340 // are enabled for extensions). | 338 // are enabled for extensions). |
| 341 IN_PROC_BROWSER_TEST_F(ProcessManagerBrowserTest, FrameClassification) { | 339 IN_PROC_BROWSER_TEST_F(ProcessManagerBrowserTest, FrameClassification) { |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 EXPECT_EQ(1u, pm->GetRenderFrameHostsForExtension(extension2->id()).size()); | 466 EXPECT_EQ(1u, pm->GetRenderFrameHostsForExtension(extension2->id()).size()); |
| 469 | 467 |
| 470 // Crash tab where the top-level frame is an extension frame. | 468 // Crash tab where the top-level frame is an extension frame. |
| 471 content::CrashTab(tab); | 469 content::CrashTab(tab); |
| 472 EXPECT_EQ(0u, pm->GetAllFrames().size()); | 470 EXPECT_EQ(0u, pm->GetAllFrames().size()); |
| 473 EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(extension1->id()).size()); | 471 EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(extension1->id()).size()); |
| 474 EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(extension2->id()).size()); | 472 EXPECT_EQ(0u, pm->GetRenderFrameHostsForExtension(extension2->id()).size()); |
| 475 | 473 |
| 476 // Now load an extension page and a non-extension page... | 474 // Now load an extension page and a non-extension page... |
| 477 ui_test_utils::NavigateToURLWithDisposition( | 475 ui_test_utils::NavigateToURLWithDisposition( |
| 478 browser(), kExt1EmptyUrl, NEW_BACKGROUND_TAB, | 476 browser(), kExt1EmptyUrl, WindowOpenDisposition::NEW_BACKGROUND_TAB, |
| 479 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 477 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 480 NavigateToURL(embedded_test_server()->GetURL("/two_iframes.html")); | 478 NavigateToURL(embedded_test_server()->GetURL("/two_iframes.html")); |
| 481 EXPECT_EQ(1u, pm->GetAllFrames().size()); | 479 EXPECT_EQ(1u, pm->GetAllFrames().size()); |
| 482 | 480 |
| 483 // ... load an extension frame in the non-extension process | 481 // ... load an extension frame in the non-extension process |
| 484 EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame1", kExt1EmptyUrl)); | 482 EXPECT_TRUE(content::NavigateIframeToURL(tab, "frame1", kExt1EmptyUrl)); |
| 485 EXPECT_EQ(IfExtensionsIsolated(2, 1), | 483 EXPECT_EQ(IfExtensionsIsolated(2, 1), |
| 486 pm->GetRenderFrameHostsForExtension(extension1->id()).size()); | 484 pm->GetRenderFrameHostsForExtension(extension1->id()).size()); |
| 487 | 485 |
| 488 // ... and take down the tab. The extension process is not part of the tab, | 486 // ... and take down the tab. The extension process is not part of the tab, |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 extension->id(), | 569 extension->id(), |
| 572 "document.cookie = 'extension_cookie';" | 570 "document.cookie = 'extension_cookie';" |
| 573 "window.domAutomationController.send(document.cookie);"); | 571 "window.domAutomationController.send(document.cookie);"); |
| 574 std::string message; | 572 std::string message; |
| 575 ASSERT_TRUE(queue.WaitForMessage(&message)); | 573 ASSERT_TRUE(queue.WaitForMessage(&message)); |
| 576 EXPECT_EQ(message, "\"extension_cookie\""); | 574 EXPECT_EQ(message, "\"extension_cookie\""); |
| 577 } | 575 } |
| 578 } | 576 } |
| 579 | 577 |
| 580 } // namespace extensions | 578 } // namespace extensions |
| OLD | NEW |