| 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 "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_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" | 10 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 GURL GetTestBaseURL(const std::string& test_directory) { | 50 GURL GetTestBaseURL(const std::string& test_directory) { |
| 51 GURL::Replacements replace_host; | 51 GURL::Replacements replace_host; |
| 52 std::string host_str("localhost"); // must stay in scope with replace_host | 52 std::string host_str("localhost"); // must stay in scope with replace_host |
| 53 replace_host.SetHostStr(host_str); | 53 replace_host.SetHostStr(host_str); |
| 54 GURL base_url = embedded_test_server()->GetURL( | 54 GURL base_url = embedded_test_server()->GetURL( |
| 55 "/extensions/api_test/" + test_directory + "/"); | 55 "/extensions/api_test/" + test_directory + "/"); |
| 56 return base_url.ReplaceComponents(replace_host); | 56 return base_url.ReplaceComponents(replace_host); |
| 57 } | 57 } |
| 58 | 58 |
| 59 // Pass flags to make testing apps easier. | 59 // Pass flags to make testing apps easier. |
| 60 void SetUpCommandLine(CommandLine* command_line) override { | 60 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 61 ExtensionApiTest::SetUpCommandLine(command_line); | 61 ExtensionApiTest::SetUpCommandLine(command_line); |
| 62 CommandLine::ForCurrentProcess()->AppendSwitch( | 62 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 63 switches::kDisablePopupBlocking); | 63 switches::kDisablePopupBlocking); |
| 64 CommandLine::ForCurrentProcess()->AppendSwitch( | 64 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 65 extensions::switches::kAllowHTTPBackgroundPage); | 65 extensions::switches::kAllowHTTPBackgroundPage); |
| 66 } | 66 } |
| 67 | 67 |
| 68 // Helper function to test that independent tabs of the named app are loaded | 68 // Helper function to test that independent tabs of the named app are loaded |
| 69 // into separate processes. | 69 // into separate processes. |
| 70 void TestAppInstancesHelper(const std::string& app_name) { | 70 void TestAppInstancesHelper(const std::string& app_name) { |
| 71 LOG(INFO) << "Start of test."; | 71 LOG(INFO) << "Start of test."; |
| 72 | 72 |
| 73 extensions::ProcessMap* process_map = | 73 extensions::ProcessMap* process_map = |
| 74 extensions::ProcessMap::Get(browser()->profile()); | 74 extensions::ProcessMap::Get(browser()->profile()); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 LOG(INFO) << "WindowOpenHelper 1."; | 127 LOG(INFO) << "WindowOpenHelper 1."; |
| 128 OpenWindow(tab2, base_url.Resolve("path2/empty.html"), true, NULL); | 128 OpenWindow(tab2, base_url.Resolve("path2/empty.html"), true, NULL); |
| 129 LOG(INFO) << "End of test."; | 129 LOG(INFO) << "End of test."; |
| 130 UnloadExtension(extension->id()); | 130 UnloadExtension(extension->id()); |
| 131 } | 131 } |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 // Omits the disable-popup-blocking flag so we can cover that case. | 134 // Omits the disable-popup-blocking flag so we can cover that case. |
| 135 class BlockedAppApiTest : public AppApiTest { | 135 class BlockedAppApiTest : public AppApiTest { |
| 136 protected: | 136 protected: |
| 137 void SetUpCommandLine(CommandLine* command_line) override { | 137 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 138 ExtensionApiTest::SetUpCommandLine(command_line); | 138 ExtensionApiTest::SetUpCommandLine(command_line); |
| 139 CommandLine::ForCurrentProcess()->AppendSwitch( | 139 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 140 extensions::switches::kAllowHTTPBackgroundPage); | 140 extensions::switches::kAllowHTTPBackgroundPage); |
| 141 } | 141 } |
| 142 }; | 142 }; |
| 143 | 143 |
| 144 // Tests that hosted apps with the background permission get a process-per-app | 144 // Tests that hosted apps with the background permission get a process-per-app |
| 145 // model, since all pages need to be able to script the background page. | 145 // model, since all pages need to be able to script the background page. |
| 146 // http://crbug.com/172750 | 146 // http://crbug.com/172750 |
| 147 IN_PROC_BROWSER_TEST_F(AppApiTest, DISABLED_AppProcess) { | 147 IN_PROC_BROWSER_TEST_F(AppApiTest, DISABLED_AppProcess) { |
| 148 LOG(INFO) << "Start of test."; | 148 LOG(INFO) << "Start of test."; |
| 149 | 149 |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 } | 592 } |
| 593 | 593 |
| 594 // Tests that if we have a non-app process (path3/container.html) that has an | 594 // Tests that if we have a non-app process (path3/container.html) that has an |
| 595 // iframe with a URL in the app's extent (path1/iframe.html), then opening a | 595 // iframe with a URL in the app's extent (path1/iframe.html), then opening a |
| 596 // 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/ |
| 597 // 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 |
| 598 // http://crbug.com/89272 for more details. | 598 // http://crbug.com/89272 for more details. |
| 599 IN_PROC_BROWSER_TEST_F(AppApiTest, OpenAppFromIframe) { | 599 IN_PROC_BROWSER_TEST_F(AppApiTest, OpenAppFromIframe) { |
| 600 #if defined(OS_WIN) && defined(USE_ASH) | 600 #if defined(OS_WIN) && defined(USE_ASH) |
| 601 // 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). |
| 602 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 602 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 603 switches::kAshBrowserTests)) |
| 603 return; | 604 return; |
| 604 #endif | 605 #endif |
| 605 | 606 |
| 606 extensions::ProcessMap* process_map = | 607 extensions::ProcessMap* process_map = |
| 607 extensions::ProcessMap::Get(browser()->profile()); | 608 extensions::ProcessMap::Get(browser()->profile()); |
| 608 | 609 |
| 609 host_resolver()->AddRule("*", "127.0.0.1"); | 610 host_resolver()->AddRule("*", "127.0.0.1"); |
| 610 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 611 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 611 | 612 |
| 612 GURL base_url = GetTestBaseURL("app_process"); | 613 GURL base_url = GetTestBaseURL("app_process"); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 // Navigate the popup to another process outside the app. | 861 // Navigate the popup to another process outside the app. |
| 861 GURL non_app_url(base_url.Resolve("path3/empty.html")); | 862 GURL non_app_url(base_url.Resolve("path3/empty.html")); |
| 862 ui_test_utils::NavigateToURL(active_browser_list->get(1), non_app_url); | 863 ui_test_utils::NavigateToURL(active_browser_list->get(1), non_app_url); |
| 863 SiteInstance* new_instance = popup_contents->GetSiteInstance(); | 864 SiteInstance* new_instance = popup_contents->GetSiteInstance(); |
| 864 EXPECT_NE(app_instance, new_instance); | 865 EXPECT_NE(app_instance, new_instance); |
| 865 | 866 |
| 866 // It should still be in the same BrowsingInstance, allowing postMessage to | 867 // It should still be in the same BrowsingInstance, allowing postMessage to |
| 867 // work. | 868 // work. |
| 868 EXPECT_TRUE(app_instance->IsRelatedSiteInstance(new_instance)); | 869 EXPECT_TRUE(app_instance->IsRelatedSiteInstance(new_instance)); |
| 869 } | 870 } |
| OLD | NEW |