Changeset 288707 in webkit


Ignore:
Timestamp:
Jan 27, 2022 3:24:19 PM (6 months ago)
Author:
Chris Dumez
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:

  • 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.

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r288701 r288707  
     12022-01-27  Chris Dumez  <cdumez@apple.com>
     2
     3        Geolocation API should callback with error if doc is not fully active
     4        https://bugs.webkit.org/show_bug.cgi?id=228319
     5        <rdar://problem/81450315>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        Update existing layout tests to reflect behavior change.
     10
     11        * fast/dom/Geolocation/disconnected-frame-already-expected.txt:
     12        * fast/dom/Geolocation/disconnected-frame-already.html:
     13        Aligns test assertions with the spec. Gecko also passes it.
     14
     15        * TestExpectations: Unskip the WPT test.
     16
    1172022-01-27  Kate Cheney  <katherine_cheney@apple.com>
    218
  • trunk/LayoutTests/TestExpectations

    r288701 r288707  
    530530imported/w3c/web-platform-tests/geolocation-API/getCurrentPosition_permission_allow.https.html [ Skip ]
    531531imported/w3c/web-platform-tests/geolocation-API/getCurrentPosition_permission_deny.https.html [ Skip ]
    532 imported/w3c/web-platform-tests/geolocation-API/non-fully-active.https.html [ Skip ]
    533532imported/w3c/web-platform-tests/geolocation-API/watchPosition_permission_deny.https.html [ Skip ]
    534533imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/location-origin-idna.sub.window.html [ Skip ]
  • trunk/LayoutTests/fast/dom/Geolocation/disconnected-frame-already-expected.txt

    r288024 r288707  
    55
    66Method called on Geolocation object with disconnected Frame.
     7PASS successCallbackInvoked is false
     8PASS positionError.code is GeolocationPositionError.POSITION_UNAVAILABLE
     9PASS positionError.message is 'Document is not fully active'
    710PASS successfullyParsed is true
    811
  • trunk/LayoutTests/fast/dom/Geolocation/disconnected-frame-already.html

    r288024 r288707  
    1818}
    1919
    20 var error;
     20window.successCallbackInvoked = false;
    2121function onSecondIframeLoaded() {
    2222    iframeGeolocation.getCurrentPosition(function () {
    23         testFailed('Success callback invoked unexpectedly');
    24         finishJSTest();
     23        window.successCallbackInvoked = true;
    2524    }, function(e) {
    26         testFailed('Error callback invoked');
    27         finishJSTest();
     25        window.positionError = e;
    2826    });
    2927    setTimeout(finishTest, 1000);
     
    3230function finishTest() {
    3331    debug('Method called on Geolocation object with disconnected Frame.');
     32    shouldBe("successCallbackInvoked", "false");
     33    shouldBe("positionError.code", "GeolocationPositionError.POSITION_UNAVAILABLE");
     34    shouldBe("positionError.message", "'Document is not fully active'");
    3435    finishJSTest();
    3536}
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r288701 r288707  
     12022-01-27  Chris Dumez  <cdumez@apple.com>
     2
     3        Geolocation API should callback with error if doc is not fully active
     4        https://bugs.webkit.org/show_bug.cgi?id=228319
     5        <rdar://problem/81450315>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        * web-platform-tests/geolocation-API/non-fully-active.https-expected.txt:
     10        Rebaseline WPT test that is now passing.
     11
    1122022-01-27  Kate Cheney  <katherine_cheney@apple.com>
    213
  • trunk/LayoutTests/imported/w3c/web-platform-tests/geolocation-API/non-fully-active.https-expected.txt

    r288024 r288707  
    11
    2 Harness Error (TIMEOUT), message = null
    32
    4 TIMEOUT non-fully active document behavior Test timed out
     3PASS non-fully active document behavior
    54
  • trunk/Source/WebCore/ChangeLog

    r288703 r288707  
     12022-01-27  Chris Dumez  <cdumez@apple.com>
     2
     3        Geolocation API should callback with error if doc is not fully active
     4        https://bugs.webkit.org/show_bug.cgi?id=228319
     5        <rdar://problem/81450315>
     6
     7        Reviewed by Ryosuke Niwa.
     8
     9        Test: imported/w3c/web-platform-tests/geolocation-API/non-fully-active.https.html
     10
     11        * Modules/geolocation/Geolocation.cpp:
     12        (WebCore::Geolocation::getCurrentPosition):
     13        (WebCore::Geolocation::watchPosition):
     14        Schedule a task to call the error callback if the document is not fully active, as
     15        per the specification:
     16        - https://github.com/w3c/geolocation-api/issues/96
     17        - https://github.com/w3c/geolocation-api/pull/97
     18
     19        * dom/TaskSource.h:
     20        As Geolocation task source for the HTML5 event loop, as per the Geolocation
     21        specification.
     22
    1232022-01-27  Andres Gonzalez  <andresg_22@apple.com>
    224
  • trunk/Source/WebCore/Modules/geolocation/Geolocation.cpp

    r288024 r288707  
    3232
    3333#include "Document.h"
     34#include "EventLoop.h"
    3435#include "FeaturePolicy.h"
    3536#include "Frame.h"
     
    300301void Geolocation::getCurrentPosition(Ref<PositionCallback>&& successCallback, RefPtr<PositionErrorCallback>&& errorCallback, PositionOptions&& options)
    301302{
    302     if (!frame())
    303         return;
     303    if (!document() || !document()->isFullyActive()) {
     304        if (errorCallback && errorCallback->scriptExecutionContext()) {
     305            errorCallback->scriptExecutionContext()->eventLoop().queueTask(TaskSource::Geolocation, [errorCallback] {
     306                errorCallback->handleEvent(GeolocationPositionError::create(GeolocationPositionError::POSITION_UNAVAILABLE, "Document is not fully active"_s));
     307            });
     308        }
     309        return;
     310    }
    304311
    305312    auto notifier = GeoNotifier::create(*this, WTFMove(successCallback), WTFMove(errorCallback), WTFMove(options));
     
    311318int Geolocation::watchPosition(Ref<PositionCallback>&& successCallback, RefPtr<PositionErrorCallback>&& errorCallback, PositionOptions&& options)
    312319{
    313     if (!frame())
     320    if (!document() || !document()->isFullyActive()) {
     321        if (errorCallback && errorCallback->scriptExecutionContext()) {
     322            errorCallback->scriptExecutionContext()->eventLoop().queueTask(TaskSource::Geolocation, [errorCallback] {
     323                errorCallback->handleEvent(GeolocationPositionError::create(GeolocationPositionError::POSITION_UNAVAILABLE, "Document is not fully active"_s));
     324            });
     325        }
    314326        return 0;
     327    }
    315328
    316329    auto notifier = GeoNotifier::create(*this, WTFMove(successCallback), WTFMove(errorCallback), WTFMove(options));
  • trunk/Source/WebCore/dom/TaskSource.h

    r288024 r288707  
    3333    FileReading,
    3434    FontLoading,
     35    Geolocation,
    3536    IdleTask,
    3637    IndexedDB,
Note: See TracChangeset for help on using the changeset viewer.