| 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/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/content_settings/host_content_settings_map.h" | 10 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 MAYBE_TestAcceptThenDenyWhichShouldBeSticky) { | 145 MAYBE_TestAcceptThenDenyWhichShouldBeSticky) { |
| 146 #if defined(OS_WIN) && defined(USE_ASH) | 146 #if defined(OS_WIN) && defined(USE_ASH) |
| 147 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 147 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
| 148 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 148 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
| 149 return; | 149 return; |
| 150 #endif | 150 #endif |
| 151 | 151 |
| 152 content::WebContents* tab_contents = LoadTestPageInTab(); | 152 content::WebContents* tab_contents = LoadTestPageInTab(); |
| 153 | 153 |
| 154 GetUserMediaAndAccept(tab_contents); | 154 GetUserMediaAndAccept(tab_contents); |
| 155 GetUserMediaAndDeny(tab_contents); | 155 DenyRequest(tab_contents, content::MEDIA_DEVICE_PERMISSION_DENIED); |
| 156 | 156 |
| 157 // Should fail with permission denied right away with no infobar popping up. | 157 // Should fail with permission denied right away with no infobar popping up. |
| 158 GetUserMedia(tab_contents, kAudioVideoCallConstraints); | 158 GetUserMedia(tab_contents, kAudioVideoCallConstraints); |
| 159 EXPECT_TRUE(test::PollingWaitUntil("obtainGetUserMediaResult()", | 159 EXPECT_TRUE(test::PollingWaitUntil("obtainGetUserMediaResult()", |
| 160 kFailedWithPermissionDeniedError, | 160 kFailedWithPermissionDeniedError, |
| 161 tab_contents)); | 161 tab_contents)); |
| 162 InfoBarService* infobar_service = | 162 InfoBarService* infobar_service = |
| 163 InfoBarService::FromWebContents(tab_contents); | 163 InfoBarService::FromWebContents(tab_contents); |
| 164 EXPECT_EQ(0u, infobar_service->infobar_count()); | 164 EXPECT_EQ(0u, infobar_service->infobar_count()); |
| 165 } | 165 } |
| 166 | 166 |
| 167 // Failing on Win Aura, so disabling on that. | 167 // Failing on Win Aura, so disabling on that. |
| 168 // See http://crbug.com/263333. | 168 // See http://crbug.com/263333. |
| 169 #if defined(USE_AURA) | 169 #if defined(USE_AURA) |
| 170 #define MAYBE_TestAcceptIsNotSticky DISABLED_TestAcceptIsNotSticky | 170 #define MAYBE_TestAcceptIsNotSticky DISABLED_TestAcceptIsNotSticky |
| 171 #else | 171 #else |
| 172 #define MAYBE_TestAcceptIsNotSticky TestAcceptIsNotSticky | 172 #define MAYBE_TestAcceptIsNotSticky TestAcceptIsNotSticky |
| 173 #endif | 173 #endif |
| 174 IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, MAYBE_TestAcceptIsNotSticky) { | 174 IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, MAYBE_TestAcceptIsNotSticky) { |
| 175 content::WebContents* tab_contents = LoadTestPageInTab(); | 175 content::WebContents* tab_contents = LoadTestPageInTab(); |
| 176 | 176 |
| 177 // If accept were sticky the second call would hang because it hangs if an | 177 // If accept were sticky the second call would hang because it hangs if an |
| 178 // infobar does not pop up. | 178 // infobar does not pop up. |
| 179 GetUserMediaAndAccept(tab_contents); | 179 GetUserMediaAndAccept(tab_contents); |
| 180 |
| 181 // Because http request permissions are sticky per navigation, we need to |
| 182 // navigate away from the current page in order to verify that the granted |
| 183 // permissions are not permanently sticky. |
| 184 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(browser(), |
| 185 GURL("about:blank"), 1); |
| 186 |
| 187 // Now navigate back to our test page. |
| 188 ui_test_utils::NavigateToURL(browser(), test_page_url()); |
| 189 tab_contents = browser()->tab_strip_model()->GetActiveWebContents(); |
| 190 |
| 180 GetUserMediaAndAccept(tab_contents); | 191 GetUserMediaAndAccept(tab_contents); |
| 181 } | 192 } |
| 182 | 193 |
| 194 // Test that accepting one getUserMedia request will not require a second |
| 195 // prompt when issuing a second getUserMedia request. |
| 196 IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, |
| 197 TestAcceptIsStickyPerNavigation) { |
| 198 content::WebContents* tab_contents = LoadTestPageInTab(); |
| 199 |
| 200 GetUserMediaAndAccept(tab_contents); |
| 201 |
| 202 // Before issuing the second gUM request, make sure we first stop the tracks |
| 203 // we started with the first request. If they're still running the permissions |
| 204 // will be active for other reasons and we won't be testing the temporary |
| 205 // stickiness properly. |
| 206 EXPECT_TRUE(StopLocalStream(tab_contents)); |
| 207 |
| 208 // Now no media tracks are running, so let's issue the second request. |
| 209 GetUserMedia(tab_contents, kAudioVideoCallConstraints); |
| 210 } |
| 211 |
| 212 IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, |
| 213 TestTwoAcceptsPlusStickyPerNavigation) { |
| 214 content::WebContents* tab_contents = LoadTestPageInTab(); |
| 215 |
| 216 // First ask for audio only and approve. |
| 217 GetUserMediaWithSpecificConstraintsAndAccept(tab_contents, |
| 218 kAudioOnlyCallConstraints); |
| 219 EXPECT_TRUE(StopLocalStream(tab_contents)); |
| 220 |
| 221 // Next ask for video permissions. |
| 222 // This will hang if the previous gUM call somehow gave video permissions. |
| 223 GetUserMediaWithSpecificConstraintsAndAccept(tab_contents, |
| 224 kVideoOnlyCallConstraints); |
| 225 EXPECT_TRUE(StopLocalStream(tab_contents)); |
| 226 |
| 227 // Now ask for both audio and video and expect the call to go through without |
| 228 // showing any UI. |
| 229 GetUserMedia(tab_contents, kAudioVideoCallConstraints); |
| 230 } |
| 231 |
| 183 IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, TestDismissIsNotSticky) { | 232 IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, TestDismissIsNotSticky) { |
| 184 content::WebContents* tab_contents = LoadTestPageInTab(); | 233 content::WebContents* tab_contents = LoadTestPageInTab(); |
| 185 | 234 |
| 186 // If dismiss were sticky the second call would hang because it hangs if an | 235 // If dismiss were sticky the second call would hang because it hangs if an |
| 187 // infobar does not pop up. | 236 // infobar does not pop up. |
| 188 GetUserMediaAndDismiss(tab_contents); | 237 GetUserMediaAndDismiss(tab_contents); |
| 189 GetUserMediaAndDismiss(tab_contents); | 238 GetUserMediaAndDismiss(tab_contents); |
| 190 } | 239 } |
| 191 | 240 |
| 192 IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, | 241 IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, | 284 IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, |
| 236 MAYBE_DenyingCameraDoesNotCauseStickyDenyForMics) { | 285 MAYBE_DenyingCameraDoesNotCauseStickyDenyForMics) { |
| 237 content::WebContents* tab_contents = LoadTestPageInTab(); | 286 content::WebContents* tab_contents = LoadTestPageInTab(); |
| 238 | 287 |
| 239 // If camera blocking also blocked mics, the second call here would hang. | 288 // If camera blocking also blocked mics, the second call here would hang. |
| 240 GetUserMediaWithSpecificConstraintsAndDeny(tab_contents, | 289 GetUserMediaWithSpecificConstraintsAndDeny(tab_contents, |
| 241 kVideoOnlyCallConstraints); | 290 kVideoOnlyCallConstraints); |
| 242 GetUserMediaWithSpecificConstraintsAndAccept(tab_contents, | 291 GetUserMediaWithSpecificConstraintsAndAccept(tab_contents, |
| 243 kAudioOnlyCallConstraints); | 292 kAudioOnlyCallConstraints); |
| 244 } | 293 } |
| OLD | NEW |