OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 } | 844 } |
845 | 845 |
846 // For Pepper request from insecure origin, even if it's ALLOW, it won't be | 846 // For Pepper request from insecure origin, even if it's ALLOW, it won't be |
847 // changed to ASK. | 847 // changed to ASK. |
848 IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, | 848 IN_PROC_BROWSER_TEST_P(MediaStreamDevicesControllerTest, |
849 PepperRequestInsecure) { | 849 PepperRequestInsecure) { |
850 InitWithUrl(GURL("http://www.example.com")); | 850 InitWithUrl(GURL("http://www.example.com")); |
851 | 851 |
852 SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); | 852 SetPromptResponseType(PermissionRequestManager::ACCEPT_ALL); |
853 | 853 |
854 RequestPermissions( | 854 { |
855 GetWebContents(), | 855 // Test that with the kRequireSecureOriginsForPepperMediaRequests flag |
856 CreateRequestWithType(example_audio_id(), std::string(), | 856 // disabled that permission will be denied. TODO(raymes): Remove this when |
857 content::MEDIA_OPEN_DEVICE_PEPPER_ONLY), | 857 // crbug.com/526324 is fixed. |
858 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 858 base::test::ScopedFeatureList scoped_feature_list; |
859 base::Unretained(this))); | 859 if (static_cast<TestType>(GetParam()) == |
860 ASSERT_EQ(2u, TotalPromptRequestCount()); | 860 TestType::TEST_WITH_GROUPED_MEDIA_REQUESTS) { |
| 861 scoped_feature_list.InitWithFeatures( |
| 862 {features::kUsePermissionManagerForMediaRequests}, |
| 863 {features::kRequireSecureOriginsForPepperMediaRequests}); |
| 864 } else { |
| 865 scoped_feature_list.InitWithFeatures( |
| 866 {}, {features::kRequireSecureOriginsForPepperMediaRequests}); |
| 867 } |
| 868 RequestPermissions( |
| 869 GetWebContents(), |
| 870 CreateRequestWithType(example_audio_id(), std::string(), |
| 871 content::MEDIA_OPEN_DEVICE_PEPPER_ONLY), |
| 872 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
| 873 base::Unretained(this))); |
| 874 ASSERT_EQ(2u, TotalPromptRequestCount()); |
861 | 875 |
862 ASSERT_EQ(content::MEDIA_DEVICE_OK, media_stream_result()); | 876 ASSERT_EQ(content::MEDIA_DEVICE_OK, media_stream_result()); |
863 ASSERT_TRUE(CheckDevicesListContains(content::MEDIA_DEVICE_AUDIO_CAPTURE)); | 877 ASSERT_TRUE(CheckDevicesListContains(content::MEDIA_DEVICE_AUDIO_CAPTURE)); |
864 ASSERT_FALSE(CheckDevicesListContains(content::MEDIA_DEVICE_VIDEO_CAPTURE)); | 878 ASSERT_FALSE(CheckDevicesListContains(content::MEDIA_DEVICE_VIDEO_CAPTURE)); |
| 879 } |
865 | 880 |
866 // Test that with the kRequireSecureOriginsForPepperMediaRequests flag enabled | |
867 // that permission will be denied. | |
868 ResetPromptCounters(); | 881 ResetPromptCounters(); |
869 base::test::ScopedFeatureList scoped_feature_list; | |
870 scoped_feature_list.InitAndEnableFeature( | |
871 features::kRequireSecureOriginsForPepperMediaRequests); | |
872 RequestPermissions( | 882 RequestPermissions( |
873 GetWebContents(), | 883 GetWebContents(), |
874 CreateRequestWithType(example_audio_id(), example_video_id(), | 884 CreateRequestWithType(example_audio_id(), example_video_id(), |
875 content::MEDIA_OPEN_DEVICE_PEPPER_ONLY), | 885 content::MEDIA_OPEN_DEVICE_PEPPER_ONLY), |
876 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, | 886 base::Bind(&MediaStreamDevicesControllerTest::OnMediaStreamResponse, |
877 base::Unretained(this))); | 887 base::Unretained(this))); |
878 ASSERT_EQ(0u, TotalPromptRequestCount()); | 888 ASSERT_EQ(0u, TotalPromptRequestCount()); |
879 | 889 |
880 ASSERT_EQ(content::MEDIA_DEVICE_PERMISSION_DENIED, media_stream_result()); | 890 ASSERT_EQ(content::MEDIA_DEVICE_PERMISSION_DENIED, media_stream_result()); |
881 ASSERT_FALSE(CheckDevicesListContains(content::MEDIA_DEVICE_AUDIO_CAPTURE)); | 891 ASSERT_FALSE(CheckDevicesListContains(content::MEDIA_DEVICE_AUDIO_CAPTURE)); |
(...skipping 29 matching lines...) Expand all Loading... |
911 ASSERT_EQ(content::MEDIA_DEVICE_KILL_SWITCH_ON, media_stream_result()); | 921 ASSERT_EQ(content::MEDIA_DEVICE_KILL_SWITCH_ON, media_stream_result()); |
912 ASSERT_FALSE(CheckDevicesListContains(content::MEDIA_DEVICE_AUDIO_CAPTURE)); | 922 ASSERT_FALSE(CheckDevicesListContains(content::MEDIA_DEVICE_AUDIO_CAPTURE)); |
913 ASSERT_FALSE(CheckDevicesListContains(content::MEDIA_DEVICE_VIDEO_CAPTURE)); | 923 ASSERT_FALSE(CheckDevicesListContains(content::MEDIA_DEVICE_VIDEO_CAPTURE)); |
914 } | 924 } |
915 | 925 |
916 INSTANTIATE_TEST_CASE_P( | 926 INSTANTIATE_TEST_CASE_P( |
917 MediaStreamDevicesControllerTestInstance, | 927 MediaStreamDevicesControllerTestInstance, |
918 MediaStreamDevicesControllerTest, | 928 MediaStreamDevicesControllerTest, |
919 ::testing::Values(TestType::DEFAULT, | 929 ::testing::Values(TestType::DEFAULT, |
920 TestType::TEST_WITH_GROUPED_MEDIA_REQUESTS)); | 930 TestType::TEST_WITH_GROUPED_MEDIA_REQUESTS)); |
OLD | NEW |