| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
[RuntimeEnabled=ApproximateGeolocationPermission] readonly attribute AccuracyMode accuracyMode;This needs to be guarded behind a different feature flag (ApproximateGeolocationPermissionAPIChanges or something similar), which can only be enabled if ApproximateGeolocationPermission is enabled (or which enables the ApproximateGeolocationPermission transitively).
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Commit-Queue | +1 |
[RuntimeEnabled=ApproximateGeolocationPermission] readonly attribute AccuracyMode accuracyMode;This needs to be guarded behind a different feature flag (ApproximateGeolocationPermissionAPIChanges or something similar), which can only be enabled if ApproximateGeolocationPermission is enabled (or which enables the ApproximateGeolocationPermission transitively).
Added a ApproximateGeolocationWebVisibleAPI feature flag.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
@Features.EnableFeatures({PermissionsAndroidFeatureList.APPROXIMATE_GEOLOCATION_PERMISSION})nit: you don't need braces {} if you only have one feature
ContentSettingsType.GEOLOCATION,shouldn't you set GEOLOCATION_WITH_OPTIONS?
mPermissionRule.runJavaScriptCodeInCurrentTabWithGesture(runJavaScriptCodeInCurrentTab should return the value from javascript. My understanding is that it should even work with promises. Can you try to use that instead of relying on the window title (!) being updated?
runTest(/* precise= */ true);can we inline the test content here instead? You can use a parameter for precise, as in https://source.chromium.org/chromium/chromium/src/+/main:base/test/android/junit/src/org/chromium/base/test/params/ExampleParameterizedTest.java;l=85;drc=6d903dddebf88f24cf9f9ba504777ea4b81f429b
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
const expectedPosition = {timestamp, coords: mockCoords, accuracyMode: 'precise'};Currently the geolocation test in wpt_internal is using `third_party/blink/web_tests/wpt_internal/geolocation-api/resources/geolocation-mock.js` to intercept mojo message from blink. Hence the `setGeolocationPosition` and `makeGeoposition` need to be updated for having `accuracyMode` set too.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
@Features.EnableFeatures({PermissionsAndroidFeatureList.APPROXIMATE_GEOLOCATION_PERMISSION})nit: you don't need braces {} if you only have one feature
Done
shouldn't you set GEOLOCATION_WITH_OPTIONS?
Done
mPermissionRule.runJavaScriptCodeInCurrentTabWithGesture(runJavaScriptCodeInCurrentTab should return the value from javascript. My understanding is that it should even work with promises. Can you try to use that instead of relying on the window title (!) being updated?
I used the same mechanism as [related tests](https://source.chromium.org/chromium/chromium/src/+/main:chrome/android/javatests/src/org/chromium/chrome/browser/permissions/RuntimePermissionTestUtils.java;l=166-199) here. However, I agree that relying on window title is not ideal, and was already working on a better approach in a follow-up CL. That CL will also combine both the API and `<geolocation>` permissions into a single test. Is it fine if I address this comment there?
can we inline the test content here instead? You can use a parameter for precise, as in https://source.chromium.org/chromium/chromium/src/+/main:base/test/android/junit/src/org/chromium/base/test/params/ExampleParameterizedTest.java;l=85;drc=6d903dddebf88f24cf9f9ba504777ea4b81f429b
Done
const expectedPosition = {timestamp, coords: mockCoords, accuracyMode: 'precise'};Currently the geolocation test in wpt_internal is using `third_party/blink/web_tests/wpt_internal/geolocation-api/resources/geolocation-mock.js` to intercept mojo message from blink. Hence the `setGeolocationPosition` and `makeGeoposition` need to be updated for having `accuracyMode` set too.
Updated, and added test that checks both precise and approximate accuracy modes.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
mPermissionRule.runJavaScriptCodeInCurrentTabWithGesture(Tom Van GoethemrunJavaScriptCodeInCurrentTab should return the value from javascript. My understanding is that it should even work with promises. Can you try to use that instead of relying on the window title (!) being updated?
I used the same mechanism as [related tests](https://source.chromium.org/chromium/chromium/src/+/main:chrome/android/javatests/src/org/chromium/chrome/browser/permissions/RuntimePermissionTestUtils.java;l=166-199) here. However, I agree that relying on window title is not ideal, and was already working on a better approach in a follow-up CL. That CL will also combine both the API and `<geolocation>` permissions into a single test. Is it fine if I address this comment there?
I guess it is :)
promise_test(async () => {
mock.setGeolocationPermission(false, true);
mock.setGeolocationPosition(mockCoords.latitude,
mockCoords.longitude,
mockCoords.accuracy);
const position = await new Promise((resolve, reject) => {
navigator.geolocation.getCurrentPosition(
resolve,
(e) => reject(new Error(`Error callback invoked unexpectedly: ${e.message}`)));
});
assert_object_equals(position.coords.toJSON(), mockCoords);
const timestamp = position.timestamp;
const expectedPosition = {timestamp, coords: mockCoords};
if (internals.runtimeFlags.approximateGeolocationWebVisibleAPIEnabled) {
expectedPosition.accuracyMode = 'approximate';
}
assert_object_equals(position.toJSON(), expectedPosition);
}, "Tests toJSON() on GeolocationPosition and GeolocationCoordinates with approximate permission.");(nit) There seems to be a lot of duplicated logic here. Maybe you could just have parametrized tests? E.g.
```js
[ true, false ].forEach(isPrecise => {
promise_test(async () => {
// ...
});
});
```
(feel free to improve e.g. with named params.)
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
LGTM with comments.
EqualIgnoringASCIICase(params.new_value, kAccuracyModePrecise));Should we also remove `kAccuracyModePrecise` if now we don't use it?.
setTimeout(() => {this.createGeolocation(receiver, user_gesture)}, 50);This `setTimeout` call is not reachable in base version of the code. I think we should remove it here.
EqualIgnoringASCIICase(params.new_value, kAccuracyModePrecise));Should we also remove `kAccuracyModePrecise` if now we don't use it?.
It is removed (see line 22). Unless I'm missing something?
promise_test(async () => {
mock.setGeolocationPermission(false, true);
mock.setGeolocationPosition(mockCoords.latitude,
mockCoords.longitude,
mockCoords.accuracy);
const position = await new Promise((resolve, reject) => {
navigator.geolocation.getCurrentPosition(
resolve,
(e) => reject(new Error(`Error callback invoked unexpectedly: ${e.message}`)));
});
assert_object_equals(position.coords.toJSON(), mockCoords);
const timestamp = position.timestamp;
const expectedPosition = {timestamp, coords: mockCoords};
if (internals.runtimeFlags.approximateGeolocationWebVisibleAPIEnabled) {
expectedPosition.accuracyMode = 'approximate';
}
assert_object_equals(position.toJSON(), expectedPosition);
}, "Tests toJSON() on GeolocationPosition and GeolocationCoordinates with approximate permission.");(nit) There seems to be a lot of duplicated logic here. Maybe you could just have parametrized tests? E.g.
```js
[ true, false ].forEach(isPrecise => {
promise_test(async () => {
// ...
});
});
```(feel free to improve e.g. with named params.)
Done.
setTimeout(() => {this.createGeolocation(receiver, user_gesture)}, 50);This `setTimeout` call is not reachable in base version of the code. I think we should remove it here.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Commit-Queue | +1 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Introduce accuracyMode for GeolocationPosition
This CL introduces the accuracyMode attribute when the ApproximateGeolocationPermission feature is enabled.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |