- Revision
- 288707
- Author
- [email protected]
- Date
- 2022-01-27 15:24:19 -0800 (Thu, 27 Jan 2022)
Log Message
Geolocation API should callback with error if doc is not fully active
https://bugs.webkit.org/show_bug.cgi?id=228319
<rdar://problem/81450315>
Reviewed by Ryosuke Niwa.
LayoutTests/imported/w3c:
* web-platform-tests/geolocation-API/non-fully-active.https-expected.txt:
Rebaseline WPT test that is now passing.
Source/WebCore:
Test: imported/w3c/web-platform-tests/geolocation-API/non-fully-active.https.html
* Modules/geolocation/Geolocation.cpp:
(WebCore::Geolocation::getCurrentPosition):
(WebCore::Geolocation::watchPosition):
Schedule a task to call the error callback if the document is not fully active, as
per the specification:
- https://github.com/w3c/geolocation-api/issues/96
- https://github.com/w3c/geolocation-api/pull/97
* dom/TaskSource.h:
As Geolocation task source for the HTML5 event loop, as per the Geolocation
specification.
LayoutTests:
Update existing layout tests to reflect behavior change.
* fast/dom/Geolocation/disconnected-frame-already-expected.txt:
* fast/dom/Geolocation/disconnected-frame-already.html:
Aligns test assertions with the spec. Gecko also passes it.
* TestExpectations: Unskip the WPT test.
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (288706 => 288707)
--- trunk/LayoutTests/ChangeLog 2022-01-27 23:22:49 UTC (rev 288706)
+++ trunk/LayoutTests/ChangeLog 2022-01-27 23:24:19 UTC (rev 288707)
@@ -1,3 +1,19 @@
+2022-01-27 Chris Dumez <[email protected]>
+
+ Geolocation API should callback with error if doc is not fully active
+ https://bugs.webkit.org/show_bug.cgi?id=228319
+ <rdar://problem/81450315>
+
+ Reviewed by Ryosuke Niwa.
+
+ Update existing layout tests to reflect behavior change.
+
+ * fast/dom/Geolocation/disconnected-frame-already-expected.txt:
+ * fast/dom/Geolocation/disconnected-frame-already.html:
+ Aligns test assertions with the spec. Gecko also passes it.
+
+ * TestExpectations: Unskip the WPT test.
+
2022-01-27 Kate Cheney <[email protected]>
"Unrecognized Content-Security-Policy directive 'worker-src'."
Modified: trunk/LayoutTests/TestExpectations (288706 => 288707)
--- trunk/LayoutTests/TestExpectations 2022-01-27 23:22:49 UTC (rev 288706)
+++ trunk/LayoutTests/TestExpectations 2022-01-27 23:24:19 UTC (rev 288707)
@@ -529,7 +529,6 @@
imported/w3c/web-platform-tests/geolocation-API/non-secure-contexts.http.html [ Skip ]
imported/w3c/web-platform-tests/geolocation-API/getCurrentPosition_permission_allow.https.html [ Skip ]
imported/w3c/web-platform-tests/geolocation-API/getCurrentPosition_permission_deny.https.html [ Skip ]
-imported/w3c/web-platform-tests/geolocation-API/non-fully-active.https.html [ Skip ]
imported/w3c/web-platform-tests/geolocation-API/watchPosition_permission_deny.https.html [ Skip ]
imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/location-origin-idna.sub.window.html [ Skip ]
imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/location_assign.html [ Skip ]
Modified: trunk/LayoutTests/fast/dom/Geolocation/disconnected-frame-already-expected.txt (288706 => 288707)
--- trunk/LayoutTests/fast/dom/Geolocation/disconnected-frame-already-expected.txt 2022-01-27 23:22:49 UTC (rev 288706)
+++ trunk/LayoutTests/fast/dom/Geolocation/disconnected-frame-already-expected.txt 2022-01-27 23:24:19 UTC (rev 288707)
@@ -4,6 +4,9 @@
Method called on Geolocation object with disconnected Frame.
+PASS successCallbackInvoked is false
+PASS positionError.code is GeolocationPositionError.POSITION_UNAVAILABLE
+PASS positionError.message is 'Document is not fully active'
PASS successfullyParsed is true
TEST COMPLETE
Modified: trunk/LayoutTests/fast/dom/Geolocation/disconnected-frame-already.html (288706 => 288707)
--- trunk/LayoutTests/fast/dom/Geolocation/disconnected-frame-already.html 2022-01-27 23:22:49 UTC (rev 288706)
+++ trunk/LayoutTests/fast/dom/Geolocation/disconnected-frame-already.html 2022-01-27 23:24:19 UTC (rev 288707)
@@ -17,14 +17,12 @@
iframe.src = '';
}
-var error;
+window.successCallbackInvoked = false;
function onSecondIframeLoaded() {
iframeGeolocation.getCurrentPosition(function () {
- testFailed('Success callback invoked unexpectedly');
- finishJSTest();
+ window.successCallbackInvoked = true;
}, function(e) {
- testFailed('Error callback invoked');
- finishJSTest();
+ window.positionError = e;
});
setTimeout(finishTest, 1000);
}
@@ -31,6 +29,9 @@
function finishTest() {
debug('Method called on Geolocation object with disconnected Frame.');
+ shouldBe("successCallbackInvoked", "false");
+ shouldBe("positionError.code", "GeolocationPositionError.POSITION_UNAVAILABLE");
+ shouldBe("positionError.message", "'Document is not fully active'");
finishJSTest();
}
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (288706 => 288707)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2022-01-27 23:22:49 UTC (rev 288706)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2022-01-27 23:24:19 UTC (rev 288707)
@@ -1,3 +1,14 @@
+2022-01-27 Chris Dumez <[email protected]>
+
+ Geolocation API should callback with error if doc is not fully active
+ https://bugs.webkit.org/show_bug.cgi?id=228319
+ <rdar://problem/81450315>
+
+ Reviewed by Ryosuke Niwa.
+
+ * web-platform-tests/geolocation-API/non-fully-active.https-expected.txt:
+ Rebaseline WPT test that is now passing.
+
2022-01-27 Kate Cheney <[email protected]>
"Unrecognized Content-Security-Policy directive 'worker-src'."
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/geolocation-API/non-fully-active.https-expected.txt (288706 => 288707)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/geolocation-API/non-fully-active.https-expected.txt 2022-01-27 23:22:49 UTC (rev 288706)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/geolocation-API/non-fully-active.https-expected.txt 2022-01-27 23:24:19 UTC (rev 288707)
@@ -1,5 +1,4 @@
-Harness Error (TIMEOUT), message = null
-TIMEOUT non-fully active document behavior Test timed out
+PASS non-fully active document behavior
Modified: trunk/Source/WebCore/ChangeLog (288706 => 288707)
--- trunk/Source/WebCore/ChangeLog 2022-01-27 23:22:49 UTC (rev 288706)
+++ trunk/Source/WebCore/ChangeLog 2022-01-27 23:24:19 UTC (rev 288707)
@@ -1,3 +1,25 @@
+2022-01-27 Chris Dumez <[email protected]>
+
+ Geolocation API should callback with error if doc is not fully active
+ https://bugs.webkit.org/show_bug.cgi?id=228319
+ <rdar://problem/81450315>
+
+ Reviewed by Ryosuke Niwa.
+
+ Test: imported/w3c/web-platform-tests/geolocation-API/non-fully-active.https.html
+
+ * Modules/geolocation/Geolocation.cpp:
+ (WebCore::Geolocation::getCurrentPosition):
+ (WebCore::Geolocation::watchPosition):
+ Schedule a task to call the error callback if the document is not fully active, as
+ per the specification:
+ - https://github.com/w3c/geolocation-api/issues/96
+ - https://github.com/w3c/geolocation-api/pull/97
+
+ * dom/TaskSource.h:
+ As Geolocation task source for the HTML5 event loop, as per the Geolocation
+ specification.
+
2022-01-27 Andres Gonzalez <[email protected]>
AXIsolatedObject::children should honor the parameter updateChildrenIfNeeded.
Modified: trunk/Source/WebCore/Modules/geolocation/Geolocation.cpp (288706 => 288707)
--- trunk/Source/WebCore/Modules/geolocation/Geolocation.cpp 2022-01-27 23:22:49 UTC (rev 288706)
+++ trunk/Source/WebCore/Modules/geolocation/Geolocation.cpp 2022-01-27 23:24:19 UTC (rev 288707)
@@ -31,6 +31,7 @@
#if ENABLE(GEOLOCATION)
#include "Document.h"
+#include "EventLoop.h"
#include "FeaturePolicy.h"
#include "Frame.h"
#include "GeoNotifier.h"
@@ -299,8 +300,14 @@
void Geolocation::getCurrentPosition(Ref<PositionCallback>&& successCallback, RefPtr<PositionErrorCallback>&& errorCallback, PositionOptions&& options)
{
- if (!frame())
+ if (!document() || !document()->isFullyActive()) {
+ if (errorCallback && errorCallback->scriptExecutionContext()) {
+ errorCallback->scriptExecutionContext()->eventLoop().queueTask(TaskSource::Geolocation, [errorCallback] {
+ errorCallback->handleEvent(GeolocationPositionError::create(GeolocationPositionError::POSITION_UNAVAILABLE, "Document is not fully active"_s));
+ });
+ }
return;
+ }
auto notifier = GeoNotifier::create(*this, WTFMove(successCallback), WTFMove(errorCallback), WTFMove(options));
startRequest(notifier.ptr());
@@ -310,8 +317,14 @@
int Geolocation::watchPosition(Ref<PositionCallback>&& successCallback, RefPtr<PositionErrorCallback>&& errorCallback, PositionOptions&& options)
{
- if (!frame())
+ if (!document() || !document()->isFullyActive()) {
+ if (errorCallback && errorCallback->scriptExecutionContext()) {
+ errorCallback->scriptExecutionContext()->eventLoop().queueTask(TaskSource::Geolocation, [errorCallback] {
+ errorCallback->handleEvent(GeolocationPositionError::create(GeolocationPositionError::POSITION_UNAVAILABLE, "Document is not fully active"_s));
+ });
+ }
return 0;
+ }
auto notifier = GeoNotifier::create(*this, WTFMove(successCallback), WTFMove(errorCallback), WTFMove(options));
startRequest(notifier.ptr());
Modified: trunk/Source/WebCore/dom/TaskSource.h (288706 => 288707)
--- trunk/Source/WebCore/dom/TaskSource.h 2022-01-27 23:22:49 UTC (rev 288706)
+++ trunk/Source/WebCore/dom/TaskSource.h 2022-01-27 23:24:19 UTC (rev 288707)
@@ -32,6 +32,7 @@
DatabaseAccess,
FileReading,
FontLoading,
+ Geolocation,
IdleTask,
IndexedDB,
MediaElement,