| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "build/build_config.h" | 6 #include "build/build_config.h" |
| 7 #include "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
| 8 #include "chrome/browser/extensions/extension_apitest.h" | 8 #include "chrome/browser/extensions/extension_apitest.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 // Pass flags to make testing apps easier. | 58 // Pass flags to make testing apps easier. |
| 59 void SetUpCommandLine(base::CommandLine* command_line) override { | 59 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 60 ExtensionApiTest::SetUpCommandLine(command_line); | 60 ExtensionApiTest::SetUpCommandLine(command_line); |
| 61 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 61 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 62 switches::kDisablePopupBlocking); | 62 switches::kDisablePopupBlocking); |
| 63 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 63 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 64 extensions::switches::kAllowHTTPBackgroundPage); | 64 extensions::switches::kAllowHTTPBackgroundPage); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void SetUpOnMainThread() override { |
| 68 ExtensionApiTest::SetUpOnMainThread(); |
| 69 host_resolver()->AddRule("*", "127.0.0.1"); |
| 70 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 71 } |
| 72 |
| 67 // Helper function to test that independent tabs of the named app are loaded | 73 // Helper function to test that independent tabs of the named app are loaded |
| 68 // into separate processes. | 74 // into separate processes. |
| 69 void TestAppInstancesHelper(const std::string& app_name) { | 75 void TestAppInstancesHelper(const std::string& app_name) { |
| 70 LOG(INFO) << "Start of test."; | 76 LOG(INFO) << "Start of test."; |
| 71 | 77 |
| 72 extensions::ProcessMap* process_map = | 78 extensions::ProcessMap* process_map = |
| 73 extensions::ProcessMap::Get(browser()->profile()); | 79 extensions::ProcessMap::Get(browser()->profile()); |
| 74 | 80 |
| 75 host_resolver()->AddRule("*", "127.0.0.1"); | |
| 76 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 77 | |
| 78 ASSERT_TRUE(LoadExtension( | 81 ASSERT_TRUE(LoadExtension( |
| 79 test_data_dir_.AppendASCII(app_name))); | 82 test_data_dir_.AppendASCII(app_name))); |
| 80 const Extension* extension = GetSingleLoadedExtension(); | 83 const Extension* extension = GetSingleLoadedExtension(); |
| 81 | 84 |
| 82 // Open two tabs in the app, one outside it. | 85 // Open two tabs in the app, one outside it. |
| 83 GURL base_url = GetTestBaseURL(app_name); | 86 GURL base_url = GetTestBaseURL(app_name); |
| 84 | 87 |
| 85 // Test both opening a URL in a new tab, and opening a tab and then | 88 // Test both opening a URL in a new tab, and opening a tab and then |
| 86 // navigating it. Either way, app tabs should be considered extension | 89 // navigating it. Either way, app tabs should be considered extension |
| 87 // processes, but they have no elevated privileges and thus should not | 90 // processes, but they have no elevated privileges and thus should not |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 | 145 |
| 143 // Tests that hosted apps with the background permission get a process-per-app | 146 // Tests that hosted apps with the background permission get a process-per-app |
| 144 // model, since all pages need to be able to script the background page. | 147 // model, since all pages need to be able to script the background page. |
| 145 // http://crbug.com/172750 | 148 // http://crbug.com/172750 |
| 146 IN_PROC_BROWSER_TEST_F(AppApiTest, DISABLED_AppProcess) { | 149 IN_PROC_BROWSER_TEST_F(AppApiTest, DISABLED_AppProcess) { |
| 147 LOG(INFO) << "Start of test."; | 150 LOG(INFO) << "Start of test."; |
| 148 | 151 |
| 149 extensions::ProcessMap* process_map = | 152 extensions::ProcessMap* process_map = |
| 150 extensions::ProcessMap::Get(browser()->profile()); | 153 extensions::ProcessMap::Get(browser()->profile()); |
| 151 | 154 |
| 152 host_resolver()->AddRule("*", "127.0.0.1"); | |
| 153 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 154 | |
| 155 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app_process"))); | 155 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app_process"))); |
| 156 | 156 |
| 157 LOG(INFO) << "Loaded extension."; | 157 LOG(INFO) << "Loaded extension."; |
| 158 | 158 |
| 159 // Open two tabs in the app, one outside it. | 159 // Open two tabs in the app, one outside it. |
| 160 GURL base_url = GetTestBaseURL("app_process"); | 160 GURL base_url = GetTestBaseURL("app_process"); |
| 161 | 161 |
| 162 // Test both opening a URL in a new tab, and opening a tab and then navigating | 162 // Test both opening a URL in a new tab, and opening a tab and then navigating |
| 163 // it. Either way, app tabs should be considered extension processes, but | 163 // it. Either way, app tabs should be considered extension processes, but |
| 164 // they have no elevated privileges and thus should not have WebUI bindings. | 164 // they have no elevated privileges and thus should not have WebUI bindings. |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 #define MAYBE_BookmarkAppGetsNormalProcess DISABLED_BookmarkAppGetsNormalProcess | 291 #define MAYBE_BookmarkAppGetsNormalProcess DISABLED_BookmarkAppGetsNormalProcess |
| 292 #else | 292 #else |
| 293 #define MAYBE_BookmarkAppGetsNormalProcess BookmarkAppGetsNormalProcess | 293 #define MAYBE_BookmarkAppGetsNormalProcess BookmarkAppGetsNormalProcess |
| 294 #endif | 294 #endif |
| 295 IN_PROC_BROWSER_TEST_F(AppApiTest, MAYBE_BookmarkAppGetsNormalProcess) { | 295 IN_PROC_BROWSER_TEST_F(AppApiTest, MAYBE_BookmarkAppGetsNormalProcess) { |
| 296 ExtensionService* service = extensions::ExtensionSystem::Get( | 296 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 297 browser()->profile())->extension_service(); | 297 browser()->profile())->extension_service(); |
| 298 extensions::ProcessMap* process_map = | 298 extensions::ProcessMap* process_map = |
| 299 extensions::ProcessMap::Get(browser()->profile()); | 299 extensions::ProcessMap::Get(browser()->profile()); |
| 300 | 300 |
| 301 host_resolver()->AddRule("*", "127.0.0.1"); | |
| 302 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 303 GURL base_url = GetTestBaseURL("app_process"); | 301 GURL base_url = GetTestBaseURL("app_process"); |
| 304 | 302 |
| 305 // Load an app as a bookmark app. | 303 // Load an app as a bookmark app. |
| 306 std::string error; | 304 std::string error; |
| 307 scoped_refptr<const Extension> extension; | 305 scoped_refptr<const Extension> extension; |
| 308 { | 306 { |
| 309 base::ThreadRestrictions::ScopedAllowIO allow_io; | 307 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 310 extension = extensions::file_util::LoadExtension( | 308 extension = extensions::file_util::LoadExtension( |
| 311 test_data_dir_.AppendASCII("app_process"), | 309 test_data_dir_.AppendASCII("app_process"), |
| 312 extensions::Manifest::UNPACKED, Extension::FROM_BOOKMARK, &error); | 310 extensions::Manifest::UNPACKED, Extension::FROM_BOOKMARK, &error); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 } | 371 } |
| 374 | 372 |
| 375 // Tests that app process switching works properly in the following scenario: | 373 // Tests that app process switching works properly in the following scenario: |
| 376 // 1. navigate to a page1 in the app | 374 // 1. navigate to a page1 in the app |
| 377 // 2. page1 redirects to a page2 outside the app extent (ie, "/server-redirect") | 375 // 2. page1 redirects to a page2 outside the app extent (ie, "/server-redirect") |
| 378 // 3. page2 redirects back to a page in the app | 376 // 3. page2 redirects back to a page in the app |
| 379 // The final navigation should end up in the app process. | 377 // The final navigation should end up in the app process. |
| 380 // See http://crbug.com/61757 | 378 // See http://crbug.com/61757 |
| 381 // Flaky. http://crbug.com/341898 | 379 // Flaky. http://crbug.com/341898 |
| 382 IN_PROC_BROWSER_TEST_F(AppApiTest, DISABLED_AppProcessRedirectBack) { | 380 IN_PROC_BROWSER_TEST_F(AppApiTest, DISABLED_AppProcessRedirectBack) { |
| 383 host_resolver()->AddRule("*", "127.0.0.1"); | |
| 384 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 385 | |
| 386 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app_process"))); | 381 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app_process"))); |
| 387 | 382 |
| 388 // Open two tabs in the app. | 383 // Open two tabs in the app. |
| 389 GURL base_url = GetTestBaseURL("app_process"); | 384 GURL base_url = GetTestBaseURL("app_process"); |
| 390 | 385 |
| 391 chrome::NewTab(browser()); | 386 chrome::NewTab(browser()); |
| 392 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html")); | 387 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html")); |
| 393 chrome::NewTab(browser()); | 388 chrome::NewTab(browser()); |
| 394 // Wait until the second tab finishes its redirect train (2 hops). | 389 // Wait until the second tab finishes its redirect train (2 hops). |
| 395 // 1. We navigate to redirect.html | 390 // 1. We navigate to redirect.html |
| (...skipping 22 matching lines...) Expand all Loading... |
| 418 | 413 |
| 419 // Ensure that re-navigating to a URL after installing or uninstalling it as an | 414 // Ensure that re-navigating to a URL after installing or uninstalling it as an |
| 420 // app correctly swaps the tab to the app process. (http://crbug.com/80621) | 415 // app correctly swaps the tab to the app process. (http://crbug.com/80621) |
| 421 // | 416 // |
| 422 // Fails on Windows. http://crbug.com/238670 | 417 // Fails on Windows. http://crbug.com/238670 |
| 423 // Added logging to help diagnose the location of the problem. | 418 // Added logging to help diagnose the location of the problem. |
| 424 IN_PROC_BROWSER_TEST_F(AppApiTest, NavigateIntoAppProcess) { | 419 IN_PROC_BROWSER_TEST_F(AppApiTest, NavigateIntoAppProcess) { |
| 425 extensions::ProcessMap* process_map = | 420 extensions::ProcessMap* process_map = |
| 426 extensions::ProcessMap::Get(browser()->profile()); | 421 extensions::ProcessMap::Get(browser()->profile()); |
| 427 | 422 |
| 428 host_resolver()->AddRule("*", "127.0.0.1"); | |
| 429 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 430 | |
| 431 // The app under test acts on URLs whose host is "localhost", | 423 // The app under test acts on URLs whose host is "localhost", |
| 432 // so the URLs we navigate to must have host "localhost". | 424 // so the URLs we navigate to must have host "localhost". |
| 433 GURL base_url = GetTestBaseURL("app_process"); | 425 GURL base_url = GetTestBaseURL("app_process"); |
| 434 | 426 |
| 435 // Load an app URL before loading the app. | 427 // Load an app URL before loading the app. |
| 436 LOG(INFO) << "Loading path1/empty.html."; | 428 LOG(INFO) << "Loading path1/empty.html."; |
| 437 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html")); | 429 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html")); |
| 438 LOG(INFO) << "Loading path1/empty.html - done."; | 430 LOG(INFO) << "Loading path1/empty.html - done."; |
| 439 WebContents* contents = browser()->tab_strip_model()->GetWebContentsAt(0); | 431 WebContents* contents = browser()->tab_strip_model()->GetWebContentsAt(0); |
| 440 EXPECT_FALSE(process_map->Contains( | 432 EXPECT_FALSE(process_map->Contains( |
| (...skipping 24 matching lines...) Expand all Loading... |
| 465 | 457 |
| 466 // Ensure that reloading a URL after installing or uninstalling it as an app | 458 // Ensure that reloading a URL after installing or uninstalling it as an app |
| 467 // correctly swaps the tab to the app process. (http://crbug.com/80621) | 459 // correctly swaps the tab to the app process. (http://crbug.com/80621) |
| 468 // | 460 // |
| 469 // Added logging to help diagnose the location of the problem. | 461 // Added logging to help diagnose the location of the problem. |
| 470 // http://crbug.com/238670 | 462 // http://crbug.com/238670 |
| 471 IN_PROC_BROWSER_TEST_F(AppApiTest, ReloadIntoAppProcess) { | 463 IN_PROC_BROWSER_TEST_F(AppApiTest, ReloadIntoAppProcess) { |
| 472 extensions::ProcessMap* process_map = | 464 extensions::ProcessMap* process_map = |
| 473 extensions::ProcessMap::Get(browser()->profile()); | 465 extensions::ProcessMap::Get(browser()->profile()); |
| 474 | 466 |
| 475 host_resolver()->AddRule("*", "127.0.0.1"); | |
| 476 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 477 | |
| 478 // The app under test acts on URLs whose host is "localhost", | 467 // The app under test acts on URLs whose host is "localhost", |
| 479 // so the URLs we navigate to must have host "localhost". | 468 // so the URLs we navigate to must have host "localhost". |
| 480 GURL base_url = GetTestBaseURL("app_process"); | 469 GURL base_url = GetTestBaseURL("app_process"); |
| 481 | 470 |
| 482 // Load app, disable it, and navigate to the page. | 471 // Load app, disable it, and navigate to the page. |
| 483 LOG(INFO) << "Loading extension."; | 472 LOG(INFO) << "Loading extension."; |
| 484 const Extension* app = | 473 const Extension* app = |
| 485 LoadExtension(test_data_dir_.AppendASCII("app_process")); | 474 LoadExtension(test_data_dir_.AppendASCII("app_process")); |
| 486 LOG(INFO) << "Loading extension - done."; | 475 LOG(INFO) << "Loading extension - done."; |
| 487 ASSERT_TRUE(app); | 476 ASSERT_TRUE(app); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 | 519 |
| 531 // Ensure that reloading a URL with JavaScript after installing or uninstalling | 520 // Ensure that reloading a URL with JavaScript after installing or uninstalling |
| 532 // it as an app correctly swaps the process. (http://crbug.com/80621) | 521 // it as an app correctly swaps the process. (http://crbug.com/80621) |
| 533 // | 522 // |
| 534 // Crashes on Windows and Mac. http://crbug.com/238670 | 523 // Crashes on Windows and Mac. http://crbug.com/238670 |
| 535 // Added logging to help diagnose the location of the problem. | 524 // Added logging to help diagnose the location of the problem. |
| 536 IN_PROC_BROWSER_TEST_F(AppApiTest, ReloadIntoAppProcessWithJavaScript) { | 525 IN_PROC_BROWSER_TEST_F(AppApiTest, ReloadIntoAppProcessWithJavaScript) { |
| 537 extensions::ProcessMap* process_map = | 526 extensions::ProcessMap* process_map = |
| 538 extensions::ProcessMap::Get(browser()->profile()); | 527 extensions::ProcessMap::Get(browser()->profile()); |
| 539 | 528 |
| 540 host_resolver()->AddRule("*", "127.0.0.1"); | |
| 541 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 542 | |
| 543 // The app under test acts on URLs whose host is "localhost", | 529 // The app under test acts on URLs whose host is "localhost", |
| 544 // so the URLs we navigate to must have host "localhost". | 530 // so the URLs we navigate to must have host "localhost". |
| 545 GURL base_url = GetTestBaseURL("app_process"); | 531 GURL base_url = GetTestBaseURL("app_process"); |
| 546 | 532 |
| 547 // Load app, disable it, and navigate to the page. | 533 // Load app, disable it, and navigate to the page. |
| 548 LOG(INFO) << "Loading extension."; | 534 LOG(INFO) << "Loading extension."; |
| 549 const Extension* app = | 535 const Extension* app = |
| 550 LoadExtension(test_data_dir_.AppendASCII("app_process")); | 536 LoadExtension(test_data_dir_.AppendASCII("app_process")); |
| 551 LOG(INFO) << "Loading extension - done."; | 537 LOG(INFO) << "Loading extension - done."; |
| 552 ASSERT_TRUE(app); | 538 ASSERT_TRUE(app); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 | 581 |
| 596 // Tests that if we have a non-app process (path3/container.html) that has an | 582 // Tests that if we have a non-app process (path3/container.html) that has an |
| 597 // iframe with a URL in the app's extent (path1/iframe.html), then opening a | 583 // iframe with a URL in the app's extent (path1/iframe.html), then opening a |
| 598 // link from that iframe to a new window to a URL in the app's extent (path1/ | 584 // link from that iframe to a new window to a URL in the app's extent (path1/ |
| 599 // empty.html) results in the new window being in an app process. See | 585 // empty.html) results in the new window being in an app process. See |
| 600 // http://crbug.com/89272 for more details. | 586 // http://crbug.com/89272 for more details. |
| 601 IN_PROC_BROWSER_TEST_F(AppApiTest, OpenAppFromIframe) { | 587 IN_PROC_BROWSER_TEST_F(AppApiTest, OpenAppFromIframe) { |
| 602 extensions::ProcessMap* process_map = | 588 extensions::ProcessMap* process_map = |
| 603 extensions::ProcessMap::Get(browser()->profile()); | 589 extensions::ProcessMap::Get(browser()->profile()); |
| 604 | 590 |
| 605 host_resolver()->AddRule("*", "127.0.0.1"); | |
| 606 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 607 | |
| 608 GURL base_url = GetTestBaseURL("app_process"); | 591 GURL base_url = GetTestBaseURL("app_process"); |
| 609 | 592 |
| 610 // Load app and start URL (not in the app). | 593 // Load app and start URL (not in the app). |
| 611 const Extension* app = | 594 const Extension* app = |
| 612 LoadExtension(test_data_dir_.AppendASCII("app_process")); | 595 LoadExtension(test_data_dir_.AppendASCII("app_process")); |
| 613 ASSERT_TRUE(app); | 596 ASSERT_TRUE(app); |
| 614 | 597 |
| 615 ui_test_utils::NavigateToURL(browser(), | 598 ui_test_utils::NavigateToURL(browser(), |
| 616 base_url.Resolve("path3/container.html")); | 599 base_url.Resolve("path3/container.html")); |
| 617 EXPECT_FALSE(process_map->Contains( | 600 EXPECT_FALSE(process_map->Contains( |
| (...skipping 13 matching lines...) Expand all Loading... |
| 631 | 614 |
| 632 // Similar to the previous test, but ensure that popup blocking bypass | 615 // Similar to the previous test, but ensure that popup blocking bypass |
| 633 // isn't granted to the iframe. See crbug.com/117446. | 616 // isn't granted to the iframe. See crbug.com/117446. |
| 634 #if defined(OS_CHROMEOS) | 617 #if defined(OS_CHROMEOS) |
| 635 // http://crbug.com/153513 | 618 // http://crbug.com/153513 |
| 636 #define MAYBE_OpenAppFromIframe DISABLED_OpenAppFromIframe | 619 #define MAYBE_OpenAppFromIframe DISABLED_OpenAppFromIframe |
| 637 #else | 620 #else |
| 638 #define MAYBE_OpenAppFromIframe OpenAppFromIframe | 621 #define MAYBE_OpenAppFromIframe OpenAppFromIframe |
| 639 #endif | 622 #endif |
| 640 IN_PROC_BROWSER_TEST_F(BlockedAppApiTest, MAYBE_OpenAppFromIframe) { | 623 IN_PROC_BROWSER_TEST_F(BlockedAppApiTest, MAYBE_OpenAppFromIframe) { |
| 641 host_resolver()->AddRule("*", "127.0.0.1"); | |
| 642 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 643 | |
| 644 // Load app and start URL (not in the app). | 624 // Load app and start URL (not in the app). |
| 645 const Extension* app = | 625 const Extension* app = |
| 646 LoadExtension(test_data_dir_.AppendASCII("app_process")); | 626 LoadExtension(test_data_dir_.AppendASCII("app_process")); |
| 647 ASSERT_TRUE(app); | 627 ASSERT_TRUE(app); |
| 648 | 628 |
| 649 ui_test_utils::NavigateToURL( | 629 ui_test_utils::NavigateToURL( |
| 650 browser(), GetTestBaseURL("app_process").Resolve("path3/container.html")); | 630 browser(), GetTestBaseURL("app_process").Resolve("path3/container.html")); |
| 651 | 631 |
| 652 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 632 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
| 653 PopupBlockerTabHelper* popup_blocker_tab_helper = | 633 PopupBlockerTabHelper* popup_blocker_tab_helper = |
| 654 PopupBlockerTabHelper::FromWebContents(tab); | 634 PopupBlockerTabHelper::FromWebContents(tab); |
| 655 if (!popup_blocker_tab_helper->GetBlockedPopupsCount()) { | 635 if (!popup_blocker_tab_helper->GetBlockedPopupsCount()) { |
| 656 content::WindowedNotificationObserver observer( | 636 content::WindowedNotificationObserver observer( |
| 657 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, | 637 chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, |
| 658 content::NotificationService::AllSources()); | 638 content::NotificationService::AllSources()); |
| 659 observer.Wait(); | 639 observer.Wait(); |
| 660 } | 640 } |
| 661 | 641 |
| 662 EXPECT_EQ(1u, popup_blocker_tab_helper->GetBlockedPopupsCount()); | 642 EXPECT_EQ(1u, popup_blocker_tab_helper->GetBlockedPopupsCount()); |
| 663 } | 643 } |
| 664 | 644 |
| 665 // Tests that if an extension launches an app via chrome.tabs.create with an URL | 645 // Tests that if an extension launches an app via chrome.tabs.create with an URL |
| 666 // that's not in the app's extent but that server redirects to it, we still end | 646 // that's not in the app's extent but that server redirects to it, we still end |
| 667 // up with an app process. See http://crbug.com/99349 for more details. | 647 // up with an app process. See http://crbug.com/99349 for more details. |
| 668 IN_PROC_BROWSER_TEST_F(AppApiTest, ServerRedirectToAppFromExtension) { | 648 IN_PROC_BROWSER_TEST_F(AppApiTest, ServerRedirectToAppFromExtension) { |
| 669 host_resolver()->AddRule("*", "127.0.0.1"); | |
| 670 ASSERT_TRUE(StartEmbeddedTestServer()); | |
| 671 | |
| 672 LoadExtension(test_data_dir_.AppendASCII("app_process")); | 649 LoadExtension(test_data_dir_.AppendASCII("app_process")); |
| 673 const Extension* launcher = | 650 const Extension* launcher = |
| 674 LoadExtension(test_data_dir_.AppendASCII("app_launcher")); | 651 LoadExtension(test_data_dir_.AppendASCII("app_launcher")); |
| 675 | 652 |
| 676 // There should be two navigations by the time the app page is loaded. | 653 // There should be two navigations by the time the app page is loaded. |
| 677 // 1. The extension launcher page. | 654 // 1. The extension launcher page. |
| 678 // 2. The app's URL (which includes a server redirect). | 655 // 2. The app's URL (which includes a server redirect). |
| 679 // Note that the server redirect does not generate a navigation event. | 656 // Note that the server redirect does not generate a navigation event. |
| 680 content::TestNavigationObserver test_navigation_observer( | 657 content::TestNavigationObserver test_navigation_observer( |
| 681 browser()->tab_strip_model()->GetActiveWebContents(), | 658 browser()->tab_strip_model()->GetActiveWebContents(), |
| (...skipping 13 matching lines...) Expand all Loading... |
| 695 browser()->tab_strip_model()->GetActiveWebContents(), | 672 browser()->tab_strip_model()->GetActiveWebContents(), |
| 696 "window.domAutomationController.send(chrome.app.isInstalled)", | 673 "window.domAutomationController.send(chrome.app.isInstalled)", |
| 697 &is_installed)); | 674 &is_installed)); |
| 698 ASSERT_TRUE(is_installed); | 675 ASSERT_TRUE(is_installed); |
| 699 } | 676 } |
| 700 | 677 |
| 701 // Tests that if an extension launches an app via chrome.tabs.create with an URL | 678 // Tests that if an extension launches an app via chrome.tabs.create with an URL |
| 702 // that's not in the app's extent but that client redirects to it, we still end | 679 // that's not in the app's extent but that client redirects to it, we still end |
| 703 // up with an app process. | 680 // up with an app process. |
| 704 IN_PROC_BROWSER_TEST_F(AppApiTest, ClientRedirectToAppFromExtension) { | 681 IN_PROC_BROWSER_TEST_F(AppApiTest, ClientRedirectToAppFromExtension) { |
| 705 host_resolver()->AddRule("*", "127.0.0.1"); | |
| 706 ASSERT_TRUE(StartEmbeddedTestServer()); | |
| 707 | |
| 708 LoadExtension(test_data_dir_.AppendASCII("app_process")); | 682 LoadExtension(test_data_dir_.AppendASCII("app_process")); |
| 709 const Extension* launcher = | 683 const Extension* launcher = |
| 710 LoadExtension(test_data_dir_.AppendASCII("app_launcher")); | 684 LoadExtension(test_data_dir_.AppendASCII("app_launcher")); |
| 711 | 685 |
| 712 // There should be three navigations by the time the app page is loaded. | 686 // There should be three navigations by the time the app page is loaded. |
| 713 // 1. The extension launcher page. | 687 // 1. The extension launcher page. |
| 714 // 2. The URL that the extension launches, which client redirects. | 688 // 2. The URL that the extension launches, which client redirects. |
| 715 // 3. The app's URL. | 689 // 3. The app's URL. |
| 716 content::TestNavigationObserver test_navigation_observer( | 690 content::TestNavigationObserver test_navigation_observer( |
| 717 browser()->tab_strip_model()->GetActiveWebContents(), | 691 browser()->tab_strip_model()->GetActiveWebContents(), |
| (...skipping 20 matching lines...) Expand all Loading... |
| 738 // iframe (path3/iframe.html), then opening a link from that iframe to a new | 712 // iframe (path3/iframe.html), then opening a link from that iframe to a new |
| 739 // window to a same-origin non-app URL (path3/empty.html) should keep the window | 713 // window to a same-origin non-app URL (path3/empty.html) should keep the window |
| 740 // in the app process. | 714 // in the app process. |
| 741 // This is in contrast to OpenAppFromIframe, since here the popup will not be | 715 // This is in contrast to OpenAppFromIframe, since here the popup will not be |
| 742 // missing special permissions and should be scriptable from the iframe. | 716 // missing special permissions and should be scriptable from the iframe. |
| 743 // See http://crbug.com/92669 for more details. | 717 // See http://crbug.com/92669 for more details. |
| 744 IN_PROC_BROWSER_TEST_F(AppApiTest, OpenWebPopupFromWebIframe) { | 718 IN_PROC_BROWSER_TEST_F(AppApiTest, OpenWebPopupFromWebIframe) { |
| 745 extensions::ProcessMap* process_map = | 719 extensions::ProcessMap* process_map = |
| 746 extensions::ProcessMap::Get(browser()->profile()); | 720 extensions::ProcessMap::Get(browser()->profile()); |
| 747 | 721 |
| 748 host_resolver()->AddRule("*", "127.0.0.1"); | |
| 749 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 750 | |
| 751 GURL base_url = GetTestBaseURL("app_process"); | 722 GURL base_url = GetTestBaseURL("app_process"); |
| 752 | 723 |
| 753 // Load app and start URL (in the app). | 724 // Load app and start URL (in the app). |
| 754 const Extension* app = | 725 const Extension* app = |
| 755 LoadExtension(test_data_dir_.AppendASCII("app_process")); | 726 LoadExtension(test_data_dir_.AppendASCII("app_process")); |
| 756 ASSERT_TRUE(app); | 727 ASSERT_TRUE(app); |
| 757 | 728 |
| 758 ui_test_utils::NavigateToURL(browser(), | 729 ui_test_utils::NavigateToURL(browser(), |
| 759 base_url.Resolve("path1/container.html")); | 730 base_url.Resolve("path1/container.html")); |
| 760 content::RenderProcessHost* process = | 731 content::RenderProcessHost* process = |
| (...skipping 19 matching lines...) Expand all Loading... |
| 780 // http://crbug.com/118502 | 751 // http://crbug.com/118502 |
| 781 #if defined(OS_MACOSX) || defined(OS_LINUX) | 752 #if defined(OS_MACOSX) || defined(OS_LINUX) |
| 782 #define MAYBE_ReloadAppAfterCrash DISABLED_ReloadAppAfterCrash | 753 #define MAYBE_ReloadAppAfterCrash DISABLED_ReloadAppAfterCrash |
| 783 #else | 754 #else |
| 784 #define MAYBE_ReloadAppAfterCrash ReloadAppAfterCrash | 755 #define MAYBE_ReloadAppAfterCrash ReloadAppAfterCrash |
| 785 #endif | 756 #endif |
| 786 IN_PROC_BROWSER_TEST_F(AppApiTest, MAYBE_ReloadAppAfterCrash) { | 757 IN_PROC_BROWSER_TEST_F(AppApiTest, MAYBE_ReloadAppAfterCrash) { |
| 787 extensions::ProcessMap* process_map = | 758 extensions::ProcessMap* process_map = |
| 788 extensions::ProcessMap::Get(browser()->profile()); | 759 extensions::ProcessMap::Get(browser()->profile()); |
| 789 | 760 |
| 790 host_resolver()->AddRule("*", "127.0.0.1"); | |
| 791 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 792 | |
| 793 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app_process"))); | 761 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app_process"))); |
| 794 | 762 |
| 795 GURL base_url = GetTestBaseURL("app_process"); | 763 GURL base_url = GetTestBaseURL("app_process"); |
| 796 | 764 |
| 797 // Load the app, chrome.app.isInstalled should be true. | 765 // Load the app, chrome.app.isInstalled should be true. |
| 798 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html")); | 766 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html")); |
| 799 WebContents* contents = browser()->tab_strip_model()->GetWebContentsAt(0); | 767 WebContents* contents = browser()->tab_strip_model()->GetWebContentsAt(0); |
| 800 EXPECT_TRUE(process_map->Contains( | 768 EXPECT_TRUE(process_map->Contains( |
| 801 contents->GetRenderProcessHost()->GetID())); | 769 contents->GetRenderProcessHost()->GetID())); |
| 802 bool is_installed = false; | 770 bool is_installed = false; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 822 ASSERT_TRUE(is_installed); | 790 ASSERT_TRUE(is_installed); |
| 823 } | 791 } |
| 824 | 792 |
| 825 // Test that a cross-process navigation away from a hosted app stays in the same | 793 // Test that a cross-process navigation away from a hosted app stays in the same |
| 826 // BrowsingInstance, so that postMessage calls to the app's other windows still | 794 // BrowsingInstance, so that postMessage calls to the app's other windows still |
| 827 // work. | 795 // work. |
| 828 IN_PROC_BROWSER_TEST_F(AppApiTest, SameBrowsingInstanceAfterSwap) { | 796 IN_PROC_BROWSER_TEST_F(AppApiTest, SameBrowsingInstanceAfterSwap) { |
| 829 extensions::ProcessMap* process_map = | 797 extensions::ProcessMap* process_map = |
| 830 extensions::ProcessMap::Get(browser()->profile()); | 798 extensions::ProcessMap::Get(browser()->profile()); |
| 831 | 799 |
| 832 host_resolver()->AddRule("*", "127.0.0.1"); | |
| 833 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 834 | |
| 835 GURL base_url = GetTestBaseURL("app_process"); | 800 GURL base_url = GetTestBaseURL("app_process"); |
| 836 | 801 |
| 837 // Load app and start URL (in the app). | 802 // Load app and start URL (in the app). |
| 838 const Extension* app = | 803 const Extension* app = |
| 839 LoadExtension(test_data_dir_.AppendASCII("app_process")); | 804 LoadExtension(test_data_dir_.AppendASCII("app_process")); |
| 840 ASSERT_TRUE(app); | 805 ASSERT_TRUE(app); |
| 841 | 806 |
| 842 ui_test_utils::NavigateToURL(browser(), | 807 ui_test_utils::NavigateToURL(browser(), |
| 843 base_url.Resolve("path1/iframe.html")); | 808 base_url.Resolve("path1/iframe.html")); |
| 844 content::SiteInstance* app_instance = | 809 content::SiteInstance* app_instance = |
| (...skipping 13 matching lines...) Expand all Loading... |
| 858 // Navigate the popup to another process outside the app. | 823 // Navigate the popup to another process outside the app. |
| 859 GURL non_app_url(base_url.Resolve("path3/empty.html")); | 824 GURL non_app_url(base_url.Resolve("path3/empty.html")); |
| 860 ui_test_utils::NavigateToURL(active_browser_list->get(1), non_app_url); | 825 ui_test_utils::NavigateToURL(active_browser_list->get(1), non_app_url); |
| 861 SiteInstance* new_instance = popup_contents->GetSiteInstance(); | 826 SiteInstance* new_instance = popup_contents->GetSiteInstance(); |
| 862 EXPECT_NE(app_instance, new_instance); | 827 EXPECT_NE(app_instance, new_instance); |
| 863 | 828 |
| 864 // It should still be in the same BrowsingInstance, allowing postMessage to | 829 // It should still be in the same BrowsingInstance, allowing postMessage to |
| 865 // work. | 830 // work. |
| 866 EXPECT_TRUE(app_instance->IsRelatedSiteInstance(new_instance)); | 831 EXPECT_TRUE(app_instance->IsRelatedSiteInstance(new_instance)); |
| 867 } | 832 } |
| OLD | NEW |