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

Side by Side Diff: chrome/browser/media/chrome_media_stream_infobar_browsertest.cc

Issue 1301653005: Setup for moving getUserMedia to secure origins only (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 5 years, 4 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 unified diff | Download patch
OLDNEW
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/media/media_stream_devices_controller.h" 9 #include "chrome/browser/media/media_stream_devices_controller.h"
10 #include "chrome/browser/media/webrtc_browsertest_base.h" 10 #include "chrome/browser/media/webrtc_browsertest_base.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 // Executes stopLocalStream() in the test page, which frees up an already 62 // Executes stopLocalStream() in the test page, which frees up an already
63 // acquired mediastream. 63 // acquired mediastream.
64 bool StopLocalStream(content::WebContents* tab_contents) { 64 bool StopLocalStream(content::WebContents* tab_contents) {
65 std::string result; 65 std::string result;
66 bool ok = content::ExecuteScriptAndExtractString( 66 bool ok = content::ExecuteScriptAndExtractString(
67 tab_contents, "stopLocalStream()", &result); 67 tab_contents, "stopLocalStream()", &result);
68 DCHECK(ok); 68 DCHECK(ok);
69 return result.compare("ok-stopped") == 0; 69 return result.compare("ok-stopped") == 0;
70 } 70 }
71 71
72 void useNonSecureOriginForTestPage() {
73 use_secure_origin_for_test_page_ = false;
tommi (sloooow) - chröme 2015/08/20 17:14:25 looks like this variable isn't needed anymore and
jww 2015/08/20 18:26:07 Good call. Done.
74 host_resolver()->AddRule("*", "127.0.0.1");
75 }
76
77 private: 72 private:
78 // The default test server is localhost, which is considered secure: 73 // The default test server is localhost, which is considered secure:
79 // http://www.w3.org/TR/powerful-features/#is-origin-trustworthy 74 // http://www.w3.org/TR/powerful-features/#is-origin-trustworthy
80 bool use_secure_origin_for_test_page_ = true; 75 bool use_secure_origin_for_test_page_ = true;
81 76
82 content::WebContents* LoadTestPageInBrowser(Browser* browser) { 77 content::WebContents* LoadTestPageInBrowser(Browser* browser) {
83 EXPECT_TRUE(test_server()->Start()); 78 EXPECT_TRUE(test_server()->Start());
84 79
85 GURL url; 80 GURL url;
86 81
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 GetUserMediaAndDismiss(tab_contents); 121 GetUserMediaAndDismiss(tab_contents);
127 } 122 }
128 123
129 IN_PROC_BROWSER_TEST_F(MediaStreamPermissionTest, 124 IN_PROC_BROWSER_TEST_F(MediaStreamPermissionTest,
130 TestDenyingUserMediaIncognito) { 125 TestDenyingUserMediaIncognito) {
131 content::WebContents* tab_contents = LoadTestPageInIncognitoTab(); 126 content::WebContents* tab_contents = LoadTestPageInIncognitoTab();
132 GetUserMediaAndDeny(tab_contents); 127 GetUserMediaAndDeny(tab_contents);
133 } 128 }
134 129
135 IN_PROC_BROWSER_TEST_F(MediaStreamPermissionTest, 130 IN_PROC_BROWSER_TEST_F(MediaStreamPermissionTest,
136 TestNonSecureOriginAcceptThenDenyIsSticky) {
137 #if defined(OS_WIN) && defined(USE_ASH)
138 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
139 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
140 switches::kAshBrowserTests))
141 return;
142 #endif
143
144 useNonSecureOriginForTestPage();
145 content::WebContents* tab_contents = LoadTestPageInTab();
146 EXPECT_FALSE(content::IsOriginSecure(tab_contents->GetLastCommittedURL()));
147
148 EXPECT_TRUE(GetUserMediaAndAccept(tab_contents));
149 GetUserMediaAndDeny(tab_contents);
150
151 GetUserMediaAndExpectAutoDenyWithoutPrompt(tab_contents);
152 }
153
154 IN_PROC_BROWSER_TEST_F(MediaStreamPermissionTest,
155 TestNonSecureOriginDenyIsSticky) {
156 useNonSecureOriginForTestPage();
157 content::WebContents* tab_contents = LoadTestPageInTab();
158 EXPECT_FALSE(content::IsOriginSecure(tab_contents->GetLastCommittedURL()));
159
160 GetUserMediaAndDeny(tab_contents);
161 GetUserMediaAndExpectAutoDenyWithoutPrompt(tab_contents);
162 }
163
164 IN_PROC_BROWSER_TEST_F(MediaStreamPermissionTest,
165 TestSecureOriginDenyIsSticky) { 131 TestSecureOriginDenyIsSticky) {
166 content::WebContents* tab_contents = LoadTestPageInTab(); 132 content::WebContents* tab_contents = LoadTestPageInTab();
167 EXPECT_TRUE(content::IsOriginSecure(tab_contents->GetLastCommittedURL())); 133 EXPECT_TRUE(content::IsOriginSecure(tab_contents->GetLastCommittedURL()));
168 134
169 GetUserMediaAndDeny(tab_contents); 135 GetUserMediaAndDeny(tab_contents);
170 GetUserMediaAndExpectAutoDenyWithoutPrompt(tab_contents); 136 GetUserMediaAndExpectAutoDenyWithoutPrompt(tab_contents);
171 } 137 }
172 138
173 IN_PROC_BROWSER_TEST_F(MediaStreamPermissionTest, 139 IN_PROC_BROWSER_TEST_F(MediaStreamPermissionTest,
174 TestNonSecureOriginAcceptIsNotSticky) {
175 useNonSecureOriginForTestPage();
176 content::WebContents* tab_contents = LoadTestPageInTab();
177 EXPECT_FALSE(content::IsOriginSecure(tab_contents->GetLastCommittedURL()));
178
179 EXPECT_TRUE(GetUserMediaAndAccept(tab_contents));
180 EXPECT_TRUE(GetUserMediaAndAccept(tab_contents));
181 }
182
183 IN_PROC_BROWSER_TEST_F(MediaStreamPermissionTest,
184 TestSecureOriginAcceptIsSticky) { 140 TestSecureOriginAcceptIsSticky) {
185 content::WebContents* tab_contents = LoadTestPageInTab(); 141 content::WebContents* tab_contents = LoadTestPageInTab();
186 EXPECT_TRUE(content::IsOriginSecure(tab_contents->GetLastCommittedURL())); 142 EXPECT_TRUE(content::IsOriginSecure(tab_contents->GetLastCommittedURL()));
187 143
188 EXPECT_TRUE(GetUserMediaAndAccept(tab_contents)); 144 EXPECT_TRUE(GetUserMediaAndAccept(tab_contents));
189 GetUserMediaAndExpectAutoAcceptWithoutPrompt(tab_contents); 145 GetUserMediaAndExpectAutoAcceptWithoutPrompt(tab_contents);
190 } 146 }
191 147
192 IN_PROC_BROWSER_TEST_F(MediaStreamPermissionTest, TestDismissIsNotSticky) { 148 IN_PROC_BROWSER_TEST_F(MediaStreamPermissionTest, TestDismissIsNotSticky) {
193 content::WebContents* tab_contents = LoadTestPageInTab(); 149 content::WebContents* tab_contents = LoadTestPageInTab();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 181
226 IN_PROC_BROWSER_TEST_F(MediaStreamPermissionTest, 182 IN_PROC_BROWSER_TEST_F(MediaStreamPermissionTest,
227 DenyingCameraDoesNotCauseStickyDenyForMics) { 183 DenyingCameraDoesNotCauseStickyDenyForMics) {
228 content::WebContents* tab_contents = LoadTestPageInTab(); 184 content::WebContents* tab_contents = LoadTestPageInTab();
229 185
230 GetUserMediaWithSpecificConstraintsAndDeny(tab_contents, 186 GetUserMediaWithSpecificConstraintsAndDeny(tab_contents,
231 kVideoOnlyCallConstraints); 187 kVideoOnlyCallConstraints);
232 EXPECT_TRUE(GetUserMediaWithSpecificConstraintsAndAccept( 188 EXPECT_TRUE(GetUserMediaWithSpecificConstraintsAndAccept(
233 tab_contents, kAudioOnlyCallConstraints)); 189 tab_contents, kAudioOnlyCallConstraints));
234 } 190 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698