| 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/utf_string_conversions.h" | 5 #include "base/utf_string_conversions.h" |
| 6 #include "chrome/browser/extensions/extension_apitest.h" | 6 #include "chrome/browser/extensions/extension_apitest.h" |
| 7 #include "chrome/browser/extensions/extension_host.h" | 7 #include "chrome/browser/extensions/extension_host.h" |
| 8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
| 9 #include "chrome/browser/extensions/process_map.h" | 9 #include "chrome/browser/extensions/process_map.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "content/public/browser/navigation_entry.h" | 21 #include "content/public/browser/navigation_entry.h" |
| 22 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
| 23 #include "content/public/browser/render_process_host.h" | 23 #include "content/public/browser/render_process_host.h" |
| 24 #include "content/public/browser/web_contents.h" | 24 #include "content/public/browser/web_contents.h" |
| 25 #include "content/test/test_navigation_observer.h" | 25 #include "content/test/test_navigation_observer.h" |
| 26 #include "net/base/mock_host_resolver.h" | 26 #include "net/base/mock_host_resolver.h" |
| 27 | 27 |
| 28 using content::NavigationController; | 28 using content::NavigationController; |
| 29 using content::WebContents; | 29 using content::WebContents; |
| 30 | 30 |
| 31 class AppApiTest : public ExtensionApiTest { | |
| 32 protected: | |
| 33 // Gets the base URL for files for a specific test, making sure that it uses | |
| 34 // "localhost" as the hostname, since that is what the extent is declared | |
| 35 // as in the test apps manifests. | |
| 36 GURL GetTestBaseURL(std::string test_directory) { | |
| 37 GURL::Replacements replace_host; | |
| 38 std::string host_str("localhost"); // must stay in scope with replace_host | |
| 39 replace_host.SetHostStr(host_str); | |
| 40 GURL base_url = test_server()->GetURL( | |
| 41 "files/extensions/api_test/" + test_directory + "/"); | |
| 42 return base_url.ReplaceComponents(replace_host); | |
| 43 } | |
| 44 }; | |
| 45 | |
| 46 // Simulates a page calling window.open on an URL, and waits for the navigation. | 31 // Simulates a page calling window.open on an URL, and waits for the navigation. |
| 47 static void WindowOpenHelper(Browser* browser, | 32 static void WindowOpenHelper(Browser* browser, |
| 48 RenderViewHost* opener_host, | 33 RenderViewHost* opener_host, |
| 49 const GURL& url, | 34 const GURL& url, |
| 50 bool newtab_process_should_equal_opener) { | 35 bool newtab_process_should_equal_opener) { |
| 51 ui_test_utils::WindowedNotificationObserver observer( | 36 ui_test_utils::WindowedNotificationObserver observer( |
| 52 content::NOTIFICATION_LOAD_STOP, | 37 content::NOTIFICATION_LOAD_STOP, |
| 53 content::NotificationService::AllSources()); | 38 content::NotificationService::AllSources()); |
| 54 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript( | 39 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript( |
| 55 opener_host, L"", L"window.open('" + UTF8ToWide(url.spec()) + L"');")); | 40 opener_host, L"", L"window.open('" + UTF8ToWide(url.spec()) + L"');")); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 80 L"window.addEventListener('unload', function() {" | 65 L"window.addEventListener('unload', function() {" |
| 81 L" window.domAutomationController.send(true);" | 66 L" window.domAutomationController.send(true);" |
| 82 L"}, false);" | 67 L"}, false);" |
| 83 L"window.location = '" + UTF8ToWide(url.spec()) + L"';", | 68 L"window.location = '" + UTF8ToWide(url.spec()) + L"';", |
| 84 &result)); | 69 &result)); |
| 85 ASSERT_TRUE(result); | 70 ASSERT_TRUE(result); |
| 86 observer.Wait(); | 71 observer.Wait(); |
| 87 EXPECT_EQ(url, contents->GetController().GetLastCommittedEntry()->GetURL()); | 72 EXPECT_EQ(url, contents->GetController().GetLastCommittedEntry()->GetURL()); |
| 88 } | 73 } |
| 89 | 74 |
| 75 class AppApiTest : public ExtensionApiTest { |
| 76 protected: |
| 77 // Gets the base URL for files for a specific test, making sure that it uses |
| 78 // "localhost" as the hostname, since that is what the extent is declared |
| 79 // as in the test apps manifests. |
| 80 GURL GetTestBaseURL(std::string test_directory) { |
| 81 GURL::Replacements replace_host; |
| 82 std::string host_str("localhost"); // must stay in scope with replace_host |
| 83 replace_host.SetHostStr(host_str); |
| 84 GURL base_url = test_server()->GetURL( |
| 85 "files/extensions/api_test/" + test_directory + "/"); |
| 86 return base_url.ReplaceComponents(replace_host); |
| 87 } |
| 88 |
| 89 // Pass flags to make testing apps easier. |
| 90 void SetUpCommandLine(CommandLine* command_line) { |
| 91 ExtensionApiTest::SetUpCommandLine(command_line); |
| 92 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 93 switches::kDisablePopupBlocking); |
| 94 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 95 switches::kAllowHTTPBackgroundPage); |
| 96 } |
| 97 |
| 98 // Helper function to test that independent tabs of the named app are loaded |
| 99 // into separate processes. |
| 100 void TestAppInstancesHelper(std::string app_name) { |
| 101 LOG(INFO) << "Start of test."; |
| 102 |
| 103 extensions::ProcessMap* process_map = |
| 104 browser()->profile()->GetExtensionService()->process_map(); |
| 105 |
| 106 host_resolver()->AddRule("*", "127.0.0.1"); |
| 107 ASSERT_TRUE(test_server()->Start()); |
| 108 |
| 109 ASSERT_TRUE(LoadExtension( |
| 110 test_data_dir_.AppendASCII(app_name))); |
| 111 |
| 112 // Open two tabs in the app, one outside it. |
| 113 GURL base_url = GetTestBaseURL(app_name); |
| 114 |
| 115 // Test both opening a URL in a new tab, and opening a tab and then |
| 116 // navigating it. Either way, app tabs should be considered extension |
| 117 // processes, but they have no elevated privileges and thus should not |
| 118 // have WebUI bindings. |
| 119 ui_test_utils::NavigateToURLWithDisposition( |
| 120 browser(), base_url.Resolve("path1/empty.html"), NEW_FOREGROUND_TAB, |
| 121 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 122 LOG(INFO) << "Nav 1."; |
| 123 EXPECT_TRUE(process_map->Contains( |
| 124 browser()->GetWebContentsAt(1)->GetRenderProcessHost()->GetID())); |
| 125 EXPECT_FALSE(browser()->GetWebContentsAt(1)->GetWebUI()); |
| 126 |
| 127 ui_test_utils::WindowedNotificationObserver tab_added_observer( |
| 128 content::NOTIFICATION_TAB_ADDED, |
| 129 content::NotificationService::AllSources()); |
| 130 browser()->NewTab(); |
| 131 tab_added_observer.Wait(); |
| 132 LOG(INFO) << "New tab."; |
| 133 ui_test_utils::NavigateToURL(browser(), |
| 134 base_url.Resolve("path2/empty.html")); |
| 135 LOG(INFO) << "Nav 2."; |
| 136 EXPECT_TRUE(process_map->Contains( |
| 137 browser()->GetWebContentsAt(2)->GetRenderProcessHost()->GetID())); |
| 138 EXPECT_FALSE(browser()->GetWebContentsAt(2)->GetWebUI()); |
| 139 |
| 140 // We should have opened 2 new extension tabs. Including the original blank |
| 141 // tab, we now have 3 tabs. The two app tabs should not be in the same |
| 142 // process, since they do not have the background permission. (Thus, we |
| 143 // want to separate them to improve responsiveness.) |
| 144 ASSERT_EQ(3, browser()->tab_count()); |
| 145 RenderViewHost* host1 = browser()->GetWebContentsAt(1)->GetRenderViewHost(); |
| 146 RenderViewHost* host2 = browser()->GetWebContentsAt(2)->GetRenderViewHost(); |
| 147 EXPECT_NE(host1->process(), host2->process()); |
| 148 |
| 149 // Opening tabs with window.open should keep the page in the opener's |
| 150 // process. |
| 151 ASSERT_EQ(1u, BrowserList::GetBrowserCount(browser()->profile())); |
| 152 WindowOpenHelper(browser(), host1, |
| 153 base_url.Resolve("path1/empty.html"), true); |
| 154 LOG(INFO) << "WindowOpenHelper 1."; |
| 155 WindowOpenHelper(browser(), host2, |
| 156 base_url.Resolve("path2/empty.html"), true); |
| 157 LOG(INFO) << "End of test."; |
| 158 } |
| 159 }; |
| 160 |
| 161 // Tests that hosted apps with the background permission get a process-per-app |
| 162 // model, since all pages need to be able to script the background page. |
| 90 IN_PROC_BROWSER_TEST_F(AppApiTest, AppProcess) { | 163 IN_PROC_BROWSER_TEST_F(AppApiTest, AppProcess) { |
| 91 LOG(INFO) << "Start of test."; | 164 LOG(INFO) << "Start of test."; |
| 92 | 165 |
| 93 CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 94 switches::kDisablePopupBlocking); | |
| 95 | |
| 96 extensions::ProcessMap* process_map = | 166 extensions::ProcessMap* process_map = |
| 97 browser()->profile()->GetExtensionService()->process_map(); | 167 browser()->profile()->GetExtensionService()->process_map(); |
| 98 | 168 |
| 99 host_resolver()->AddRule("*", "127.0.0.1"); | 169 host_resolver()->AddRule("*", "127.0.0.1"); |
| 100 ASSERT_TRUE(test_server()->Start()); | 170 ASSERT_TRUE(test_server()->Start()); |
| 101 | 171 |
| 102 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app_process"))); | 172 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app_process"))); |
| 103 | 173 |
| 104 LOG(INFO) << "Loaded extension."; | 174 LOG(INFO) << "Loaded extension."; |
| 105 | 175 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 L"window.domAutomationController.send(window.opener != null)", | 263 L"window.domAutomationController.send(window.opener != null)", |
| 194 &windowOpenerValid)); | 264 &windowOpenerValid)); |
| 195 ASSERT_TRUE(windowOpenerValid); | 265 ASSERT_TRUE(windowOpenerValid); |
| 196 | 266 |
| 197 LOG(INFO) << "End of test."; | 267 LOG(INFO) << "End of test."; |
| 198 } | 268 } |
| 199 | 269 |
| 200 // Test that hosted apps without the background permission use a process per app | 270 // Test that hosted apps without the background permission use a process per app |
| 201 // instance model, such that separate instances are in separate processes. | 271 // instance model, such that separate instances are in separate processes. |
| 202 IN_PROC_BROWSER_TEST_F(AppApiTest, AppProcessInstances) { | 272 IN_PROC_BROWSER_TEST_F(AppApiTest, AppProcessInstances) { |
| 203 LOG(INFO) << "Start of test."; | 273 TestAppInstancesHelper("app_process_instances"); |
| 274 } |
| 204 | 275 |
| 205 CommandLine::ForCurrentProcess()->AppendSwitch( | 276 // Test that hosted apps with the background permission but that set |
| 206 switches::kDisablePopupBlocking); | 277 // allow_js_access to false also use a process per app instance model. |
| 207 | 278 // Separate instances should be in separate processes. |
| 208 extensions::ProcessMap* process_map = | 279 IN_PROC_BROWSER_TEST_F(AppApiTest, AppProcessBackgroundInstances) { |
| 209 browser()->profile()->GetExtensionService()->process_map(); | 280 TestAppInstancesHelper("app_process_background_instances"); |
| 210 | |
| 211 host_resolver()->AddRule("*", "127.0.0.1"); | |
| 212 ASSERT_TRUE(test_server()->Start()); | |
| 213 | |
| 214 ASSERT_TRUE(LoadExtension( | |
| 215 test_data_dir_.AppendASCII("app_process_instances"))); | |
| 216 | |
| 217 // Open two tabs in the app, one outside it. | |
| 218 GURL base_url = GetTestBaseURL("app_process_instances"); | |
| 219 | |
| 220 // Test both opening a URL in a new tab, and opening a tab and then navigating | |
| 221 // it. Either way, app tabs should be considered extension processes, but | |
| 222 // they have no elevated privileges and thus should not have WebUI bindings. | |
| 223 ui_test_utils::NavigateToURLWithDisposition( | |
| 224 browser(), base_url.Resolve("path1/empty.html"), NEW_FOREGROUND_TAB, | |
| 225 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | |
| 226 LOG(INFO) << "Nav 1."; | |
| 227 EXPECT_TRUE(process_map->Contains( | |
| 228 browser()->GetWebContentsAt(1)->GetRenderProcessHost()->GetID())); | |
| 229 EXPECT_FALSE(browser()->GetWebContentsAt(1)->GetWebUI()); | |
| 230 | |
| 231 ui_test_utils::WindowedNotificationObserver tab_added_observer( | |
| 232 content::NOTIFICATION_TAB_ADDED, | |
| 233 content::NotificationService::AllSources()); | |
| 234 browser()->NewTab(); | |
| 235 tab_added_observer.Wait(); | |
| 236 LOG(INFO) << "New tab."; | |
| 237 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path2/empty.html")); | |
| 238 LOG(INFO) << "Nav 2."; | |
| 239 EXPECT_TRUE(process_map->Contains( | |
| 240 browser()->GetWebContentsAt(2)->GetRenderProcessHost()->GetID())); | |
| 241 EXPECT_FALSE(browser()->GetWebContentsAt(2)->GetWebUI()); | |
| 242 | |
| 243 // We should have opened 2 new extension tabs. Including the original blank | |
| 244 // tab, we now have 3 tabs. The two app tabs should not be in the same | |
| 245 // process, since they do not have the background permission. (Thus, we want | |
| 246 // to separate them to improve responsiveness.) | |
| 247 ASSERT_EQ(3, browser()->tab_count()); | |
| 248 RenderViewHost* host1 = browser()->GetWebContentsAt(1)->GetRenderViewHost(); | |
| 249 RenderViewHost* host2 = browser()->GetWebContentsAt(2)->GetRenderViewHost(); | |
| 250 EXPECT_NE(host1->process(), host2->process()); | |
| 251 | |
| 252 // Opening tabs with window.open should keep the page in the opener's process. | |
| 253 ASSERT_EQ(1u, BrowserList::GetBrowserCount(browser()->profile())); | |
| 254 WindowOpenHelper(browser(), host1, | |
| 255 base_url.Resolve("path1/empty.html"), true); | |
| 256 LOG(INFO) << "WindowOpenHelper 1."; | |
| 257 WindowOpenHelper(browser(), host2, | |
| 258 base_url.Resolve("path2/empty.html"), true); | |
| 259 LOG(INFO) << "End of test."; | |
| 260 } | 281 } |
| 261 | 282 |
| 262 // Tests that bookmark apps do not use the app process model and are treated | 283 // Tests that bookmark apps do not use the app process model and are treated |
| 263 // like normal web pages instead. http://crbug.com/104636. | 284 // like normal web pages instead. http://crbug.com/104636. |
| 264 IN_PROC_BROWSER_TEST_F(AppApiTest, BookmarkAppGetsNormalProcess) { | 285 IN_PROC_BROWSER_TEST_F(AppApiTest, BookmarkAppGetsNormalProcess) { |
| 265 CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 266 switches::kDisablePopupBlocking); | |
| 267 | |
| 268 ExtensionService* service = browser()->profile()->GetExtensionService(); | 286 ExtensionService* service = browser()->profile()->GetExtensionService(); |
| 269 extensions::ProcessMap* process_map = service->process_map(); | 287 extensions::ProcessMap* process_map = service->process_map(); |
| 270 | 288 |
| 271 host_resolver()->AddRule("*", "127.0.0.1"); | 289 host_resolver()->AddRule("*", "127.0.0.1"); |
| 272 ASSERT_TRUE(test_server()->Start()); | 290 ASSERT_TRUE(test_server()->Start()); |
| 273 GURL base_url = GetTestBaseURL("app_process"); | 291 GURL base_url = GetTestBaseURL("app_process"); |
| 274 | 292 |
| 275 // Load an app as a bookmark app. | 293 // Load an app as a bookmark app. |
| 276 std::string error; | 294 std::string error; |
| 277 scoped_refptr<const Extension> extension(extension_file_util::LoadExtension( | 295 scoped_refptr<const Extension> extension(extension_file_util::LoadExtension( |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 // 3. page2 redirects back to a page in the app | 356 // 3. page2 redirects back to a page in the app |
| 339 // The final navigation should end up in the app process. | 357 // The final navigation should end up in the app process. |
| 340 // See http://crbug.com/61757 | 358 // See http://crbug.com/61757 |
| 341 // This test doesn't complete on WebKit Win (dbg). See crbug.com/108853. | 359 // This test doesn't complete on WebKit Win (dbg). See crbug.com/108853. |
| 342 #if defined(OS_WIN) && !defined(NDEBUG) | 360 #if defined(OS_WIN) && !defined(NDEBUG) |
| 343 #define MAYBE_AppProcessRedirectBack DISABLED_AppProcessRedirectBack | 361 #define MAYBE_AppProcessRedirectBack DISABLED_AppProcessRedirectBack |
| 344 #else | 362 #else |
| 345 #define MAYBE_AppProcessRedirectBack AppProcessRedirectBack | 363 #define MAYBE_AppProcessRedirectBack AppProcessRedirectBack |
| 346 #endif | 364 #endif |
| 347 IN_PROC_BROWSER_TEST_F(AppApiTest, MAYBE_AppProcessRedirectBack) { | 365 IN_PROC_BROWSER_TEST_F(AppApiTest, MAYBE_AppProcessRedirectBack) { |
| 348 CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 349 switches::kDisablePopupBlocking); | |
| 350 | |
| 351 host_resolver()->AddRule("*", "127.0.0.1"); | 366 host_resolver()->AddRule("*", "127.0.0.1"); |
| 352 ASSERT_TRUE(test_server()->Start()); | 367 ASSERT_TRUE(test_server()->Start()); |
| 353 | 368 |
| 354 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app_process"))); | 369 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app_process"))); |
| 355 | 370 |
| 356 // Open two tabs in the app. | 371 // Open two tabs in the app. |
| 357 GURL base_url = GetTestBaseURL("app_process"); | 372 GURL base_url = GetTestBaseURL("app_process"); |
| 358 | 373 |
| 359 browser()->NewTab(); | 374 browser()->NewTab(); |
| 360 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html")); | 375 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html")); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 381 EXPECT_EQ("/files/extensions/api_test/app_process/path1/empty.html", | 396 EXPECT_EQ("/files/extensions/api_test/app_process/path1/empty.html", |
| 382 browser()->GetWebContentsAt(2)->GetController(). | 397 browser()->GetWebContentsAt(2)->GetController(). |
| 383 GetLastCommittedEntry()->GetURL().path()); | 398 GetLastCommittedEntry()->GetURL().path()); |
| 384 EXPECT_EQ(browser()->GetWebContentsAt(1)->GetRenderProcessHost(), | 399 EXPECT_EQ(browser()->GetWebContentsAt(1)->GetRenderProcessHost(), |
| 385 browser()->GetWebContentsAt(2)->GetRenderProcessHost()); | 400 browser()->GetWebContentsAt(2)->GetRenderProcessHost()); |
| 386 } | 401 } |
| 387 | 402 |
| 388 // Ensure that reloading a URL after installing or uninstalling it as an app | 403 // Ensure that reloading a URL after installing or uninstalling it as an app |
| 389 // correctly swaps the process. (http://crbug.com/80621) | 404 // correctly swaps the process. (http://crbug.com/80621) |
| 390 IN_PROC_BROWSER_TEST_F(AppApiTest, ReloadIntoAppProcess) { | 405 IN_PROC_BROWSER_TEST_F(AppApiTest, ReloadIntoAppProcess) { |
| 391 CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 392 switches::kDisablePopupBlocking); | |
| 393 | |
| 394 extensions::ProcessMap* process_map = | 406 extensions::ProcessMap* process_map = |
| 395 browser()->profile()->GetExtensionService()->process_map(); | 407 browser()->profile()->GetExtensionService()->process_map(); |
| 396 | 408 |
| 397 host_resolver()->AddRule("*", "127.0.0.1"); | 409 host_resolver()->AddRule("*", "127.0.0.1"); |
| 398 ASSERT_TRUE(test_server()->Start()); | 410 ASSERT_TRUE(test_server()->Start()); |
| 399 | 411 |
| 400 // The app under test acts on URLs whose host is "localhost", | 412 // The app under test acts on URLs whose host is "localhost", |
| 401 // so the URLs we navigate to must have host "localhost". | 413 // so the URLs we navigate to must have host "localhost". |
| 402 GURL base_url = GetTestBaseURL("app_process"); | 414 GURL base_url = GetTestBaseURL("app_process"); |
| 403 | 415 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 EXPECT_FALSE(process_map->Contains( | 483 EXPECT_FALSE(process_map->Contains( |
| 472 contents->GetRenderProcessHost()->GetID())); | 484 contents->GetRenderProcessHost()->GetID())); |
| 473 } | 485 } |
| 474 | 486 |
| 475 // Tests that if we have a non-app process (path3/container.html) that has an | 487 // Tests that if we have a non-app process (path3/container.html) that has an |
| 476 // iframe with a URL in the app's extent (path1/iframe.html), then opening a | 488 // iframe with a URL in the app's extent (path1/iframe.html), then opening a |
| 477 // link from that iframe to a new window to a URL in the app's extent (path1/ | 489 // link from that iframe to a new window to a URL in the app's extent (path1/ |
| 478 // empty.html) results in the new window being in an app process. See | 490 // empty.html) results in the new window being in an app process. See |
| 479 // http://crbug.com/89272 for more details. | 491 // http://crbug.com/89272 for more details. |
| 480 IN_PROC_BROWSER_TEST_F(AppApiTest, OpenAppFromIframe) { | 492 IN_PROC_BROWSER_TEST_F(AppApiTest, OpenAppFromIframe) { |
| 481 CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 482 switches::kDisablePopupBlocking); | |
| 483 | |
| 484 extensions::ProcessMap* process_map = | 493 extensions::ProcessMap* process_map = |
| 485 browser()->profile()->GetExtensionService()->process_map(); | 494 browser()->profile()->GetExtensionService()->process_map(); |
| 486 | 495 |
| 487 host_resolver()->AddRule("*", "127.0.0.1"); | 496 host_resolver()->AddRule("*", "127.0.0.1"); |
| 488 ASSERT_TRUE(test_server()->Start()); | 497 ASSERT_TRUE(test_server()->Start()); |
| 489 | 498 |
| 490 GURL base_url = GetTestBaseURL("app_process"); | 499 GURL base_url = GetTestBaseURL("app_process"); |
| 491 | 500 |
| 492 // Load app and start URL (not in the app). | 501 // Load app and start URL (not in the app). |
| 493 const Extension* app = | 502 const Extension* app = |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 } | 578 } |
| 570 | 579 |
| 571 // Tests that if we have an app process (path1/container.html) with a non-app | 580 // Tests that if we have an app process (path1/container.html) with a non-app |
| 572 // iframe (path3/iframe.html), then opening a link from that iframe to a new | 581 // iframe (path3/iframe.html), then opening a link from that iframe to a new |
| 573 // window to a same-origin non-app URL (path3/empty.html) should keep the window | 582 // window to a same-origin non-app URL (path3/empty.html) should keep the window |
| 574 // in the app process. | 583 // in the app process. |
| 575 // This is in contrast to OpenAppFromIframe, since here the popup will not be | 584 // This is in contrast to OpenAppFromIframe, since here the popup will not be |
| 576 // missing special permissions and should be scriptable from the iframe. | 585 // missing special permissions and should be scriptable from the iframe. |
| 577 // See http://crbug.com/92669 for more details. | 586 // See http://crbug.com/92669 for more details. |
| 578 IN_PROC_BROWSER_TEST_F(AppApiTest, OpenWebPopupFromWebIframe) { | 587 IN_PROC_BROWSER_TEST_F(AppApiTest, OpenWebPopupFromWebIframe) { |
| 579 CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 580 switches::kDisablePopupBlocking); | |
| 581 | |
| 582 extensions::ProcessMap* process_map = | 588 extensions::ProcessMap* process_map = |
| 583 browser()->profile()->GetExtensionService()->process_map(); | 589 browser()->profile()->GetExtensionService()->process_map(); |
| 584 | 590 |
| 585 host_resolver()->AddRule("*", "127.0.0.1"); | 591 host_resolver()->AddRule("*", "127.0.0.1"); |
| 586 ASSERT_TRUE(test_server()->Start()); | 592 ASSERT_TRUE(test_server()->Start()); |
| 587 | 593 |
| 588 GURL base_url = GetTestBaseURL("app_process"); | 594 GURL base_url = GetTestBaseURL("app_process"); |
| 589 | 595 |
| 590 // Load app and start URL (in the app). | 596 // Load app and start URL (in the app). |
| 591 const Extension* app = | 597 const Extension* app = |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 &browser()->GetSelectedTabContentsWrapper()->web_contents()-> | 664 &browser()->GetSelectedTabContentsWrapper()->web_contents()-> |
| 659 GetController())); | 665 GetController())); |
| 660 browser()->Reload(CURRENT_TAB); | 666 browser()->Reload(CURRENT_TAB); |
| 661 observer.Wait(); | 667 observer.Wait(); |
| 662 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 668 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 663 contents->GetRenderViewHost(), L"", | 669 contents->GetRenderViewHost(), L"", |
| 664 L"window.domAutomationController.send(chrome.app.isInstalled)", | 670 L"window.domAutomationController.send(chrome.app.isInstalled)", |
| 665 &is_installed)); | 671 &is_installed)); |
| 666 ASSERT_TRUE(is_installed); | 672 ASSERT_TRUE(is_installed); |
| 667 } | 673 } |
| OLD | NEW |