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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
9 #include "chrome/browser/infobars/infobar_service.h" | |
10 #include "chrome/browser/media/media_stream_devices_controller.h" | 9 #include "chrome/browser/media/media_stream_devices_controller.h" |
11 #include "chrome/browser/media/webrtc_browsertest_base.h" | 10 #include "chrome/browser/media/webrtc_browsertest_base.h" |
12 #include "chrome/browser/media/webrtc_browsertest_common.h" | 11 #include "chrome/browser/media/webrtc_browsertest_common.h" |
13 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
15 #include "chrome/browser/ui/browser_tabstrip.h" | 14 #include "chrome/browser/ui/browser_tabstrip.h" |
16 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
17 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" | 16 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" |
18 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
19 #include "chrome/test/base/in_process_browser_test.h" | 18 #include "chrome/test/base/in_process_browser_test.h" |
20 #include "chrome/test/base/test_switches.h" | 19 #include "chrome/test/base/test_switches.h" |
21 #include "chrome/test/base/ui_test_utils.h" | 20 #include "chrome/test/base/ui_test_utils.h" |
22 #include "components/content_settings/core/browser/host_content_settings_map.h" | 21 #include "components/content_settings/core/browser/host_content_settings_map.h" |
23 #include "components/content_settings/core/common/content_settings_types.h" | 22 #include "components/content_settings/core/common/content_settings_types.h" |
24 #include "components/infobars/core/infobar.h" | |
25 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
26 #include "content/public/common/media_stream_request.h" | 24 #include "content/public/common/media_stream_request.h" |
27 #include "content/public/test/browser_test_utils.h" | 25 #include "content/public/test/browser_test_utils.h" |
28 #include "media/base/media_switches.h" | 26 #include "media/base/media_switches.h" |
29 #include "net/test/spawned_test_server/spawned_test_server.h" | 27 #include "net/test/spawned_test_server/spawned_test_server.h" |
30 | 28 |
31 // MediaStreamPermissionTest --------------------------------------------------- | 29 // MediaStreamPermissionTest --------------------------------------------------- |
32 | 30 |
33 class MediaStreamPermissionTest : public WebRtcTestBase, | 31 class MediaStreamPermissionTest : public WebRtcTestBase, |
34 public testing::WithParamInterface<bool> { | 32 public testing::WithParamInterface<bool> { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 // Dummy callback for when we deny the current request directly. | 105 // Dummy callback for when we deny the current request directly. |
108 static void OnMediaStreamResponse(const content::MediaStreamDevices& devices, | 106 static void OnMediaStreamResponse(const content::MediaStreamDevices& devices, |
109 content::MediaStreamRequestResult result, | 107 content::MediaStreamRequestResult result, |
110 scoped_ptr<content::MediaStreamUI> ui) {} | 108 scoped_ptr<content::MediaStreamUI> ui) {} |
111 | 109 |
112 DISALLOW_COPY_AND_ASSIGN(MediaStreamPermissionTest); | 110 DISALLOW_COPY_AND_ASSIGN(MediaStreamPermissionTest); |
113 }; | 111 }; |
114 | 112 |
115 // Actual tests --------------------------------------------------------------- | 113 // Actual tests --------------------------------------------------------------- |
116 | 114 |
117 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, | 115 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, TestAllowingUserMedia) { |
118 DISABLED_TestAllowingUserMedia) { | |
119 content::WebContents* tab_contents = LoadTestPageInTab(); | 116 content::WebContents* tab_contents = LoadTestPageInTab(); |
120 EXPECT_TRUE(GetUserMediaAndAccept(tab_contents)); | 117 EXPECT_TRUE(GetUserMediaAndAccept(tab_contents)); |
121 } | 118 } |
122 | 119 |
123 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, | 120 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, TestDenyingUserMedia) { |
124 DISABLED_TestDenyingUserMedia) { | |
125 content::WebContents* tab_contents = LoadTestPageInTab(); | 121 content::WebContents* tab_contents = LoadTestPageInTab(); |
126 GetUserMediaAndDeny(tab_contents); | 122 GetUserMediaAndDeny(tab_contents); |
127 } | 123 } |
128 | 124 |
129 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, | 125 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, TestDismissingRequest) { |
130 DISABLED_TestDismissingInfobar) { | |
131 content::WebContents* tab_contents = LoadTestPageInTab(); | 126 content::WebContents* tab_contents = LoadTestPageInTab(); |
132 GetUserMediaAndDismiss(tab_contents); | 127 GetUserMediaAndDismiss(tab_contents); |
133 } | 128 } |
134 | 129 |
135 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, | 130 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, |
136 DISABLED_TestDenyingUserMediaIncognito) { | 131 TestDenyingUserMediaIncognito) { |
137 content::WebContents* tab_contents = LoadTestPageInIncognitoTab(); | 132 content::WebContents* tab_contents = LoadTestPageInIncognitoTab(); |
138 GetUserMediaAndDeny(tab_contents); | 133 GetUserMediaAndDeny(tab_contents); |
139 } | 134 } |
140 | 135 |
141 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, | 136 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, |
142 DISABLED_TestAcceptThenDenyWhichShouldBeSticky) { | 137 TestAcceptThenDenyWhichShouldBeSticky) { |
143 #if defined(OS_WIN) && defined(USE_ASH) | 138 #if defined(OS_WIN) && defined(USE_ASH) |
144 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 139 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
145 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 140 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
146 switches::kAshBrowserTests)) | 141 switches::kAshBrowserTests)) |
147 return; | 142 return; |
148 #endif | 143 #endif |
149 | 144 |
150 content::WebContents* tab_contents = LoadTestPageInTab(); | 145 content::WebContents* tab_contents = LoadTestPageInTab(); |
151 | 146 |
152 EXPECT_TRUE(GetUserMediaAndAccept(tab_contents)); | 147 EXPECT_TRUE(GetUserMediaAndAccept(tab_contents)); |
153 GetUserMediaAndDeny(tab_contents); | 148 GetUserMediaAndDeny(tab_contents); |
154 | 149 |
155 // Should fail with permission denied right away with no infobar popping up. | 150 // Should fail with permission denied, instead of hanging. |
156 GetUserMedia(tab_contents, kAudioVideoCallConstraints); | 151 GetUserMedia(tab_contents, kAudioVideoCallConstraints); |
157 EXPECT_TRUE(test::PollingWaitUntil("obtainGetUserMediaResult()", | 152 EXPECT_TRUE(test::PollingWaitUntil("obtainGetUserMediaResult()", |
158 kFailedWithPermissionDeniedError, | 153 kFailedWithPermissionDeniedError, |
159 tab_contents)); | 154 tab_contents)); |
160 InfoBarService* infobar_service = | |
161 InfoBarService::FromWebContents(tab_contents); | |
162 EXPECT_EQ(0u, infobar_service->infobar_count()); | |
163 } | 155 } |
164 | 156 |
165 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, | 157 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, TestAcceptIsNotSticky) { |
166 DISABLED_TestAcceptIsNotSticky) { | |
167 content::WebContents* tab_contents = LoadTestPageInTab(); | 158 content::WebContents* tab_contents = LoadTestPageInTab(); |
168 | 159 |
169 // If accept were sticky the second call would hang because it hangs if an | 160 // If accept were sticky the second call would hang because it hangs if an |
170 // infobar does not pop up. | 161 // infobar or bubble does not pop up. |
171 EXPECT_TRUE(GetUserMediaAndAccept(tab_contents)); | 162 EXPECT_TRUE(GetUserMediaAndAccept(tab_contents)); |
172 EXPECT_TRUE(GetUserMediaAndAccept(tab_contents)); | 163 EXPECT_TRUE(GetUserMediaAndAccept(tab_contents)); |
173 } | 164 } |
174 | 165 |
175 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, | 166 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, TestDismissIsNotSticky) { |
176 DISABLED_TestDismissIsNotSticky) { | |
177 content::WebContents* tab_contents = LoadTestPageInTab(); | 167 content::WebContents* tab_contents = LoadTestPageInTab(); |
178 | 168 |
179 // If dismiss were sticky the second call would hang because it hangs if an | 169 // If dismiss were sticky the second call would hang because it hangs if an |
180 // infobar does not pop up. | 170 // infobar or bubble does not pop up. |
181 GetUserMediaAndDismiss(tab_contents); | 171 GetUserMediaAndDismiss(tab_contents); |
182 GetUserMediaAndDismiss(tab_contents); | 172 GetUserMediaAndDismiss(tab_contents); |
183 } | 173 } |
184 | 174 |
185 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, | 175 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, |
186 DISABLED_TestDenyingThenClearingStickyException) { | 176 TestDenyingThenClearingStickyException) { |
187 content::WebContents* tab_contents = LoadTestPageInTab(); | 177 content::WebContents* tab_contents = LoadTestPageInTab(); |
188 | 178 |
189 GetUserMediaAndDeny(tab_contents); | 179 GetUserMediaAndDeny(tab_contents); |
190 | 180 |
191 HostContentSettingsMap* settings_map = | 181 HostContentSettingsMap* settings_map = |
192 browser()->profile()->GetHostContentSettingsMap(); | 182 browser()->profile()->GetHostContentSettingsMap(); |
193 | 183 |
194 settings_map->ClearSettingsForOneType(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); | 184 settings_map->ClearSettingsForOneType(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC); |
195 settings_map->ClearSettingsForOneType( | 185 settings_map->ClearSettingsForOneType( |
196 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); | 186 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA); |
197 | 187 |
198 // If an infobar is not launched now, this will hang. | 188 // If an infobar or bubble is not launched now, this will hang. |
199 GetUserMediaAndDeny(tab_contents); | 189 GetUserMediaAndDeny(tab_contents); |
200 } | 190 } |
201 | 191 |
202 // Times out on win debug builds; http://crbug.com/295723 . | 192 // Times out on win debug builds; http://crbug.com/295723 . |
203 #if defined(OS_WIN) && !defined(NDEBUG) | 193 #if defined(OS_WIN) && !defined(NDEBUG) |
204 #define MAYBE_DenyingMicDoesNotCauseStickyDenyForCameras \ | 194 #define MAYBE_DenyingMicDoesNotCauseStickyDenyForCameras \ |
205 DISABLED_DenyingMicDoesNotCauseStickyDenyForCameras | 195 DISABLED_DenyingMicDoesNotCauseStickyDenyForCameras |
206 #else | 196 #else |
207 #define MAYBE_DenyingMicDoesNotCauseStickyDenyForCameras \ | 197 #define MAYBE_DenyingMicDoesNotCauseStickyDenyForCameras \ |
208 DenyingMicDoesNotCauseStickyDenyForCameras | 198 DenyingMicDoesNotCauseStickyDenyForCameras |
209 #endif | 199 #endif |
210 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, | 200 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, |
211 MAYBE_DenyingMicDoesNotCauseStickyDenyForCameras) { | 201 MAYBE_DenyingMicDoesNotCauseStickyDenyForCameras) { |
212 content::WebContents* tab_contents = LoadTestPageInTab(); | 202 content::WebContents* tab_contents = LoadTestPageInTab(); |
213 | 203 |
214 // If mic blocking also blocked cameras, the second call here would hang. | 204 // If mic blocking also blocked cameras, the second call here would hang. |
215 GetUserMediaWithSpecificConstraintsAndDeny(tab_contents, | 205 GetUserMediaWithSpecificConstraintsAndDeny(tab_contents, |
216 kAudioOnlyCallConstraints); | 206 kAudioOnlyCallConstraints); |
217 EXPECT_TRUE(GetUserMediaWithSpecificConstraintsAndAccept( | 207 EXPECT_TRUE(GetUserMediaWithSpecificConstraintsAndAccept( |
218 tab_contents, kVideoOnlyCallConstraints)); | 208 tab_contents, kVideoOnlyCallConstraints)); |
219 } | 209 } |
220 | 210 |
221 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, | 211 IN_PROC_BROWSER_TEST_P(MediaStreamPermissionTest, |
222 DISABLED_DenyingCameraDoesNotCauseStickyDenyForMics) { | 212 DenyingCameraDoesNotCauseStickyDenyForMics) { |
223 content::WebContents* tab_contents = LoadTestPageInTab(); | 213 content::WebContents* tab_contents = LoadTestPageInTab(); |
224 | 214 |
225 // If camera blocking also blocked mics, the second call here would hang. | 215 // If camera blocking also blocked mics, the second call here would hang. |
226 GetUserMediaWithSpecificConstraintsAndDeny(tab_contents, | 216 GetUserMediaWithSpecificConstraintsAndDeny(tab_contents, |
227 kVideoOnlyCallConstraints); | 217 kVideoOnlyCallConstraints); |
228 EXPECT_TRUE(GetUserMediaWithSpecificConstraintsAndAccept( | 218 EXPECT_TRUE(GetUserMediaWithSpecificConstraintsAndAccept( |
229 tab_contents, kAudioOnlyCallConstraints)); | 219 tab_contents, kAudioOnlyCallConstraints)); |
230 } | 220 } |
231 | 221 |
232 INSTANTIATE_TEST_CASE_P(MediaStreamPermissionTestWithParams, | 222 INSTANTIATE_TEST_CASE_P(MediaStreamPermissionTestWithParams, |
233 MediaStreamPermissionTest, | 223 MediaStreamPermissionTest, |
234 testing::Values(false, true)); | 224 testing::Values(false, true)); |
OLD | NEW |