Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1518)

Unified Diff: chrome/browser/media/chrome_media_stream_infobar_browsertest.cc

Issue 338753002: Revert of Revert: Per navigation sticky media permissions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/media/media_stream_devices_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/media/chrome_media_stream_infobar_browsertest.cc
diff --git a/chrome/browser/media/chrome_media_stream_infobar_browsertest.cc b/chrome/browser/media/chrome_media_stream_infobar_browsertest.cc
index 4c9dd5f09b3f6bbb1474cb25c17d151d8b0eb41c..07c4f0b083a2aecbf953feae8bfde65fbcf68521 100644
--- a/chrome/browser/media/chrome_media_stream_infobar_browsertest.cc
+++ b/chrome/browser/media/chrome_media_stream_infobar_browsertest.cc
@@ -152,7 +152,7 @@
content::WebContents* tab_contents = LoadTestPageInTab();
GetUserMediaAndAccept(tab_contents);
- GetUserMediaAndDeny(tab_contents);
+ DenyRequest(tab_contents, content::MEDIA_DEVICE_PERMISSION_DENIED);
// Should fail with permission denied right away with no infobar popping up.
GetUserMedia(tab_contents, kAudioVideoCallConstraints);
@@ -177,7 +177,56 @@
// If accept were sticky the second call would hang because it hangs if an
// infobar does not pop up.
GetUserMediaAndAccept(tab_contents);
- GetUserMediaAndAccept(tab_contents);
+
+ // Because http request permissions are sticky per navigation, we need to
+ // navigate away from the current page in order to verify that the granted
+ // permissions are not permanently sticky.
+ ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(browser(),
+ GURL("about:blank"), 1);
+
+ // Now navigate back to our test page.
+ ui_test_utils::NavigateToURL(browser(), test_page_url());
+ tab_contents = browser()->tab_strip_model()->GetActiveWebContents();
+
+ GetUserMediaAndAccept(tab_contents);
+}
+
+// Test that accepting one getUserMedia request will not require a second
+// prompt when issuing a second getUserMedia request.
+IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest,
+ TestAcceptIsStickyPerNavigation) {
+ content::WebContents* tab_contents = LoadTestPageInTab();
+
+ GetUserMediaAndAccept(tab_contents);
+
+ // Before issuing the second gUM request, make sure we first stop the tracks
+ // we started with the first request. If they're still running the permissions
+ // will be active for other reasons and we won't be testing the temporary
+ // stickiness properly.
+ EXPECT_TRUE(StopLocalStream(tab_contents));
+
+ // Now no media tracks are running, so let's issue the second request.
+ GetUserMedia(tab_contents, kAudioVideoCallConstraints);
+}
+
+IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest,
+ TestTwoAcceptsPlusStickyPerNavigation) {
+ content::WebContents* tab_contents = LoadTestPageInTab();
+
+ // First ask for audio only and approve.
+ GetUserMediaWithSpecificConstraintsAndAccept(tab_contents,
+ kAudioOnlyCallConstraints);
+ EXPECT_TRUE(StopLocalStream(tab_contents));
+
+ // Next ask for video permissions.
+ // This will hang if the previous gUM call somehow gave video permissions.
+ GetUserMediaWithSpecificConstraintsAndAccept(tab_contents,
+ kVideoOnlyCallConstraints);
+ EXPECT_TRUE(StopLocalStream(tab_contents));
+
+ // Now ask for both audio and video and expect the call to go through without
+ // showing any UI.
+ GetUserMedia(tab_contents, kAudioVideoCallConstraints);
}
IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, TestDismissIsNotSticky) {
« no previous file with comments | « no previous file | chrome/browser/media/media_stream_devices_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698