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

Side by Side Diff: android_webview/javatests/src/org/chromium/android_webview/test/GeolocationTest.java

Issue 1515103003: Revert of Removal of geolocation APIs on insecure origins (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 5 years 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
« no previous file with comments | « no previous file | chrome/browser/geolocation/geolocation_permission_context.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 package org.chromium.android_webview.test; 5 package org.chromium.android_webview.test;
6 6
7 import android.test.suitebuilder.annotation.MediumTest; 7 import android.test.suitebuilder.annotation.MediumTest;
8 import android.test.suitebuilder.annotation.SmallTest; 8 import android.test.suitebuilder.annotation.SmallTest;
9 import android.webkit.GeolocationPermissions; 9 import android.webkit.GeolocationPermissions;
10 10
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 } 116 }
117 117
118 118
119 /** 119 /**
120 * Ensure that a call to navigator.getCurrentPosition works in WebView. 120 * Ensure that a call to navigator.getCurrentPosition works in WebView.
121 */ 121 */
122 @MediumTest 122 @MediumTest
123 @Feature({"AndroidWebView"}) 123 @Feature({"AndroidWebView"})
124 public void testGetPosition() throws Throwable { 124 public void testGetPosition() throws Throwable {
125 initAwContents(new GrantPermisionAwContentClient()); 125 initAwContents(new GrantPermisionAwContentClient());
126 loadDataWithBaseUrlSync(mAwContents, mContentsClient.getOnPageFinishedHe lper(), RAW_HTML, 126 loadDataSync(mAwContents, mContentsClient.getOnPageFinishedHelper(),
127 "text/html", false, "https://google.com/", "about:blank"); 127 RAW_HTML, "text/html", false);
128 128
129 mAwContents.evaluateJavaScriptForTests("initiate_getCurrentPosition();", null); 129 mAwContents.evaluateJavaScriptForTests("initiate_getCurrentPosition();", null);
130 130
131 poll(new Callable<Boolean>() { 131 poll(new Callable<Boolean>() {
132 @Override 132 @Override
133 public Boolean call() throws Exception { 133 public Boolean call() throws Exception {
134 return getPositionCountFromJS() == 1; 134 return getPositionCountFromJS() == 1;
135 } 135 }
136 }); 136 });
137 137
138 mAwContents.evaluateJavaScriptForTests("initiate_getCurrentPosition();", null); 138 mAwContents.evaluateJavaScriptForTests("initiate_getCurrentPosition();", null);
139 poll(new Callable<Boolean>() { 139 poll(new Callable<Boolean>() {
140 @Override 140 @Override
141 public Boolean call() throws Exception { 141 public Boolean call() throws Exception {
142 return getPositionCountFromJS() == 2; 142 return getPositionCountFromJS() == 2;
143 } 143 }
144 }); 144 });
145 } 145 }
146 146
147 /** 147 /**
148 * Ensure that a call to navigator.watchPosition works in WebView. 148 * Ensure that a call to navigator.watchPosition works in WebView.
149 */ 149 */
150 @MediumTest 150 @MediumTest
151 @Feature({"AndroidWebView"}) 151 @Feature({"AndroidWebView"})
152 public void testWatchPosition() throws Throwable { 152 public void testWatchPosition() throws Throwable {
153 initAwContents(new GrantPermisionAwContentClient()); 153 initAwContents(new GrantPermisionAwContentClient());
154 loadDataWithBaseUrlSync(mAwContents, mContentsClient.getOnPageFinishedHe lper(), RAW_HTML, 154 loadDataSync(mAwContents, mContentsClient.getOnPageFinishedHelper(),
155 "text/html", false, "https://google.com/", "about:blank"); 155 RAW_HTML, "text/html", false);
156 156
157 mAwContents.evaluateJavaScriptForTests("initiate_watchPosition();", null ); 157 mAwContents.evaluateJavaScriptForTests("initiate_watchPosition();", null );
158 158
159 poll(new Callable<Boolean>() { 159 poll(new Callable<Boolean>() {
160 @Override 160 @Override
161 public Boolean call() throws Exception { 161 public Boolean call() throws Exception {
162 return getPositionCountFromJS() > 1; 162 return getPositionCountFromJS() > 1;
163 } 163 }
164 }); 164 });
165 } 165 }
166 166
167 @MediumTest 167 @MediumTest
168 @Feature({"AndroidWebView"}) 168 @Feature({"AndroidWebView"})
169 public void testPauseGeolocationOnPause() throws Throwable { 169 public void testPauseGeolocationOnPause() throws Throwable {
170 initAwContents(new GrantPermisionAwContentClient()); 170 initAwContents(new GrantPermisionAwContentClient());
171 // Start a watch going. 171 // Start a watch going.
172 loadDataWithBaseUrlSync(mAwContents, mContentsClient.getOnPageFinishedHe lper(), RAW_HTML, 172 loadDataSync(mAwContents, mContentsClient.getOnPageFinishedHelper(),
173 "text/html", false, "https://google.com/", "about:blank"); 173 RAW_HTML, "text/html", false);
174 174
175 mAwContents.evaluateJavaScriptForTests("initiate_watchPosition();", null ); 175 mAwContents.evaluateJavaScriptForTests("initiate_watchPosition();", null );
176 176
177 poll(new Callable<Boolean>() { 177 poll(new Callable<Boolean>() {
178 @Override 178 @Override
179 public Boolean call() throws Exception { 179 public Boolean call() throws Exception {
180 return getPositionCountFromJS() > 1; 180 return getPositionCountFromJS() > 1;
181 } 181 }
182 }); 182 });
183 183
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 public void testPauseAwContentsBeforeNavigating() throws Throwable { 221 public void testPauseAwContentsBeforeNavigating() throws Throwable {
222 initAwContents(new GrantPermisionAwContentClient()); 222 initAwContents(new GrantPermisionAwContentClient());
223 getInstrumentation().runOnMainSync(new Runnable() { 223 getInstrumentation().runOnMainSync(new Runnable() {
224 @Override 224 @Override
225 public void run() { 225 public void run() {
226 mAwContents.onPause(); 226 mAwContents.onPause();
227 } 227 }
228 }); 228 });
229 229
230 // Start a watch going. 230 // Start a watch going.
231 loadDataWithBaseUrlSync(mAwContents, mContentsClient.getOnPageFinishedHe lper(), RAW_HTML, 231 loadDataSync(mAwContents, mContentsClient.getOnPageFinishedHelper(),
232 "text/html", false, "https://google.com/", "about:blank"); 232 RAW_HTML, "text/html", false);
233 233
234 mAwContents.evaluateJavaScriptForTests("initiate_watchPosition();", null ); 234 mAwContents.evaluateJavaScriptForTests("initiate_watchPosition();", null );
235 235
236 assertEquals(0, getPositionCountFromJS()); 236 assertEquals(0, getPositionCountFromJS());
237 237
238 ensureGeolocationRunning(false); 238 ensureGeolocationRunning(false);
239 239
240 getInstrumentation().runOnMainSync(new Runnable() { 240 getInstrumentation().runOnMainSync(new Runnable() {
241 @Override 241 @Override
242 public void run() { 242 public void run() {
(...skipping 15 matching lines...) Expand all
258 @Feature({"AndroidWebView"}) 258 @Feature({"AndroidWebView"})
259 public void testResumeWhenNotStarted() throws Throwable { 259 public void testResumeWhenNotStarted() throws Throwable {
260 initAwContents(new GrantPermisionAwContentClient()); 260 initAwContents(new GrantPermisionAwContentClient());
261 getInstrumentation().runOnMainSync(new Runnable() { 261 getInstrumentation().runOnMainSync(new Runnable() {
262 @Override 262 @Override
263 public void run() { 263 public void run() {
264 mAwContents.onPause(); 264 mAwContents.onPause();
265 } 265 }
266 }); 266 });
267 267
268 loadDataWithBaseUrlSync(mAwContents, mContentsClient.getOnPageFinishedHe lper(), RAW_HTML, 268 loadDataSync(mAwContents, mContentsClient.getOnPageFinishedHelper(),
269 "text/html", false, "https://google.com/", "about:blank"); 269 RAW_HTML, "text/html", false);
270 270
271 getInstrumentation().runOnMainSync(new Runnable() { 271 getInstrumentation().runOnMainSync(new Runnable() {
272 @Override 272 @Override
273 public void run() { 273 public void run() {
274 mAwContents.onResume(); 274 mAwContents.onResume();
275 } 275 }
276 }); 276 });
277 277
278 ensureGeolocationRunning(false); 278 ensureGeolocationRunning(false);
279 } 279 }
280 280
281 @Feature({"AndroidWebView"}) 281 @Feature({"AndroidWebView"})
282 @SmallTest 282 @SmallTest
283 public void testDenyAccessByDefault() throws Throwable { 283 public void testDenyAccessByDefault() throws Throwable {
284 initAwContents(new DefaultPermisionAwContentClient()); 284 initAwContents(new DefaultPermisionAwContentClient());
285 loadDataWithBaseUrlSync(mAwContents, mContentsClient.getOnPageFinishedHe lper(), RAW_HTML, 285 loadDataSync(mAwContents, mContentsClient.getOnPageFinishedHelper(),
286 "text/html", false, "https://google.com/", "about:blank"); 286 RAW_HTML, "text/html", false);
287 287
288 mAwContents.evaluateJavaScriptForTests("initiate_getCurrentPosition();", null); 288 mAwContents.evaluateJavaScriptForTests("initiate_getCurrentPosition();", null);
289 289
290 poll(new Callable<Boolean>() { 290 poll(new Callable<Boolean>() {
291 @SuppressFBWarnings("DM_GC") 291 @SuppressFBWarnings("DM_GC")
292 @Override 292 @Override
293 public Boolean call() throws Exception { 293 public Boolean call() throws Exception {
294 Runtime.getRuntime().gc(); 294 Runtime.getRuntime().gc();
295 return "deny".equals(getTitleOnUiThread(mAwContents)); 295 return "deny".equals(getTitleOnUiThread(mAwContents));
296 } 296 }
297 }); 297 });
298 } 298 }
299 299
300 } 300 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/geolocation/geolocation_permission_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698