| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "apps/ui/native_app_window.h" | 5 #include "apps/ui/native_app_window.h" |
| 6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/apps/app_browsertest_util.h" | 9 #include "chrome/browser/apps/app_browsertest_util.h" |
| 10 #include "chrome/browser/automation/automation_util.h" | 10 #include "chrome/browser/automation/automation_util.h" |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 LoadAndLaunchPlatformApp(app_location.c_str()); | 513 LoadAndLaunchPlatformApp(app_location.c_str()); |
| 514 if (!launched_listener.WaitUntilSatisfied()) { | 514 if (!launched_listener.WaitUntilSatisfied()) { |
| 515 LOG(ERROR) << "TEST DID NOT LAUNCH."; | 515 LOG(ERROR) << "TEST DID NOT LAUNCH."; |
| 516 return; | 516 return; |
| 517 } | 517 } |
| 518 | 518 |
| 519 // Flush any pending events to make sure we start with a clean slate. | 519 // Flush any pending events to make sure we start with a clean slate. |
| 520 content::RunAllPendingInMessageLoop(); | 520 content::RunAllPendingInMessageLoop(); |
| 521 | 521 |
| 522 content::WebContents* embedder_web_contents = | 522 content::WebContents* embedder_web_contents = |
| 523 GetFirstShellWindowWebContents(); | 523 GetFirstAppWindowWebContents(); |
| 524 if (!embedder_web_contents) { | 524 if (!embedder_web_contents) { |
| 525 LOG(ERROR) << "UNABLE TO FIND EMBEDDER WEB CONTENTS."; | 525 LOG(ERROR) << "UNABLE TO FIND EMBEDDER WEB CONTENTS."; |
| 526 return; | 526 return; |
| 527 } | 527 } |
| 528 | 528 |
| 529 ExtensionTestMessageListener done_listener("TEST_PASSED", false); | 529 ExtensionTestMessageListener done_listener("TEST_PASSED", false); |
| 530 done_listener.AlsoListenForFailureMessage("TEST_FAILED"); | 530 done_listener.AlsoListenForFailureMessage("TEST_FAILED"); |
| 531 if (!content::ExecuteScript( | 531 if (!content::ExecuteScript( |
| 532 embedder_web_contents, | 532 embedder_web_contents, |
| 533 base::StringPrintf("runTest('%s')", test_name.c_str()))) { | 533 base::StringPrintf("runTest('%s')", test_name.c_str()))) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 | 570 |
| 571 // Runs media_access/deny tests, each of them are run separately otherwise | 571 // Runs media_access/deny tests, each of them are run separately otherwise |
| 572 // they timeout (mostly on Windows). | 572 // they timeout (mostly on Windows). |
| 573 void MediaAccessAPIDenyTestHelper(const std::string& test_name) { | 573 void MediaAccessAPIDenyTestHelper(const std::string& test_name) { |
| 574 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages. | 574 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages. |
| 575 ExtensionTestMessageListener loaded_listener("loaded", false); | 575 ExtensionTestMessageListener loaded_listener("loaded", false); |
| 576 LoadAndLaunchPlatformApp("web_view/media_access/deny"); | 576 LoadAndLaunchPlatformApp("web_view/media_access/deny"); |
| 577 ASSERT_TRUE(loaded_listener.WaitUntilSatisfied()); | 577 ASSERT_TRUE(loaded_listener.WaitUntilSatisfied()); |
| 578 | 578 |
| 579 content::WebContents* embedder_web_contents = | 579 content::WebContents* embedder_web_contents = |
| 580 GetFirstShellWindowWebContents(); | 580 GetFirstAppWindowWebContents(); |
| 581 ASSERT_TRUE(embedder_web_contents); | 581 ASSERT_TRUE(embedder_web_contents); |
| 582 | 582 |
| 583 ExtensionTestMessageListener test_run_listener("PASSED", false); | 583 ExtensionTestMessageListener test_run_listener("PASSED", false); |
| 584 test_run_listener.AlsoListenForFailureMessage("FAILED"); | 584 test_run_listener.AlsoListenForFailureMessage("FAILED"); |
| 585 EXPECT_TRUE( | 585 EXPECT_TRUE( |
| 586 content::ExecuteScript( | 586 content::ExecuteScript( |
| 587 embedder_web_contents, | 587 embedder_web_contents, |
| 588 base::StringPrintf("startDenyTest('%s')", test_name.c_str()))); | 588 base::StringPrintf("startDenyTest('%s')", test_name.c_str()))); |
| 589 ASSERT_TRUE(test_run_listener.WaitUntilSatisfied()); | 589 ASSERT_TRUE(test_run_listener.WaitUntilSatisfied()); |
| 590 } | 590 } |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 } | 899 } |
| 900 | 900 |
| 901 IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestRemoveWebviewOnExit) { | 901 IN_PROC_BROWSER_TEST_F(WebViewTest, Shim_TestRemoveWebviewOnExit) { |
| 902 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages. | 902 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages. |
| 903 | 903 |
| 904 // Launch the app and wait until it's ready to load a test. | 904 // Launch the app and wait until it's ready to load a test. |
| 905 ExtensionTestMessageListener launched_listener("Launched", false); | 905 ExtensionTestMessageListener launched_listener("Launched", false); |
| 906 LoadAndLaunchPlatformApp("web_view/shim"); | 906 LoadAndLaunchPlatformApp("web_view/shim"); |
| 907 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); | 907 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); |
| 908 | 908 |
| 909 content::WebContents* embedder_web_contents = | 909 content::WebContents* embedder_web_contents = GetFirstAppWindowWebContents(); |
| 910 GetFirstShellWindowWebContents(); | |
| 911 ASSERT_TRUE(embedder_web_contents); | 910 ASSERT_TRUE(embedder_web_contents); |
| 912 | 911 |
| 913 GURL::Replacements replace_host; | 912 GURL::Replacements replace_host; |
| 914 std::string host_str("localhost"); // Must stay in scope with replace_host. | 913 std::string host_str("localhost"); // Must stay in scope with replace_host. |
| 915 replace_host.SetHostStr(host_str); | 914 replace_host.SetHostStr(host_str); |
| 916 | 915 |
| 917 std::string guest_path( | 916 std::string guest_path( |
| 918 "/extensions/platform_apps/web_view/shim/empty_guest.html"); | 917 "/extensions/platform_apps/web_view/shim/empty_guest.html"); |
| 919 GURL guest_url = embedded_test_server()->GetURL(guest_path); | 918 GURL guest_url = embedded_test_server()->GetURL(guest_path); |
| 920 guest_url = guest_url.ReplaceComponents(replace_host); | 919 guest_url = guest_url.ReplaceComponents(replace_host); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 991 ExtensionTestMessageListener embedder_loaded_listener("EmbedderLoaded", | 990 ExtensionTestMessageListener embedder_loaded_listener("EmbedderLoaded", |
| 992 false); | 991 false); |
| 993 LoadAndLaunchPlatformApp("web_view/interstitial_teardown"); | 992 LoadAndLaunchPlatformApp("web_view/interstitial_teardown"); |
| 994 ASSERT_TRUE(embedder_loaded_listener.WaitUntilSatisfied()); | 993 ASSERT_TRUE(embedder_loaded_listener.WaitUntilSatisfied()); |
| 995 | 994 |
| 996 GuestContentBrowserClient new_client; | 995 GuestContentBrowserClient new_client; |
| 997 content::ContentBrowserClient* old_client = | 996 content::ContentBrowserClient* old_client = |
| 998 SetBrowserClientForTesting(&new_client); | 997 SetBrowserClientForTesting(&new_client); |
| 999 | 998 |
| 1000 // Now load the guest. | 999 // Now load the guest. |
| 1001 content::WebContents* embedder_web_contents = | 1000 content::WebContents* embedder_web_contents = GetFirstAppWindowWebContents(); |
| 1002 GetFirstShellWindowWebContents(); | |
| 1003 ExtensionTestMessageListener second("GuestAddedToDom", false); | 1001 ExtensionTestMessageListener second("GuestAddedToDom", false); |
| 1004 EXPECT_TRUE(content::ExecuteScript( | 1002 EXPECT_TRUE(content::ExecuteScript( |
| 1005 embedder_web_contents, | 1003 embedder_web_contents, |
| 1006 base::StringPrintf("loadGuest(%d);\n", host_and_port.port()))); | 1004 base::StringPrintf("loadGuest(%d);\n", host_and_port.port()))); |
| 1007 ASSERT_TRUE(second.WaitUntilSatisfied()); | 1005 ASSERT_TRUE(second.WaitUntilSatisfied()); |
| 1008 | 1006 |
| 1009 // Wait for interstitial page to be shown in guest. | 1007 // Wait for interstitial page to be shown in guest. |
| 1010 content::WebContents* guest_web_contents = new_client.WaitForGuestCreated(); | 1008 content::WebContents* guest_web_contents = new_client.WaitForGuestCreated(); |
| 1011 SetBrowserClientForTesting(old_client); | 1009 SetBrowserClientForTesting(old_client); |
| 1012 ASSERT_TRUE(guest_web_contents->GetRenderProcessHost()->IsGuest()); | 1010 ASSERT_TRUE(guest_web_contents->GetRenderProcessHost()->IsGuest()); |
| 1013 WaitForInterstitial(guest_web_contents); | 1011 WaitForInterstitial(guest_web_contents); |
| 1014 | 1012 |
| 1015 // Now close the app while interstitial page being shown in guest. | 1013 // Now close the app while interstitial page being shown in guest. |
| 1016 apps::ShellWindow* window = GetFirstShellWindow(); | 1014 apps::AppWindow* window = GetFirstAppWindow(); |
| 1017 window->GetBaseWindow()->Close(); | 1015 window->GetBaseWindow()->Close(); |
| 1018 } | 1016 } |
| 1019 | 1017 |
| 1020 IN_PROC_BROWSER_TEST_F(WebViewTest, ShimSrcAttribute) { | 1018 IN_PROC_BROWSER_TEST_F(WebViewTest, ShimSrcAttribute) { |
| 1021 ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view/src_attribute")) | 1019 ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view/src_attribute")) |
| 1022 << message_; | 1020 << message_; |
| 1023 } | 1021 } |
| 1024 | 1022 |
| 1025 // This test verifies that prerendering has been disabled inside <webview>. | 1023 // This test verifies that prerendering has been disabled inside <webview>. |
| 1026 // This test is here rather than in PrerenderBrowserTest for testing convenience | 1024 // This test is here rather than in PrerenderBrowserTest for testing convenience |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1483 MediaAccessAPIDeny_TestNoPreventDefaultImpliesDeny) { | 1481 MediaAccessAPIDeny_TestNoPreventDefaultImpliesDeny) { |
| 1484 MediaAccessAPIDenyTestHelper("testNoPreventDefaultImpliesDeny"); | 1482 MediaAccessAPIDenyTestHelper("testNoPreventDefaultImpliesDeny"); |
| 1485 } | 1483 } |
| 1486 | 1484 |
| 1487 void WebViewTest::MediaAccessAPIAllowTestHelper(const std::string& test_name) { | 1485 void WebViewTest::MediaAccessAPIAllowTestHelper(const std::string& test_name) { |
| 1488 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages. | 1486 ASSERT_TRUE(StartEmbeddedTestServer()); // For serving guest pages. |
| 1489 ExtensionTestMessageListener launched_listener("Launched", false); | 1487 ExtensionTestMessageListener launched_listener("Launched", false); |
| 1490 LoadAndLaunchPlatformApp("web_view/media_access/allow"); | 1488 LoadAndLaunchPlatformApp("web_view/media_access/allow"); |
| 1491 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); | 1489 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); |
| 1492 | 1490 |
| 1493 content::WebContents* embedder_web_contents = | 1491 content::WebContents* embedder_web_contents = GetFirstAppWindowWebContents(); |
| 1494 GetFirstShellWindowWebContents(); | |
| 1495 ASSERT_TRUE(embedder_web_contents); | 1492 ASSERT_TRUE(embedder_web_contents); |
| 1496 MockWebContentsDelegate* mock = new MockWebContentsDelegate; | 1493 MockWebContentsDelegate* mock = new MockWebContentsDelegate; |
| 1497 embedder_web_contents->SetDelegate(mock); | 1494 embedder_web_contents->SetDelegate(mock); |
| 1498 | 1495 |
| 1499 ExtensionTestMessageListener done_listener("TEST_PASSED", false); | 1496 ExtensionTestMessageListener done_listener("TEST_PASSED", false); |
| 1500 done_listener.AlsoListenForFailureMessage("TEST_FAILED"); | 1497 done_listener.AlsoListenForFailureMessage("TEST_FAILED"); |
| 1501 EXPECT_TRUE( | 1498 EXPECT_TRUE( |
| 1502 content::ExecuteScript( | 1499 content::ExecuteScript( |
| 1503 embedder_web_contents, | 1500 embedder_web_contents, |
| 1504 base::StringPrintf("startAllowTest('%s')", | 1501 base::StringPrintf("startAllowTest('%s')", |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1574 #if defined(OS_WIN) | 1571 #if defined(OS_WIN) |
| 1575 #define MAYBE_TearDownTest DISABLED_TearDownTest | 1572 #define MAYBE_TearDownTest DISABLED_TearDownTest |
| 1576 #else | 1573 #else |
| 1577 #define MAYBE_TearDownTest TearDownTest | 1574 #define MAYBE_TearDownTest TearDownTest |
| 1578 #endif | 1575 #endif |
| 1579 IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_TearDownTest) { | 1576 IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_TearDownTest) { |
| 1580 ExtensionTestMessageListener first_loaded_listener("guest-loaded", false); | 1577 ExtensionTestMessageListener first_loaded_listener("guest-loaded", false); |
| 1581 const extensions::Extension* extension = | 1578 const extensions::Extension* extension = |
| 1582 LoadAndLaunchPlatformApp("web_view/teardown"); | 1579 LoadAndLaunchPlatformApp("web_view/teardown"); |
| 1583 ASSERT_TRUE(first_loaded_listener.WaitUntilSatisfied()); | 1580 ASSERT_TRUE(first_loaded_listener.WaitUntilSatisfied()); |
| 1584 apps::ShellWindow* window = NULL; | 1581 apps::AppWindow* window = NULL; |
| 1585 if (!GetShellWindowCount()) | 1582 if (!GetAppWindowCount()) |
| 1586 window = CreateShellWindow(extension); | 1583 window = CreateAppWindow(extension); |
| 1587 else | 1584 else |
| 1588 window = GetFirstShellWindow(); | 1585 window = GetFirstAppWindow(); |
| 1589 CloseShellWindow(window); | 1586 CloseAppWindow(window); |
| 1590 | 1587 |
| 1591 // Load the app again. | 1588 // Load the app again. |
| 1592 ExtensionTestMessageListener second_loaded_listener("guest-loaded", false); | 1589 ExtensionTestMessageListener second_loaded_listener("guest-loaded", false); |
| 1593 LoadAndLaunchPlatformApp("web_view/teardown"); | 1590 LoadAndLaunchPlatformApp("web_view/teardown"); |
| 1594 ASSERT_TRUE(second_loaded_listener.WaitUntilSatisfied()); | 1591 ASSERT_TRUE(second_loaded_listener.WaitUntilSatisfied()); |
| 1595 } | 1592 } |
| 1596 | 1593 |
| 1597 // In following GeolocationAPIEmbedderHasNoAccess* tests, embedder (i.e. the | 1594 // In following GeolocationAPIEmbedderHasNoAccess* tests, embedder (i.e. the |
| 1598 // platform app) does not have geolocation permission for this test. | 1595 // platform app) does not have geolocation permission for this test. |
| 1599 // No matter what the API does, geolocation permission would be denied. | 1596 // No matter what the API does, geolocation permission would be denied. |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1892 INSTANTIATE_TEST_CASE_P(WithoutThreadedCompositor, | 1889 INSTANTIATE_TEST_CASE_P(WithoutThreadedCompositor, |
| 1893 WebViewCaptureTest, | 1890 WebViewCaptureTest, |
| 1894 ::testing::Values(std::string(switches::kDisableThreadedCompositing))); | 1891 ::testing::Values(std::string(switches::kDisableThreadedCompositing))); |
| 1895 | 1892 |
| 1896 // http://crbug.com/171744 | 1893 // http://crbug.com/171744 |
| 1897 #if !defined(OS_MACOSX) | 1894 #if !defined(OS_MACOSX) |
| 1898 INSTANTIATE_TEST_CASE_P(WithThreadedCompositor, | 1895 INSTANTIATE_TEST_CASE_P(WithThreadedCompositor, |
| 1899 WebViewCaptureTest, | 1896 WebViewCaptureTest, |
| 1900 ::testing::Values(std::string(switches::kEnableThreadedCompositing))); | 1897 ::testing::Values(std::string(switches::kEnableThreadedCompositing))); |
| 1901 #endif | 1898 #endif |
| OLD | NEW |