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

Side by Side Diff: chrome/browser/extensions/app_process_apitest.cc

Issue 139943005: Convert extensions::ProcessMap to BrowserContextKeyedService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase process_map Created 6 years, 11 months 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 | Annotate | Revision Log
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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "chrome/browser/chrome_notification_types.h" 6 #include "chrome/browser/chrome_notification_types.h"
7 #include "chrome/browser/extensions/extension_apitest.h" 7 #include "chrome/browser/extensions/extension_apitest.h"
8 #include "chrome/browser/extensions/extension_host.h" 8 #include "chrome/browser/extensions/extension_host.h"
9 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/extensions/extension_system.h" 10 #include "chrome/browser/extensions/extension_system.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 switches::kDisablePopupBlocking); 62 switches::kDisablePopupBlocking);
63 CommandLine::ForCurrentProcess()->AppendSwitch( 63 CommandLine::ForCurrentProcess()->AppendSwitch(
64 extensions::switches::kAllowHTTPBackgroundPage); 64 extensions::switches::kAllowHTTPBackgroundPage);
65 } 65 }
66 66
67 // Helper function to test that independent tabs of the named app are loaded 67 // Helper function to test that independent tabs of the named app are loaded
68 // into separate processes. 68 // into separate processes.
69 void TestAppInstancesHelper(std::string app_name) { 69 void TestAppInstancesHelper(std::string app_name) {
70 LOG(INFO) << "Start of test."; 70 LOG(INFO) << "Start of test.";
71 71
72 extensions::ProcessMap* process_map = extensions::ExtensionSystem::Get( 72 extensions::ProcessMap* process_map =
73 browser()->profile())->extension_service()->process_map(); 73 extensions::ProcessMap::Get(browser()->profile());
74 74
75 host_resolver()->AddRule("*", "127.0.0.1"); 75 host_resolver()->AddRule("*", "127.0.0.1");
76 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 76 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
77 77
78 ASSERT_TRUE(LoadExtension( 78 ASSERT_TRUE(LoadExtension(
79 test_data_dir_.AppendASCII(app_name))); 79 test_data_dir_.AppendASCII(app_name)));
80 const Extension* extension = GetSingleLoadedExtension(); 80 const Extension* extension = GetSingleLoadedExtension();
81 81
82 // Open two tabs in the app, one outside it. 82 // Open two tabs in the app, one outside it.
83 GURL base_url = GetTestBaseURL(app_name); 83 GURL base_url = GetTestBaseURL(app_name);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 extensions::switches::kAllowHTTPBackgroundPage); 139 extensions::switches::kAllowHTTPBackgroundPage);
140 } 140 }
141 }; 141 };
142 142
143 // Tests that hosted apps with the background permission get a process-per-app 143 // 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. 144 // model, since all pages need to be able to script the background page.
145 // http://crbug.com/172750 145 // http://crbug.com/172750
146 IN_PROC_BROWSER_TEST_F(AppApiTest, DISABLED_AppProcess) { 146 IN_PROC_BROWSER_TEST_F(AppApiTest, DISABLED_AppProcess) {
147 LOG(INFO) << "Start of test."; 147 LOG(INFO) << "Start of test.";
148 148
149 extensions::ProcessMap* process_map = extensions::ExtensionSystem::Get( 149 extensions::ProcessMap* process_map =
150 browser()->profile())->extension_service()->process_map(); 150 extensions::ProcessMap::Get(browser()->profile());
151 151
152 host_resolver()->AddRule("*", "127.0.0.1"); 152 host_resolver()->AddRule("*", "127.0.0.1");
153 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 153 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
154 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");
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 // like normal web pages instead. http://crbug.com/104636. 287 // like normal web pages instead. http://crbug.com/104636.
288 // Timing out on Windows. http://crbug.com/238777 288 // Timing out on Windows. http://crbug.com/238777
289 #if defined(OS_WIN) 289 #if defined(OS_WIN)
290 #define MAYBE_BookmarkAppGetsNormalProcess DISABLED_BookmarkAppGetsNormalProcess 290 #define MAYBE_BookmarkAppGetsNormalProcess DISABLED_BookmarkAppGetsNormalProcess
291 #else 291 #else
292 #define MAYBE_BookmarkAppGetsNormalProcess BookmarkAppGetsNormalProcess 292 #define MAYBE_BookmarkAppGetsNormalProcess BookmarkAppGetsNormalProcess
293 #endif 293 #endif
294 IN_PROC_BROWSER_TEST_F(AppApiTest, MAYBE_BookmarkAppGetsNormalProcess) { 294 IN_PROC_BROWSER_TEST_F(AppApiTest, MAYBE_BookmarkAppGetsNormalProcess) {
295 ExtensionService* service = extensions::ExtensionSystem::Get( 295 ExtensionService* service = extensions::ExtensionSystem::Get(
296 browser()->profile())->extension_service(); 296 browser()->profile())->extension_service();
297 extensions::ProcessMap* process_map = service->process_map(); 297 extensions::ProcessMap* process_map =
298 extensions::ProcessMap::Get(browser()->profile());
298 299
299 host_resolver()->AddRule("*", "127.0.0.1"); 300 host_resolver()->AddRule("*", "127.0.0.1");
300 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 301 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
301 GURL base_url = GetTestBaseURL("app_process"); 302 GURL base_url = GetTestBaseURL("app_process");
302 303
303 // Load an app as a bookmark app. 304 // Load an app as a bookmark app.
304 std::string error; 305 std::string error;
305 scoped_refptr<const Extension> extension(extension_file_util::LoadExtension( 306 scoped_refptr<const Extension> extension(extension_file_util::LoadExtension(
306 test_data_dir_.AppendASCII("app_process"), 307 test_data_dir_.AppendASCII("app_process"),
307 extensions::Manifest::UNPACKED, 308 extensions::Manifest::UNPACKED,
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 browser()->tab_strip_model()->GetWebContentsAt(2)-> 413 browser()->tab_strip_model()->GetWebContentsAt(2)->
413 GetRenderProcessHost()); 414 GetRenderProcessHost());
414 } 415 }
415 416
416 // Ensure that re-navigating to a URL after installing or uninstalling it as an 417 // Ensure that re-navigating to a URL after installing or uninstalling it as an
417 // app correctly swaps the tab to the app process. (http://crbug.com/80621) 418 // app correctly swaps the tab to the app process. (http://crbug.com/80621)
418 // 419 //
419 // Fails on Windows. http://crbug.com/238670 420 // Fails on Windows. http://crbug.com/238670
420 // Added logging to help diagnose the location of the problem. 421 // Added logging to help diagnose the location of the problem.
421 IN_PROC_BROWSER_TEST_F(AppApiTest, NavigateIntoAppProcess) { 422 IN_PROC_BROWSER_TEST_F(AppApiTest, NavigateIntoAppProcess) {
422 extensions::ProcessMap* process_map = extensions::ExtensionSystem::Get( 423 extensions::ProcessMap* process_map =
423 browser()->profile())->extension_service()->process_map(); 424 extensions::ProcessMap::Get(browser()->profile());
424 425
425 host_resolver()->AddRule("*", "127.0.0.1"); 426 host_resolver()->AddRule("*", "127.0.0.1");
426 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 427 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
427 428
428 // The app under test acts on URLs whose host is "localhost", 429 // The app under test acts on URLs whose host is "localhost",
429 // so the URLs we navigate to must have host "localhost". 430 // so the URLs we navigate to must have host "localhost".
430 GURL base_url = GetTestBaseURL("app_process"); 431 GURL base_url = GetTestBaseURL("app_process");
431 432
432 // Load an app URL before loading the app. 433 // Load an app URL before loading the app.
433 LOG(INFO) << "Loading path1/empty.html."; 434 LOG(INFO) << "Loading path1/empty.html.";
(...skipping 25 matching lines...) Expand all
459 EXPECT_FALSE(process_map->Contains( 460 EXPECT_FALSE(process_map->Contains(
460 contents->GetRenderProcessHost()->GetID())); 461 contents->GetRenderProcessHost()->GetID()));
461 } 462 }
462 463
463 // Ensure that reloading a URL after installing or uninstalling it as an app 464 // Ensure that reloading a URL after installing or uninstalling it as an app
464 // correctly swaps the tab to the app process. (http://crbug.com/80621) 465 // correctly swaps the tab to the app process. (http://crbug.com/80621)
465 // 466 //
466 // Added logging to help diagnose the location of the problem. 467 // Added logging to help diagnose the location of the problem.
467 // http://crbug.com/238670 468 // http://crbug.com/238670
468 IN_PROC_BROWSER_TEST_F(AppApiTest, ReloadIntoAppProcess) { 469 IN_PROC_BROWSER_TEST_F(AppApiTest, ReloadIntoAppProcess) {
469 extensions::ProcessMap* process_map = extensions::ExtensionSystem::Get( 470 extensions::ProcessMap* process_map =
470 browser()->profile())->extension_service()->process_map(); 471 extensions::ProcessMap::Get(browser()->profile());
471 472
472 host_resolver()->AddRule("*", "127.0.0.1"); 473 host_resolver()->AddRule("*", "127.0.0.1");
473 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 474 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
474 475
475 // The app under test acts on URLs whose host is "localhost", 476 // The app under test acts on URLs whose host is "localhost",
476 // so the URLs we navigate to must have host "localhost". 477 // so the URLs we navigate to must have host "localhost".
477 GURL base_url = GetTestBaseURL("app_process"); 478 GURL base_url = GetTestBaseURL("app_process");
478 479
479 // Load app, disable it, and navigate to the page. 480 // Load app, disable it, and navigate to the page.
480 LOG(INFO) << "Loading extension."; 481 LOG(INFO) << "Loading extension.";
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 EXPECT_FALSE(process_map->Contains( 525 EXPECT_FALSE(process_map->Contains(
525 contents->GetRenderProcessHost()->GetID())); 526 contents->GetRenderProcessHost()->GetID()));
526 } 527 }
527 528
528 // Ensure that reloading a URL with JavaScript after installing or uninstalling 529 // Ensure that reloading a URL with JavaScript after installing or uninstalling
529 // it as an app correctly swaps the process. (http://crbug.com/80621) 530 // it as an app correctly swaps the process. (http://crbug.com/80621)
530 // 531 //
531 // Crashes on Windows and Mac. http://crbug.com/238670 532 // Crashes on Windows and Mac. http://crbug.com/238670
532 // Added logging to help diagnose the location of the problem. 533 // Added logging to help diagnose the location of the problem.
533 IN_PROC_BROWSER_TEST_F(AppApiTest, ReloadIntoAppProcessWithJavaScript) { 534 IN_PROC_BROWSER_TEST_F(AppApiTest, ReloadIntoAppProcessWithJavaScript) {
534 extensions::ProcessMap* process_map = extensions::ExtensionSystem::Get( 535 extensions::ProcessMap* process_map =
535 browser()->profile())->extension_service()->process_map(); 536 extensions::ProcessMap::Get(browser()->profile());
536 537
537 host_resolver()->AddRule("*", "127.0.0.1"); 538 host_resolver()->AddRule("*", "127.0.0.1");
538 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 539 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
539 540
540 // The app under test acts on URLs whose host is "localhost", 541 // The app under test acts on URLs whose host is "localhost",
541 // so the URLs we navigate to must have host "localhost". 542 // so the URLs we navigate to must have host "localhost".
542 GURL base_url = GetTestBaseURL("app_process"); 543 GURL base_url = GetTestBaseURL("app_process");
543 544
544 // Load app, disable it, and navigate to the page. 545 // Load app, disable it, and navigate to the page.
545 LOG(INFO) << "Loading extension."; 546 LOG(INFO) << "Loading extension.";
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 // link from that iframe to a new window to a URL in the app's extent (path1/ 596 // link from that iframe to a new window to a URL in the app's extent (path1/
596 // empty.html) results in the new window being in an app process. See 597 // empty.html) results in the new window being in an app process. See
597 // http://crbug.com/89272 for more details. 598 // http://crbug.com/89272 for more details.
598 IN_PROC_BROWSER_TEST_F(AppApiTest, OpenAppFromIframe) { 599 IN_PROC_BROWSER_TEST_F(AppApiTest, OpenAppFromIframe) {
599 #if defined(OS_WIN) && defined(USE_ASH) 600 #if defined(OS_WIN) && defined(USE_ASH)
600 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 601 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
601 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) 602 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests))
602 return; 603 return;
603 #endif 604 #endif
604 605
605 extensions::ProcessMap* process_map = extensions::ExtensionSystem::Get( 606 extensions::ProcessMap* process_map =
606 browser()->profile())->extension_service()->process_map(); 607 extensions::ProcessMap::Get(browser()->profile());
607 608
608 host_resolver()->AddRule("*", "127.0.0.1"); 609 host_resolver()->AddRule("*", "127.0.0.1");
609 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 610 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
610 611
611 GURL base_url = GetTestBaseURL("app_process"); 612 GURL base_url = GetTestBaseURL("app_process");
612 613
613 // Load app and start URL (not in the app). 614 // Load app and start URL (not in the app).
614 const Extension* app = 615 const Extension* app =
615 LoadExtension(test_data_dir_.AppendASCII("app_process")); 616 LoadExtension(test_data_dir_.AppendASCII("app_process"));
616 ASSERT_TRUE(app); 617 ASSERT_TRUE(app);
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 } 746 }
746 747
747 // Tests that if we have an app process (path1/container.html) with a non-app 748 // Tests that if we have an app process (path1/container.html) with a non-app
748 // iframe (path3/iframe.html), then opening a link from that iframe to a new 749 // iframe (path3/iframe.html), then opening a link from that iframe to a new
749 // window to a same-origin non-app URL (path3/empty.html) should keep the window 750 // window to a same-origin non-app URL (path3/empty.html) should keep the window
750 // in the app process. 751 // in the app process.
751 // This is in contrast to OpenAppFromIframe, since here the popup will not be 752 // This is in contrast to OpenAppFromIframe, since here the popup will not be
752 // missing special permissions and should be scriptable from the iframe. 753 // missing special permissions and should be scriptable from the iframe.
753 // See http://crbug.com/92669 for more details. 754 // See http://crbug.com/92669 for more details.
754 IN_PROC_BROWSER_TEST_F(AppApiTest, OpenWebPopupFromWebIframe) { 755 IN_PROC_BROWSER_TEST_F(AppApiTest, OpenWebPopupFromWebIframe) {
755 extensions::ProcessMap* process_map = extensions::ExtensionSystem::Get( 756 extensions::ProcessMap* process_map =
756 browser()->profile())->extension_service()->process_map(); 757 extensions::ProcessMap::Get(browser()->profile());
757 758
758 host_resolver()->AddRule("*", "127.0.0.1"); 759 host_resolver()->AddRule("*", "127.0.0.1");
759 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 760 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
760 761
761 GURL base_url = GetTestBaseURL("app_process"); 762 GURL base_url = GetTestBaseURL("app_process");
762 763
763 // Load app and start URL (in the app). 764 // Load app and start URL (in the app).
764 const Extension* app = 765 const Extension* app =
765 LoadExtension(test_data_dir_.AppendASCII("app_process")); 766 LoadExtension(test_data_dir_.AppendASCII("app_process"));
766 ASSERT_TRUE(app); 767 ASSERT_TRUE(app);
(...skipping 16 matching lines...) Expand all
783 EXPECT_EQ(process, popup_host->GetProcess()); 784 EXPECT_EQ(process, popup_host->GetProcess());
784 } 785 }
785 786
786 // http://crbug.com/118502 787 // http://crbug.com/118502
787 #if defined(OS_MACOSX) || defined(OS_LINUX) 788 #if defined(OS_MACOSX) || defined(OS_LINUX)
788 #define MAYBE_ReloadAppAfterCrash DISABLED_ReloadAppAfterCrash 789 #define MAYBE_ReloadAppAfterCrash DISABLED_ReloadAppAfterCrash
789 #else 790 #else
790 #define MAYBE_ReloadAppAfterCrash ReloadAppAfterCrash 791 #define MAYBE_ReloadAppAfterCrash ReloadAppAfterCrash
791 #endif 792 #endif
792 IN_PROC_BROWSER_TEST_F(AppApiTest, MAYBE_ReloadAppAfterCrash) { 793 IN_PROC_BROWSER_TEST_F(AppApiTest, MAYBE_ReloadAppAfterCrash) {
793 extensions::ProcessMap* process_map = extensions::ExtensionSystem::Get( 794 extensions::ProcessMap* process_map =
794 browser()->profile())->extension_service()->process_map(); 795 extensions::ProcessMap::Get(browser()->profile());
795 796
796 host_resolver()->AddRule("*", "127.0.0.1"); 797 host_resolver()->AddRule("*", "127.0.0.1");
797 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 798 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
798 799
799 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app_process"))); 800 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app_process")));
800 801
801 GURL base_url = GetTestBaseURL("app_process"); 802 GURL base_url = GetTestBaseURL("app_process");
802 803
803 // Load the app, chrome.app.isInstalled should be true. 804 // Load the app, chrome.app.isInstalled should be true.
804 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html")); 805 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html"));
(...skipping 20 matching lines...) Expand all
825 contents, 826 contents,
826 "window.domAutomationController.send(chrome.app.isInstalled)", 827 "window.domAutomationController.send(chrome.app.isInstalled)",
827 &is_installed)); 828 &is_installed));
828 ASSERT_TRUE(is_installed); 829 ASSERT_TRUE(is_installed);
829 } 830 }
830 831
831 // Test that a cross-process navigation away from a hosted app stays in the same 832 // Test that a cross-process navigation away from a hosted app stays in the same
832 // BrowsingInstance, so that postMessage calls to the app's other windows still 833 // BrowsingInstance, so that postMessage calls to the app's other windows still
833 // work. 834 // work.
834 IN_PROC_BROWSER_TEST_F(AppApiTest, SameBrowsingInstanceAfterSwap) { 835 IN_PROC_BROWSER_TEST_F(AppApiTest, SameBrowsingInstanceAfterSwap) {
835 extensions::ProcessMap* process_map = extensions::ExtensionSystem::Get( 836 extensions::ProcessMap* process_map =
836 browser()->profile())->extension_service()->process_map(); 837 extensions::ProcessMap::Get(browser()->profile());
837 838
838 host_resolver()->AddRule("*", "127.0.0.1"); 839 host_resolver()->AddRule("*", "127.0.0.1");
839 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 840 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
840 841
841 GURL base_url = GetTestBaseURL("app_process"); 842 GURL base_url = GetTestBaseURL("app_process");
842 843
843 // Load app and start URL (in the app). 844 // Load app and start URL (in the app).
844 const Extension* app = 845 const Extension* app =
845 LoadExtension(test_data_dir_.AppendASCII("app_process")); 846 LoadExtension(test_data_dir_.AppendASCII("app_process"));
846 ASSERT_TRUE(app); 847 ASSERT_TRUE(app);
(...skipping 18 matching lines...) Expand all
865 // Navigate the popup to another process outside the app. 866 // Navigate the popup to another process outside the app.
866 GURL non_app_url(base_url.Resolve("path3/empty.html")); 867 GURL non_app_url(base_url.Resolve("path3/empty.html"));
867 ui_test_utils::NavigateToURL(active_browser_list->get(1), non_app_url); 868 ui_test_utils::NavigateToURL(active_browser_list->get(1), non_app_url);
868 SiteInstance* new_instance = popup_contents->GetSiteInstance(); 869 SiteInstance* new_instance = popup_contents->GetSiteInstance();
869 EXPECT_NE(app_instance, new_instance); 870 EXPECT_NE(app_instance, new_instance);
870 871
871 // It should still be in the same BrowsingInstance, allowing postMessage to 872 // It should still be in the same BrowsingInstance, allowing postMessage to
872 // work. 873 // work.
873 EXPECT_TRUE(app_instance->IsRelatedSiteInstance(new_instance)); 874 EXPECT_TRUE(app_instance->IsRelatedSiteInstance(new_instance));
874 } 875 }
OLDNEW
« no previous file with comments | « chrome/browser/chrome_content_browser_client.cc ('k') | chrome/browser/extensions/extension_crash_recovery_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698