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 "chrome/browser/extensions/extension_apitest.h" | 5 #include "chrome/browser/extensions/extension_apitest.h" |
6 #include "chrome/browser/extensions/extension_host.h" | 6 #include "chrome/browser/extensions/extension_host.h" |
7 #include "chrome/browser/extensions/extension_service.h" | 7 #include "chrome/browser/extensions/extension_service.h" |
8 #include "chrome/browser/extensions/extension_system.h" | 8 #include "chrome/browser/extensions/extension_system.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 "chrome/common/extensions/extension_file_util.h" | 21 #include "chrome/common/extensions/extension_file_util.h" |
22 #include "chrome/test/base/ui_test_utils.h" | 22 #include "chrome/test/base/ui_test_utils.h" |
23 #include "content/public/browser/navigation_entry.h" | 23 #include "content/public/browser/navigation_entry.h" |
24 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
25 #include "content/public/browser/render_process_host.h" | 25 #include "content/public/browser/render_process_host.h" |
26 #include "content/public/browser/render_view_host.h" | 26 #include "content/public/browser/render_view_host.h" |
27 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
28 #include "content/public/test/browser_test_utils.h" | 28 #include "content/public/test/browser_test_utils.h" |
29 #include "content/public/test/test_navigation_observer.h" | 29 #include "content/public/test/test_navigation_observer.h" |
30 #include "net/dns/mock_host_resolver.h" | 30 #include "net/dns/mock_host_resolver.h" |
| 31 #include "net/test/embedded_test_server/embedded_test_server.h" |
31 #include "sync/api/string_ordinal.h" | 32 #include "sync/api/string_ordinal.h" |
32 | 33 |
33 using content::NavigationController; | 34 using content::NavigationController; |
34 using content::RenderViewHost; | 35 using content::RenderViewHost; |
35 using content::WebContents; | 36 using content::WebContents; |
36 using extensions::Extension; | 37 using extensions::Extension; |
37 | 38 |
38 class AppApiTest : public ExtensionApiTest { | 39 class AppApiTest : public ExtensionApiTest { |
39 protected: | 40 protected: |
40 // Gets the base URL for files for a specific test, making sure that it uses | 41 // Gets the base URL for files for a specific test, making sure that it uses |
41 // "localhost" as the hostname, since that is what the extent is declared | 42 // "localhost" as the hostname, since that is what the extent is declared |
42 // as in the test apps manifests. | 43 // as in the test apps manifests. |
43 GURL GetTestBaseURL(std::string test_directory) { | 44 GURL GetTestBaseURL(std::string test_directory) { |
44 GURL::Replacements replace_host; | 45 GURL::Replacements replace_host; |
45 std::string host_str("localhost"); // must stay in scope with replace_host | 46 std::string host_str("localhost"); // must stay in scope with replace_host |
46 replace_host.SetHostStr(host_str); | 47 replace_host.SetHostStr(host_str); |
47 GURL base_url = test_server()->GetURL( | 48 GURL base_url = embedded_test_server()->GetURL( |
48 "files/extensions/api_test/" + test_directory + "/"); | 49 "/extensions/api_test/" + test_directory + "/"); |
49 return base_url.ReplaceComponents(replace_host); | 50 return base_url.ReplaceComponents(replace_host); |
50 } | 51 } |
51 | 52 |
52 // Pass flags to make testing apps easier. | 53 // Pass flags to make testing apps easier. |
53 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 54 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
54 ExtensionApiTest::SetUpCommandLine(command_line); | 55 ExtensionApiTest::SetUpCommandLine(command_line); |
55 CommandLine::ForCurrentProcess()->AppendSwitch( | 56 CommandLine::ForCurrentProcess()->AppendSwitch( |
56 switches::kDisablePopupBlocking); | 57 switches::kDisablePopupBlocking); |
57 CommandLine::ForCurrentProcess()->AppendSwitch( | 58 CommandLine::ForCurrentProcess()->AppendSwitch( |
58 switches::kAllowHTTPBackgroundPage); | 59 switches::kAllowHTTPBackgroundPage); |
59 } | 60 } |
60 | 61 |
61 // Helper function to test that independent tabs of the named app are loaded | 62 // Helper function to test that independent tabs of the named app are loaded |
62 // into separate processes. | 63 // into separate processes. |
63 void TestAppInstancesHelper(std::string app_name) { | 64 void TestAppInstancesHelper(std::string app_name) { |
64 LOG(INFO) << "Start of test."; | 65 LOG(INFO) << "Start of test."; |
65 | 66 |
66 extensions::ProcessMap* process_map = extensions::ExtensionSystem::Get( | 67 extensions::ProcessMap* process_map = extensions::ExtensionSystem::Get( |
67 browser()->profile())->extension_service()->process_map(); | 68 browser()->profile())->extension_service()->process_map(); |
68 | 69 |
69 host_resolver()->AddRule("*", "127.0.0.1"); | 70 host_resolver()->AddRule("*", "127.0.0.1"); |
70 ASSERT_TRUE(test_server()->Start()); | 71 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
71 | 72 |
72 ASSERT_TRUE(LoadExtension( | 73 ASSERT_TRUE(LoadExtension( |
73 test_data_dir_.AppendASCII(app_name))); | 74 test_data_dir_.AppendASCII(app_name))); |
74 const Extension* extension = GetSingleLoadedExtension(); | 75 const Extension* extension = GetSingleLoadedExtension(); |
75 | 76 |
76 // Open two tabs in the app, one outside it. | 77 // Open two tabs in the app, one outside it. |
77 GURL base_url = GetTestBaseURL(app_name); | 78 GURL base_url = GetTestBaseURL(app_name); |
78 | 79 |
79 // Test both opening a URL in a new tab, and opening a tab and then | 80 // Test both opening a URL in a new tab, and opening a tab and then |
80 // navigating it. Either way, app tabs should be considered extension | 81 // navigating it. Either way, app tabs should be considered extension |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 // Tests that hosted apps with the background permission get a process-per-app | 138 // Tests that hosted apps with the background permission get a process-per-app |
138 // model, since all pages need to be able to script the background page. | 139 // model, since all pages need to be able to script the background page. |
139 // http://crbug.com/172750 | 140 // http://crbug.com/172750 |
140 IN_PROC_BROWSER_TEST_F(AppApiTest, DISABLED_AppProcess) { | 141 IN_PROC_BROWSER_TEST_F(AppApiTest, DISABLED_AppProcess) { |
141 LOG(INFO) << "Start of test."; | 142 LOG(INFO) << "Start of test."; |
142 | 143 |
143 extensions::ProcessMap* process_map = extensions::ExtensionSystem::Get( | 144 extensions::ProcessMap* process_map = extensions::ExtensionSystem::Get( |
144 browser()->profile())->extension_service()->process_map(); | 145 browser()->profile())->extension_service()->process_map(); |
145 | 146 |
146 host_resolver()->AddRule("*", "127.0.0.1"); | 147 host_resolver()->AddRule("*", "127.0.0.1"); |
147 ASSERT_TRUE(test_server()->Start()); | 148 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
148 | 149 |
149 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app_process"))); | 150 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app_process"))); |
150 | 151 |
151 LOG(INFO) << "Loaded extension."; | 152 LOG(INFO) << "Loaded extension."; |
152 | 153 |
153 // Open two tabs in the app, one outside it. | 154 // Open two tabs in the app, one outside it. |
154 GURL base_url = GetTestBaseURL("app_process"); | 155 GURL base_url = GetTestBaseURL("app_process"); |
155 | 156 |
156 // Test both opening a URL in a new tab, and opening a tab and then navigating | 157 // Test both opening a URL in a new tab, and opening a tab and then navigating |
157 // it. Either way, app tabs should be considered extension processes, but | 158 // it. Either way, app tabs should be considered extension processes, but |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 #define MAYBE_BookmarkAppGetsNormalProcess DISABLED_BookmarkAppGetsNormalProcess | 285 #define MAYBE_BookmarkAppGetsNormalProcess DISABLED_BookmarkAppGetsNormalProcess |
285 #else | 286 #else |
286 #define MAYBE_BookmarkAppGetsNormalProcess BookmarkAppGetsNormalProcess | 287 #define MAYBE_BookmarkAppGetsNormalProcess BookmarkAppGetsNormalProcess |
287 #endif | 288 #endif |
288 IN_PROC_BROWSER_TEST_F(AppApiTest, MAYBE_BookmarkAppGetsNormalProcess) { | 289 IN_PROC_BROWSER_TEST_F(AppApiTest, MAYBE_BookmarkAppGetsNormalProcess) { |
289 ExtensionService* service = extensions::ExtensionSystem::Get( | 290 ExtensionService* service = extensions::ExtensionSystem::Get( |
290 browser()->profile())->extension_service(); | 291 browser()->profile())->extension_service(); |
291 extensions::ProcessMap* process_map = service->process_map(); | 292 extensions::ProcessMap* process_map = service->process_map(); |
292 | 293 |
293 host_resolver()->AddRule("*", "127.0.0.1"); | 294 host_resolver()->AddRule("*", "127.0.0.1"); |
294 ASSERT_TRUE(test_server()->Start()); | 295 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
295 GURL base_url = GetTestBaseURL("app_process"); | 296 GURL base_url = GetTestBaseURL("app_process"); |
296 | 297 |
297 // Load an app as a bookmark app. | 298 // Load an app as a bookmark app. |
298 std::string error; | 299 std::string error; |
299 scoped_refptr<const Extension> extension(extension_file_util::LoadExtension( | 300 scoped_refptr<const Extension> extension(extension_file_util::LoadExtension( |
300 test_data_dir_.AppendASCII("app_process"), | 301 test_data_dir_.AppendASCII("app_process"), |
301 extensions::Manifest::UNPACKED, | 302 extensions::Manifest::UNPACKED, |
302 Extension::FROM_BOOKMARK, | 303 Extension::FROM_BOOKMARK, |
303 &error)); | 304 &error)); |
304 service->OnExtensionInstalled(extension.get(), | 305 service->OnExtensionInstalled(extension.get(), |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 } | 365 } |
365 | 366 |
366 // Tests that app process switching works properly in the following scenario: | 367 // Tests that app process switching works properly in the following scenario: |
367 // 1. navigate to a page1 in the app | 368 // 1. navigate to a page1 in the app |
368 // 2. page1 redirects to a page2 outside the app extent (ie, "/server-redirect") | 369 // 2. page1 redirects to a page2 outside the app extent (ie, "/server-redirect") |
369 // 3. page2 redirects back to a page in the app | 370 // 3. page2 redirects back to a page in the app |
370 // The final navigation should end up in the app process. | 371 // The final navigation should end up in the app process. |
371 // See http://crbug.com/61757 | 372 // See http://crbug.com/61757 |
372 IN_PROC_BROWSER_TEST_F(AppApiTest, AppProcessRedirectBack) { | 373 IN_PROC_BROWSER_TEST_F(AppApiTest, AppProcessRedirectBack) { |
373 host_resolver()->AddRule("*", "127.0.0.1"); | 374 host_resolver()->AddRule("*", "127.0.0.1"); |
374 ASSERT_TRUE(test_server()->Start()); | 375 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
375 | 376 |
376 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app_process"))); | 377 ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app_process"))); |
377 | 378 |
378 // Open two tabs in the app. | 379 // Open two tabs in the app. |
379 GURL base_url = GetTestBaseURL("app_process"); | 380 GURL base_url = GetTestBaseURL("app_process"); |
380 | 381 |
381 chrome::NewTab(browser()); | 382 chrome::NewTab(browser()); |
382 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html")); | 383 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html")); |
383 chrome::NewTab(browser()); | 384 chrome::NewTab(browser()); |
384 // Wait until the second tab finishes its redirect train (2 hops). | 385 // Wait until the second tab finishes its redirect train (2 hops). |
385 // 1. We navigate to redirect.html | 386 // 1. We navigate to redirect.html |
386 // 2. Renderer navigates and finishes, counting as a load stop. | 387 // 2. Renderer navigates and finishes, counting as a load stop. |
387 // 3. Renderer issues the meta refresh to navigate to server-redirect. | 388 // 3. Renderer issues the meta refresh to navigate to server-redirect. |
388 // 4. Renderer is now in a "provisional load", waiting for navigation to | 389 // 4. Renderer is now in a "provisional load", waiting for navigation to |
389 // complete. | 390 // complete. |
390 // 5. Browser sees a redirect response from server-redirect to empty.html, and | 391 // 5. Browser sees a redirect response from server-redirect to empty.html, and |
391 // transfers that to a new navigation, using RequestTransferURL. | 392 // transfers that to a new navigation, using RequestTransferURL. |
392 // 6. Renderer navigates to empty.html, and finishes loading, counting as the | 393 // 6. Renderer navigates to empty.html, and finishes loading, counting as the |
393 // second load stop | 394 // second load stop |
394 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( | 395 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete( |
395 browser(), base_url.Resolve("path1/redirect.html"), 2); | 396 browser(), base_url.Resolve("path1/redirect.html"), 2); |
396 | 397 |
397 // 3 tabs, including the initial about:blank. The last 2 should be the same | 398 // 3 tabs, including the initial about:blank. The last 2 should be the same |
398 // process. | 399 // process. |
399 ASSERT_EQ(3, browser()->tab_strip_model()->count()); | 400 ASSERT_EQ(3, browser()->tab_strip_model()->count()); |
400 EXPECT_EQ("/files/extensions/api_test/app_process/path1/empty.html", | 401 EXPECT_EQ("/extensions/api_test/app_process/path1/empty.html", |
401 browser()->tab_strip_model()->GetWebContentsAt(2)-> | 402 browser()->tab_strip_model()->GetWebContentsAt(2)-> |
402 GetController().GetLastCommittedEntry()->GetURL().path()); | 403 GetController().GetLastCommittedEntry()->GetURL().path()); |
403 EXPECT_EQ(browser()->tab_strip_model()->GetWebContentsAt(1)-> | 404 EXPECT_EQ(browser()->tab_strip_model()->GetWebContentsAt(1)-> |
404 GetRenderProcessHost(), | 405 GetRenderProcessHost(), |
405 browser()->tab_strip_model()->GetWebContentsAt(2)-> | 406 browser()->tab_strip_model()->GetWebContentsAt(2)-> |
406 GetRenderProcessHost()); | 407 GetRenderProcessHost()); |
407 } | 408 } |
408 | 409 |
409 // Ensure that re-navigating to a URL after installing or uninstalling it as an | 410 // Ensure that re-navigating to a URL after installing or uninstalling it as an |
410 // app correctly swaps the tab to the app process. (http://crbug.com/80621) | 411 // app correctly swaps the tab to the app process. (http://crbug.com/80621) |
411 // | 412 // |
412 // Fails on Windows. http://crbug.com/238670 | 413 // Fails on Windows. http://crbug.com/238670 |
413 // Added logging to help diagnose the location of the problem. | 414 // Added logging to help diagnose the location of the problem. |
414 IN_PROC_BROWSER_TEST_F(AppApiTest, NavigateIntoAppProcess) { | 415 IN_PROC_BROWSER_TEST_F(AppApiTest, NavigateIntoAppProcess) { |
415 extensions::ProcessMap* process_map = extensions::ExtensionSystem::Get( | 416 extensions::ProcessMap* process_map = extensions::ExtensionSystem::Get( |
416 browser()->profile())->extension_service()->process_map(); | 417 browser()->profile())->extension_service()->process_map(); |
417 | 418 |
418 host_resolver()->AddRule("*", "127.0.0.1"); | 419 host_resolver()->AddRule("*", "127.0.0.1"); |
419 ASSERT_TRUE(test_server()->Start()); | 420 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
420 | 421 |
421 // The app under test acts on URLs whose host is "localhost", | 422 // The app under test acts on URLs whose host is "localhost", |
422 // so the URLs we navigate to must have host "localhost". | 423 // so the URLs we navigate to must have host "localhost". |
423 GURL base_url = GetTestBaseURL("app_process"); | 424 GURL base_url = GetTestBaseURL("app_process"); |
424 | 425 |
425 // Load an app URL before loading the app. | 426 // Load an app URL before loading the app. |
426 LOG(INFO) << "Loading path1/empty.html."; | 427 LOG(INFO) << "Loading path1/empty.html."; |
427 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html")); | 428 ui_test_utils::NavigateToURL(browser(), base_url.Resolve("path1/empty.html")); |
428 LOG(INFO) << "Loading path1/empty.html - done."; | 429 LOG(INFO) << "Loading path1/empty.html - done."; |
429 WebContents* contents = browser()->tab_strip_model()->GetWebContentsAt(0); | 430 WebContents* contents = browser()->tab_strip_model()->GetWebContentsAt(0); |
(...skipping 26 matching lines...) Expand all Loading... |
456 // Ensure that reloading a URL after installing or uninstalling it as an app | 457 // Ensure that reloading a URL after installing or uninstalling it as an app |
457 // correctly swaps the tab to the app process. (http://crbug.com/80621) | 458 // correctly swaps the tab to the app process. (http://crbug.com/80621) |
458 // | 459 // |
459 // Added logging to help diagnose the location of the problem. | 460 // Added logging to help diagnose the location of the problem. |
460 // http://crbug.com/238670 | 461 // http://crbug.com/238670 |
461 IN_PROC_BROWSER_TEST_F(AppApiTest, ReloadIntoAppProcess) { | 462 IN_PROC_BROWSER_TEST_F(AppApiTest, ReloadIntoAppProcess) { |
462 extensions::ProcessMap* process_map = extensions::ExtensionSystem::Get( | 463 extensions::ProcessMap* process_map = extensions::ExtensionSystem::Get( |
463 browser()->profile())->extension_service()->process_map(); | 464 browser()->profile())->extension_service()->process_map(); |
464 | 465 |
465 host_resolver()->AddRule("*", "127.0.0.1"); | 466 host_resolver()->AddRule("*", "127.0.0.1"); |
466 ASSERT_TRUE(test_server()->Start()); | 467 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
467 | 468 |
468 // The app under test acts on URLs whose host is "localhost", | 469 // The app under test acts on URLs whose host is "localhost", |
469 // so the URLs we navigate to must have host "localhost". | 470 // so the URLs we navigate to must have host "localhost". |
470 GURL base_url = GetTestBaseURL("app_process"); | 471 GURL base_url = GetTestBaseURL("app_process"); |
471 | 472 |
472 // Load app, disable it, and navigate to the page. | 473 // Load app, disable it, and navigate to the page. |
473 LOG(INFO) << "Loading extension."; | 474 LOG(INFO) << "Loading extension."; |
474 const Extension* app = | 475 const Extension* app = |
475 LoadExtension(test_data_dir_.AppendASCII("app_process")); | 476 LoadExtension(test_data_dir_.AppendASCII("app_process")); |
476 LOG(INFO) << "Loading extension - done."; | 477 LOG(INFO) << "Loading extension - done."; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 // Ensure that reloading a URL with JavaScript after installing or uninstalling | 522 // Ensure that reloading a URL with JavaScript after installing or uninstalling |
522 // it as an app correctly swaps the process. (http://crbug.com/80621) | 523 // it as an app correctly swaps the process. (http://crbug.com/80621) |
523 // | 524 // |
524 // Crashes on Windows and Mac. http://crbug.com/238670 | 525 // Crashes on Windows and Mac. http://crbug.com/238670 |
525 // Added logging to help diagnose the location of the problem. | 526 // Added logging to help diagnose the location of the problem. |
526 IN_PROC_BROWSER_TEST_F(AppApiTest, ReloadIntoAppProcessWithJavaScript) { | 527 IN_PROC_BROWSER_TEST_F(AppApiTest, ReloadIntoAppProcessWithJavaScript) { |
527 extensions::ProcessMap* process_map = extensions::ExtensionSystem::Get( | 528 extensions::ProcessMap* process_map = extensions::ExtensionSystem::Get( |
528 browser()->profile())->extension_service()->process_map(); | 529 browser()->profile())->extension_service()->process_map(); |
529 | 530 |
530 host_resolver()->AddRule("*", "127.0.0.1"); | 531 host_resolver()->AddRule("*", "127.0.0.1"); |
531 ASSERT_TRUE(test_server()->Start()); | 532 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
532 | 533 |
533 // The app under test acts on URLs whose host is "localhost", | 534 // The app under test acts on URLs whose host is "localhost", |
534 // so the URLs we navigate to must have host "localhost". | 535 // so the URLs we navigate to must have host "localhost". |
535 GURL base_url = GetTestBaseURL("app_process"); | 536 GURL base_url = GetTestBaseURL("app_process"); |
536 | 537 |
537 // Load app, disable it, and navigate to the page. | 538 // Load app, disable it, and navigate to the page. |
538 LOG(INFO) << "Loading extension."; | 539 LOG(INFO) << "Loading extension."; |
539 const Extension* app = | 540 const Extension* app = |
540 LoadExtension(test_data_dir_.AppendASCII("app_process")); | 541 LoadExtension(test_data_dir_.AppendASCII("app_process")); |
541 LOG(INFO) << "Loading extension - done."; | 542 LOG(INFO) << "Loading extension - done."; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 // Tests that if we have a non-app process (path3/container.html) that has an | 596 // Tests that if we have a non-app process (path3/container.html) that has an |
596 // iframe with a URL in the app's extent (path1/iframe.html), then opening a | 597 // iframe with a URL in the app's extent (path1/iframe.html), then opening a |
597 // link from that iframe to a new window to a URL in the app's extent (path1/ | 598 // link from that iframe to a new window to a URL in the app's extent (path1/ |
598 // empty.html) results in the new window being in an app process. See | 599 // empty.html) results in the new window being in an app process. See |
599 // http://crbug.com/89272 for more details. | 600 // http://crbug.com/89272 for more details. |
600 IN_PROC_BROWSER_TEST_F(AppApiTest, OpenAppFromIframe) { | 601 IN_PROC_BROWSER_TEST_F(AppApiTest, OpenAppFromIframe) { |
601 extensions::ProcessMap* process_map = extensions::ExtensionSystem::Get( | 602 extensions::ProcessMap* process_map = extensions::ExtensionSystem::Get( |
602 browser()->profile())->extension_service()->process_map(); | 603 browser()->profile())->extension_service()->process_map(); |
603 | 604 |
604 host_resolver()->AddRule("*", "127.0.0.1"); | 605 host_resolver()->AddRule("*", "127.0.0.1"); |
605 ASSERT_TRUE(test_server()->Start()); | 606 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
606 | 607 |
607 GURL base_url = GetTestBaseURL("app_process"); | 608 GURL base_url = GetTestBaseURL("app_process"); |
608 | 609 |
609 // Load app and start URL (not in the app). | 610 // Load app and start URL (not in the app). |
610 const Extension* app = | 611 const Extension* app = |
611 LoadExtension(test_data_dir_.AppendASCII("app_process")); | 612 LoadExtension(test_data_dir_.AppendASCII("app_process")); |
612 ASSERT_TRUE(app); | 613 ASSERT_TRUE(app); |
613 | 614 |
614 std::vector<content::RenderViewHost*> rvh_vector; | 615 std::vector<content::RenderViewHost*> rvh_vector; |
615 content::RenderViewHost::CreatedCallback rvh_callback( | 616 content::RenderViewHost::CreatedCallback rvh_callback( |
(...skipping 15 matching lines...) Expand all Loading... |
631 // Similar to the previous test, but ensure that popup blocking bypass | 632 // Similar to the previous test, but ensure that popup blocking bypass |
632 // isn't granted to the iframe. See crbug.com/117446. | 633 // isn't granted to the iframe. See crbug.com/117446. |
633 #if defined(OS_CHROMEOS) | 634 #if defined(OS_CHROMEOS) |
634 // http://crbug.com/153513 | 635 // http://crbug.com/153513 |
635 #define MAYBE_OpenAppFromIframe DISABLED_OpenAppFromIframe | 636 #define MAYBE_OpenAppFromIframe DISABLED_OpenAppFromIframe |
636 #else | 637 #else |
637 #define MAYBE_OpenAppFromIframe OpenAppFromIframe | 638 #define MAYBE_OpenAppFromIframe OpenAppFromIframe |
638 #endif | 639 #endif |
639 IN_PROC_BROWSER_TEST_F(BlockedAppApiTest, MAYBE_OpenAppFromIframe) { | 640 IN_PROC_BROWSER_TEST_F(BlockedAppApiTest, MAYBE_OpenAppFromIframe) { |
640 host_resolver()->AddRule("*", "127.0.0.1"); | 641 host_resolver()->AddRule("*", "127.0.0.1"); |
641 ASSERT_TRUE(test_server()->Start()); | 642 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
642 | 643 |
643 // Load app and start URL (not in the app). | 644 // Load app and start URL (not in the app). |
644 const Extension* app = | 645 const Extension* app = |
645 LoadExtension(test_data_dir_.AppendASCII("app_process")); | 646 LoadExtension(test_data_dir_.AppendASCII("app_process")); |
646 ASSERT_TRUE(app); | 647 ASSERT_TRUE(app); |
647 | 648 |
648 content::WindowedNotificationObserver blocker_observer( | 649 content::WindowedNotificationObserver blocker_observer( |
649 chrome::NOTIFICATION_CONTENT_BLOCKED_STATE_CHANGED, | 650 chrome::NOTIFICATION_CONTENT_BLOCKED_STATE_CHANGED, |
650 content::NotificationService::AllSources()); | 651 content::NotificationService::AllSources()); |
651 ui_test_utils::NavigateToURL( | 652 ui_test_utils::NavigateToURL( |
652 browser(), GetTestBaseURL("app_process").Resolve("path3/container.html")); | 653 browser(), GetTestBaseURL("app_process").Resolve("path3/container.html")); |
653 | 654 |
654 blocker_observer.Wait(); | 655 blocker_observer.Wait(); |
655 | 656 |
656 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 657 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
657 BlockedContentTabHelper* blocked_content_tab_helper = | 658 BlockedContentTabHelper* blocked_content_tab_helper = |
658 BlockedContentTabHelper::FromWebContents(tab); | 659 BlockedContentTabHelper::FromWebContents(tab); |
659 std::vector<WebContents*> blocked_contents; | 660 std::vector<WebContents*> blocked_contents; |
660 blocked_content_tab_helper->GetBlockedContents(&blocked_contents); | 661 blocked_content_tab_helper->GetBlockedContents(&blocked_contents); |
661 EXPECT_EQ(blocked_contents.size(), 1u); | 662 EXPECT_EQ(blocked_contents.size(), 1u); |
662 } | 663 } |
663 | 664 |
664 // Tests that if an extension launches an app via chrome.tabs.create with an URL | 665 // Tests that if an extension launches an app via chrome.tabs.create with an URL |
665 // that's not in the app's extent but that server redirects to it, we still end | 666 // that's not in the app's extent but that server redirects to it, we still end |
666 // up with an app process. See http://crbug.com/99349 for more details. | 667 // up with an app process. See http://crbug.com/99349 for more details. |
667 IN_PROC_BROWSER_TEST_F(AppApiTest, ServerRedirectToAppFromExtension) { | 668 IN_PROC_BROWSER_TEST_F(AppApiTest, ServerRedirectToAppFromExtension) { |
668 host_resolver()->AddRule("*", "127.0.0.1"); | 669 host_resolver()->AddRule("*", "127.0.0.1"); |
669 ASSERT_TRUE(StartTestServer()); | 670 ASSERT_TRUE(StartEmbeddedTestServer()); |
670 | 671 |
671 LoadExtension(test_data_dir_.AppendASCII("app_process")); | 672 LoadExtension(test_data_dir_.AppendASCII("app_process")); |
672 const Extension* launcher = | 673 const Extension* launcher = |
673 LoadExtension(test_data_dir_.AppendASCII("app_launcher")); | 674 LoadExtension(test_data_dir_.AppendASCII("app_launcher")); |
674 | 675 |
675 // There should be two navigations by the time the app page is loaded. | 676 // There should be two navigations by the time the app page is loaded. |
676 // 1. The extension launcher page. | 677 // 1. The extension launcher page. |
677 // 2. The app's URL (which includes a server redirect). | 678 // 2. The app's URL (which includes a server redirect). |
678 // Note that the server redirect does not generate a navigation event. | 679 // Note that the server redirect does not generate a navigation event. |
679 content::TestNavigationObserver test_navigation_observer( | 680 content::TestNavigationObserver test_navigation_observer( |
(...skipping 21 matching lines...) Expand all Loading... |
701 "window.domAutomationController.send(chrome.app.isInstalled)", | 702 "window.domAutomationController.send(chrome.app.isInstalled)", |
702 &is_installed)); | 703 &is_installed)); |
703 ASSERT_TRUE(is_installed); | 704 ASSERT_TRUE(is_installed); |
704 } | 705 } |
705 | 706 |
706 // Tests that if an extension launches an app via chrome.tabs.create with an URL | 707 // Tests that if an extension launches an app via chrome.tabs.create with an URL |
707 // that's not in the app's extent but that client redirects to it, we still end | 708 // that's not in the app's extent but that client redirects to it, we still end |
708 // up with an app process. | 709 // up with an app process. |
709 IN_PROC_BROWSER_TEST_F(AppApiTest, ClientRedirectToAppFromExtension) { | 710 IN_PROC_BROWSER_TEST_F(AppApiTest, ClientRedirectToAppFromExtension) { |
710 host_resolver()->AddRule("*", "127.0.0.1"); | 711 host_resolver()->AddRule("*", "127.0.0.1"); |
711 ASSERT_TRUE(StartTestServer()); | 712 ASSERT_TRUE(StartEmbeddedTestServer()); |
712 | 713 |
713 LoadExtension(test_data_dir_.AppendASCII("app_process")); | 714 LoadExtension(test_data_dir_.AppendASCII("app_process")); |
714 const Extension* launcher = | 715 const Extension* launcher = |
715 LoadExtension(test_data_dir_.AppendASCII("app_launcher")); | 716 LoadExtension(test_data_dir_.AppendASCII("app_launcher")); |
716 | 717 |
717 // There should be three navigations by the time the app page is loaded. | 718 // There should be three navigations by the time the app page is loaded. |
718 // 1. The extension launcher page. | 719 // 1. The extension launcher page. |
719 // 2. The URL that the extension launches, which client redirects. | 720 // 2. The URL that the extension launches, which client redirects. |
720 // 3. The app's URL. | 721 // 3. The app's URL. |
721 content::TestNavigationObserver test_navigation_observer( | 722 content::TestNavigationObserver test_navigation_observer( |
(...skipping 28 matching lines...) Expand all Loading... |
750 // window to a same-origin non-app URL (path3/empty.html) should keep the window | 751 // window to a same-origin non-app URL (path3/empty.html) should keep the window |
751 // in the app process. | 752 // in the app process. |
752 // This is in contrast to OpenAppFromIframe, since here the popup will not be | 753 // This is in contrast to OpenAppFromIframe, since here the popup will not be |
753 // missing special permissions and should be scriptable from the iframe. | 754 // missing special permissions and should be scriptable from the iframe. |
754 // See http://crbug.com/92669 for more details. | 755 // See http://crbug.com/92669 for more details. |
755 IN_PROC_BROWSER_TEST_F(AppApiTest, OpenWebPopupFromWebIframe) { | 756 IN_PROC_BROWSER_TEST_F(AppApiTest, OpenWebPopupFromWebIframe) { |
756 extensions::ProcessMap* process_map = extensions::ExtensionSystem::Get( | 757 extensions::ProcessMap* process_map = extensions::ExtensionSystem::Get( |
757 browser()->profile())->extension_service()->process_map(); | 758 browser()->profile())->extension_service()->process_map(); |
758 | 759 |
759 host_resolver()->AddRule("*", "127.0.0.1"); | 760 host_resolver()->AddRule("*", "127.0.0.1"); |
760 ASSERT_TRUE(test_server()->Start()); | 761 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
761 | 762 |
762 GURL base_url = GetTestBaseURL("app_process"); | 763 GURL base_url = GetTestBaseURL("app_process"); |
763 | 764 |
764 // Load app and start URL (in the app). | 765 // Load app and start URL (in the app). |
765 const Extension* app = | 766 const Extension* app = |
766 LoadExtension(test_data_dir_.AppendASCII("app_process")); | 767 LoadExtension(test_data_dir_.AppendASCII("app_process")); |
767 ASSERT_TRUE(app); | 768 ASSERT_TRUE(app); |
768 | 769 |
769 std::vector<content::RenderViewHost*> rvh_vector; | 770 std::vector<content::RenderViewHost*> rvh_vector; |
770 content::RenderViewHost::CreatedCallback rvh_callback( | 771 content::RenderViewHost::CreatedCallback rvh_callback( |
(...skipping 16 matching lines...) Expand all Loading... |
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 = extensions::ExtensionSystem::Get( |
794 browser()->profile())->extension_service()->process_map(); | 795 browser()->profile())->extension_service()->process_map(); |
795 | 796 |
796 host_resolver()->AddRule("*", "127.0.0.1"); | 797 host_resolver()->AddRule("*", "127.0.0.1"); |
797 ASSERT_TRUE(test_server()->Start()); | 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")); |
805 WebContents* contents = browser()->tab_strip_model()->GetWebContentsAt(0); | 806 WebContents* contents = browser()->tab_strip_model()->GetWebContentsAt(0); |
806 EXPECT_TRUE(process_map->Contains( | 807 EXPECT_TRUE(process_map->Contains( |
807 contents->GetRenderProcessHost()->GetID())); | 808 contents->GetRenderProcessHost()->GetID())); |
(...skipping 12 matching lines...) Expand all Loading... |
820 &browser()->tab_strip_model()->GetActiveWebContents()-> | 821 &browser()->tab_strip_model()->GetActiveWebContents()-> |
821 GetController())); | 822 GetController())); |
822 chrome::Reload(browser(), CURRENT_TAB); | 823 chrome::Reload(browser(), CURRENT_TAB); |
823 observer.Wait(); | 824 observer.Wait(); |
824 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( | 825 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( |
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 } |
OLD | NEW |