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/stringprintf.h" | 5 #include "base/stringprintf.h" |
6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
7 #include "chrome/browser/automation/automation_util.h" | 7 #include "chrome/browser/automation/automation_util.h" |
8 #include "chrome/browser/extensions/extension_test_message_listener.h" | 8 #include "chrome/browser/extensions/extension_test_message_listener.h" |
9 #include "chrome/browser/extensions/platform_app_browsertest_util.h" | 9 #include "chrome/browser/extensions/platform_app_browsertest_util.h" |
10 #include "chrome/browser/prerender/prerender_link_manager.h" | 10 #include "chrome/browser/prerender/prerender_link_manager.h" |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 EXPECT_TRUE(source->GetWebContents()->GetRenderProcessHost()->IsGuest()); | 397 EXPECT_TRUE(source->GetWebContents()->GetRenderProcessHost()->IsGuest()); |
398 | 398 |
399 bool satisfied = guest_loaded_listener.WaitUntilSatisfied(); | 399 bool satisfied = guest_loaded_listener.WaitUntilSatisfied(); |
400 if (!satisfied) | 400 if (!satisfied) |
401 return NULL; | 401 return NULL; |
402 | 402 |
403 content::WebContents* guest_web_contents = source->GetWebContents(); | 403 content::WebContents* guest_web_contents = source->GetWebContents(); |
404 return guest_web_contents; | 404 return guest_web_contents; |
405 } | 405 } |
406 | 406 |
| 407 void MediaAccessAPIAllowTestHelper(const std::string& test_name); |
| 408 |
407 private: | 409 private: |
408 scoped_ptr<content::FakeSpeechRecognitionManager> | 410 scoped_ptr<content::FakeSpeechRecognitionManager> |
409 fake_speech_recognition_manager_; | 411 fake_speech_recognition_manager_; |
410 }; | 412 }; |
411 | 413 |
412 // This test is flaky on Windows, Chrome OS, and Mac (all platforms that | 414 // This test is flaky on Windows, Chrome OS, and Mac (all platforms that |
413 // have threaded compositing enabled). | 415 // have threaded compositing enabled). |
414 // http://crbug.com/176122 | 416 // http://crbug.com/176122 |
415 #if defined(OS_WIN) || defined(OS_CHROMEOS) || defined(OS_MACOSX) | 417 #if defined(OS_WIN) || defined(OS_CHROMEOS) || defined(OS_MACOSX) |
416 #define MAYBE_Shim DISABLED_Shim | 418 #define MAYBE_Shim DISABLED_Shim |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 ASSERT_TRUE(done_test_listener.WaitUntilSatisfied()); | 840 ASSERT_TRUE(done_test_listener.WaitUntilSatisfied()); |
839 } | 841 } |
840 | 842 |
841 // Disabled for being flaky: http://crbug.com/237985 | 843 // Disabled for being flaky: http://crbug.com/237985 |
842 IN_PROC_BROWSER_TEST_F(WebViewTest, DISABLED_MediaAccessAPIDeny) { | 844 IN_PROC_BROWSER_TEST_F(WebViewTest, DISABLED_MediaAccessAPIDeny) { |
843 ASSERT_TRUE(StartTestServer()); // For serving guest pages. | 845 ASSERT_TRUE(StartTestServer()); // For serving guest pages. |
844 ASSERT_TRUE(RunPlatformAppTest( | 846 ASSERT_TRUE(RunPlatformAppTest( |
845 "platform_apps/web_view/media_access/deny")) << message_; | 847 "platform_apps/web_view/media_access/deny")) << message_; |
846 } | 848 } |
847 | 849 |
848 // Disabled for being flaky: http://crbug.com/238662 | 850 void WebViewTest::MediaAccessAPIAllowTestHelper(const std::string& test_name) { |
849 #if defined(OS_CHROMEOS) | |
850 #define MAYBE_MediaAccessAPIAllow DISABLED_MediaAccessAPIAllow | |
851 #else | |
852 #define MAYBE_MediaAccessAPIAllow MediaAccessAPIAllow | |
853 #endif | |
854 IN_PROC_BROWSER_TEST_F(WebViewTest, MAYBE_MediaAccessAPIAllow) { | |
855 ASSERT_TRUE(StartTestServer()); // For serving guest pages. | 851 ASSERT_TRUE(StartTestServer()); // For serving guest pages. |
856 ExtensionTestMessageListener launched_listener("Launched", false); | 852 ExtensionTestMessageListener launched_listener("Launched", false); |
857 LoadAndLaunchPlatformApp("web_view/media_access/allow"); | 853 LoadAndLaunchPlatformApp("web_view/media_access/allow"); |
858 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); | 854 ASSERT_TRUE(launched_listener.WaitUntilSatisfied()); |
859 | 855 |
860 content::WebContents* embedder_web_contents = | 856 content::WebContents* embedder_web_contents = |
861 GetFirstShellWindowWebContents(); | 857 GetFirstShellWindowWebContents(); |
862 ASSERT_TRUE(embedder_web_contents); | 858 ASSERT_TRUE(embedder_web_contents); |
863 MockWebContentsDelegate* mock = new MockWebContentsDelegate; | 859 MockWebContentsDelegate* mock = new MockWebContentsDelegate; |
864 embedder_web_contents->SetDelegate(mock); | 860 embedder_web_contents->SetDelegate(mock); |
865 | 861 |
866 const size_t num_tests = 4; | 862 ExtensionTestMessageListener done_listener("DoneMediaTest.PASSED", false); |
867 std::string test_names[num_tests] = { | 863 done_listener.AlsoListenForFailureMessage("DoneMediaTest.FAILED"); |
868 "testAllow", | 864 EXPECT_TRUE( |
869 "testAllowAndThenDeny", | 865 content::ExecuteScript( |
870 "testAllowTwice", | 866 embedder_web_contents, |
871 "testAllowAsync", | 867 base::StringPrintf("startAllowTest('%s')", |
872 }; | 868 test_name.c_str()))); |
873 for (size_t i = 0; i < num_tests; ++i) { | 869 ASSERT_TRUE(done_listener.WaitUntilSatisfied()); |
874 ExtensionTestMessageListener done_listener("DoneMediaTest", false); | |
875 EXPECT_TRUE( | |
876 content::ExecuteScript( | |
877 embedder_web_contents, | |
878 base::StringPrintf("startAllowTest('%s')", | |
879 test_names[i].c_str()))); | |
880 done_listener.WaitUntilSatisfied(); | |
881 | 870 |
882 std::string result; | 871 mock->WaitForSetMediaPermission(); |
883 EXPECT_TRUE( | 872 } |
884 content::ExecuteScriptAndExtractString( | |
885 embedder_web_contents, | |
886 "window.domAutomationController.send(getTestStatus())", &result)); | |
887 ASSERT_EQ(std::string("PASSED"), result); | |
888 | 873 |
889 mock->WaitForSetMediaPermission(); | 874 IN_PROC_BROWSER_TEST_F(WebViewTest, MediaAccessAPIAllow_TestAllow) { |
890 } | 875 MediaAccessAPIAllowTestHelper("testAllow"); |
| 876 } |
| 877 |
| 878 IN_PROC_BROWSER_TEST_F(WebViewTest, MediaAccessAPIAllow_TestAllowAndThenDeny) { |
| 879 MediaAccessAPIAllowTestHelper("testAllowAndThenDeny"); |
| 880 } |
| 881 |
| 882 IN_PROC_BROWSER_TEST_F(WebViewTest, MediaAccessAPIAllow_TestAllowTwice) { |
| 883 MediaAccessAPIAllowTestHelper("testAllowTwice"); |
| 884 } |
| 885 |
| 886 IN_PROC_BROWSER_TEST_F(WebViewTest, MediaAccessAPIAllow_TestAllowAsync) { |
| 887 MediaAccessAPIAllowTestHelper("testAllowAsync"); |
891 } | 888 } |
892 | 889 |
893 // Checks that window.screenX/screenY/screenLeft/screenTop works correctly for | 890 // Checks that window.screenX/screenY/screenLeft/screenTop works correctly for |
894 // guests. | 891 // guests. |
895 IN_PROC_BROWSER_TEST_F(WebViewTest, ScreenCoordinates) { | 892 IN_PROC_BROWSER_TEST_F(WebViewTest, ScreenCoordinates) { |
896 ASSERT_TRUE(StartTestServer()); // For serving guest pages. | 893 ASSERT_TRUE(StartTestServer()); // For serving guest pages. |
897 ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view/screen_coordinates")) | 894 ASSERT_TRUE(RunPlatformAppTest("platform_apps/web_view/screen_coordinates")) |
898 << message_; | 895 << message_; |
899 } | 896 } |
900 | 897 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1015 EXPECT_TRUE(content::ExecuteScript(guest_web_contents, | 1012 EXPECT_TRUE(content::ExecuteScript(guest_web_contents, |
1016 "startDownload('download-link-2')")); | 1013 "startDownload('download-link-2')")); |
1017 mock_delegate->WaitForCanDownload(true); // Expect to allow. | 1014 mock_delegate->WaitForCanDownload(true); // Expect to allow. |
1018 mock_delegate->Reset(); | 1015 mock_delegate->Reset(); |
1019 | 1016 |
1020 // 3. Guest requests a download that its embedder ignores, this implies deny. | 1017 // 3. Guest requests a download that its embedder ignores, this implies deny. |
1021 EXPECT_TRUE(content::ExecuteScript(guest_web_contents, | 1018 EXPECT_TRUE(content::ExecuteScript(guest_web_contents, |
1022 "startDownload('download-link-3')")); | 1019 "startDownload('download-link-3')")); |
1023 mock_delegate->WaitForCanDownload(false); // Expect to not allow. | 1020 mock_delegate->WaitForCanDownload(false); // Expect to not allow. |
1024 } | 1021 } |
OLD | NEW |