From 85f875265fb39a1c8ad8c9c39602c3c9d73a776f Mon Sep 17 00:00:00 2001 From: kouhei Date: Fri, 18 Feb 2022 13:33:26 +0000 Subject: [PATCH] Handle invisible to visible change on Geolocation::PageVisibilityChanged This CL is split from https://chromium-review.googlesource.com/c/chromium/src/+/3449477 This CL changes Geolocation::PageVisibilityChanged so that it would care about invisible->visible cases. Before this CL, the code path assumed visible->invisible case, where it only needed to shutdown the notifier updates, which didn't require UpdateGeolocationConnection calls with actual notifier pointers. This CL updates it to loop for all notifiers registered, so that it can setup the timers in invisible->visible case. Bug: 626703 Change-Id: I32aa48837157d181d3348528b853b4f7b6af3b99 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3470643 Reviewed-by: Kentaro Hara Commit-Queue: Kouhei Ueno Auto-Submit: Kouhei Ueno Cr-Commit-Position: refs/heads/main@{#972926} --- .../modules/geolocation/geolocation.cc | 8 +++- .../getCurrentPosition_visibility.https.html | 42 +++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 third_party/blink/web_tests/wpt_internal/geolocation-api/getCurrentPosition_visibility.https.html diff --git a/third_party/blink/renderer/modules/geolocation/geolocation.cc b/third_party/blink/renderer/modules/geolocation/geolocation.cc index 854280a0b439cc..2e77b50548c6c8 100644 --- a/third_party/blink/renderer/modules/geolocation/geolocation.cc +++ b/third_party/blink/renderer/modules/geolocation/geolocation.cc @@ -512,7 +512,13 @@ void Geolocation::OnPositionUpdated( } void Geolocation::PageVisibilityChanged() { - UpdateGeolocationConnection(nullptr); + for (auto& notifier : *one_shots_) + UpdateGeolocationConnection(notifier); + + HeapVector> watchers; + watchers_->CopyNotifiersToVector(watchers); + for (auto& notifier : watchers) + UpdateGeolocationConnection(notifier); } bool Geolocation::HasPendingActivity() const { diff --git a/third_party/blink/web_tests/wpt_internal/geolocation-api/getCurrentPosition_visibility.https.html b/third_party/blink/web_tests/wpt_internal/geolocation-api/getCurrentPosition_visibility.https.html new file mode 100644 index 00000000000000..42decf89702e0e --- /dev/null +++ b/third_party/blink/web_tests/wpt_internal/geolocation-api/getCurrentPosition_visibility.https.html @@ -0,0 +1,42 @@ + + +Geolocation Test: getCurrentPosition returns after visibilityState changes + + + + + + +

Clear all Geolocation permissions before running this test. If prompted for permission, please allow.

+
+ +