Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Callback with error if doc is not fully active #97

Merged
merged 2 commits into from
Jul 27, 2021

Conversation

marcoscaceres
Copy link
Member

@marcoscaceres marcoscaceres commented Jul 26, 2021

@marcoscaceres
Copy link
Member Author

@reillyeon
Copy link
Member

I've filed an issue against Chromium for this and updated the summary. Any chance the test you've added in the Gecko patch could be added to WPT instead?

Copy link
Member

@reillyeon reillyeon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is one of the first instances I've seen where the behavior of calling a method on a non-fully active document is well-defined. It is something I always need to handle in Chromium (because non-fully active documents in Blink have a rather conspicuous null pointer) but haven't ever specified.

@marcoscaceres
Copy link
Member Author

marcoscaceres commented Jul 27, 2021

Thanks @reillyeon! And I again have to give a huge shout out to @rakina and co. for producing that TAG guide and for her guidance - and to @saschanaz for a super detailed review over on the Gecko side, who caught the potential issue when used with promises.

I'll see if I can create a WPT test. The challenge I've been facing is that the page requires permission to use the API. But I'll see if Webdriver, via WPT, lets me grant a page permission to use the API... Oh! might be in luck!

 await test_driver.set_permission({name: 'geolocation'}, 'granted');

Re non fully active in general: yeah, I've been finding really weird behavior... not sure if you are following the Permission's one, where (unsurprisingly) Chrome and Firefox are producing different results:

w3c/permissions#162 (comment)

These are a lot of fun to work on tho! So please ping if there are other APIs that could use a look over.

@marcoscaceres
Copy link
Member Author

Ok, WPT is up web-platform-tests/wpt#29799 - however, I'm unsure who to tag for review? @reillyeon can you suggest anyone (or review it?).

That reminds me... we need to find new folks to review the tests. The current set listed over at WPT don't appear to be very active in this space as they might have moved onto other things.

@marcoscaceres
Copy link
Member Author

@saschanaz
Copy link
Member

Ok, WPT is up web-platform-tests/wpt#29799 - however, I'm unsure who to tag for review? @reillyeon can you suggest anyone (or review it?).

That reminds me... we need to find new folks to review the tests. The current set listed over at WPT don't appear to be very active in this space as they might have moved onto other things.

It can be included the gecko patch so that it can be automatically upstreamed.

@marcoscaceres
Copy link
Member Author

@saschanaz wrote:

It can be included the gecko patch so that it can be automatically upstreamed.

I was hoping to do that, but Gecko doesn't implement test_driver.set_permission() yet 😢. I could still bundle it in, if you think it's still worth while.

@saschanaz
Copy link
Member

Oops!

@jgraham Are we planning to implement test_driver.set_permission() in the foreseeable future?

moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Aug 3, 2021
jamienicol pushed a commit to jamienicol/gecko that referenced this pull request Aug 4, 2021
@marcoscaceres marcoscaceres mentioned this pull request Aug 12, 2021
@marcoscaceres
Copy link
Member Author

Good news! WebKit patch inbound for this too! https://bugs.webkit.org/show_bug.cgi?id=228319 🎉

webkit-commit-queue pushed a commit to WebKit/WebKit that referenced this pull request Aug 24, 2021
https://bugs.webkit.org/show_bug.cgi?id=228319
<rdar://problem/81450315>

Reviewed by Ryosuke Niwa.

LayoutTests/imported/w3c:

* web-platform-tests/geolocation-API/PositionOptions.https-expected.txt:
Rebaseline WPT test now that more checks are passing.

* web-platform-tests/geolocation-API/non-fully-active.https-expected.txt: Added.
* web-platform-tests/geolocation-API/non-fully-active.https.html: Added.
* web-platform-tests/geolocation-API/resources/iframe.html: Added.
Import test coverage from WPT web-platform-tests/wpt#29799.

* web-platform-tests/resources/testdriver-vendor.js:
(window.test_driver_internal.set_permission):
Add support for test_driver.set_permission("geolocation", "granted") so that Geolocation
WPT tests can run with our infrastructure.

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:
- w3c/geolocation#96
- w3c/geolocation#97

* bindings/js/JSDOMConvertCallbacks.h:
(WebCore::Converter<IDLCallbackFunction<T>>::convert):
(WebCore::Converter<IDLCallbackInterface<T>>::convert):
Make sure we use the incumbent global object when constructing callback functions /
interfaces, as per the Web IDL specification:
- https://heycam.github.io/webidl/#es-callback-interface
- https://heycam.github.io/webidl/#es-callback-function
Without this, the geolocation API would be unable to call its error callback when in
a detached frame because the callback's global object would be the geolocation object's
global object.

* dom/IdleCallbackController.cpp:
(WebCore::IdleCallbackController::invokeIdleCallbacks):
Make sure we don't fire requestIdleCallback callbacks in detached iframes, to maintain
pre-existing behavior and keep layout tests passing. I had to make this change because
callback interfaces / functions are now using a different global object and can now
get called in cases when they previously couldn't.

* dom/TaskSource.h:
As Geolocation task source for the HTML5 event loop, as per the Geolocation
specification.

LayoutTests:

Update / rebaseline existing layout tests to reflect behavior change.

* fast/dom/Geolocation/callback-to-deleted-context-expected.txt:
* fast/dom/Geolocation/callback-to-deleted-context.html:
* fast/dom/Geolocation/disconnected-frame-already-expected.txt:
* fast/dom/Geolocation/disconnected-frame-already.html:
* fast/dom/Geolocation/disconnected-frame-expected.txt:
* fast/dom/Geolocation/disconnected-frame-permission-denied-expected.txt:
* fast/dom/Geolocation/disconnected-frame-permission-denied.html:
* fast/dom/Geolocation/disconnected-frame.html:
* fast/dom/Geolocation/resources/callback-to-deleted-context-inner1.html:
* fast/events/detached-svg-parent-window-events-expected.txt:
* fast/events/detached-svg-parent-window-events.html:


Canonical link: https://commits.webkit.org/240893@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@281520 268f45cc-cd09-0410-ab3c-d52691b4dbfc
@marcoscaceres
Copy link
Member Author

@reillyeon, could you by chance point me to how fully active checks are done in Chromium? With a little guidance, maybe I can slap together a Chromium patch? ☺️

@reillyeon
Copy link
Member

bertogg pushed a commit to Igalia/webkit that referenced this pull request Sep 6, 2021
https://bugs.webkit.org/show_bug.cgi?id=228319
<rdar://problem/81450315>

Reviewed by Ryosuke Niwa.

LayoutTests/imported/w3c:

* web-platform-tests/geolocation-API/PositionOptions.https-expected.txt:
Rebaseline WPT test now that more checks are passing.

* web-platform-tests/geolocation-API/non-fully-active.https-expected.txt: Added.
* web-platform-tests/geolocation-API/non-fully-active.https.html: Added.
* web-platform-tests/geolocation-API/resources/iframe.html: Added.
Import test coverage from WPT web-platform-tests/wpt#29799.

* web-platform-tests/resources/testdriver-vendor.js:
(window.test_driver_internal.set_permission):
Add support for test_driver.set_permission("geolocation", "granted") so that Geolocation
WPT tests can run with our infrastructure.

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:
- w3c/geolocation#96
- w3c/geolocation#97

* bindings/js/JSDOMConvertCallbacks.h:
(WebCore::Converter<IDLCallbackFunction<T>>::convert):
(WebCore::Converter<IDLCallbackInterface<T>>::convert):
Make sure we use the incumbent global object when constructing callback functions /
interfaces, as per the Web IDL specification:
- https://heycam.github.io/webidl/#es-callback-interface
- https://heycam.github.io/webidl/#es-callback-function
Without this, the geolocation API would be unable to call its error callback when in
a detached frame because the callback's global object would be the geolocation object's
global object.

* dom/IdleCallbackController.cpp:
(WebCore::IdleCallbackController::invokeIdleCallbacks):
Make sure we don't fire requestIdleCallback callbacks in detached iframes, to maintain
pre-existing behavior and keep layout tests passing. I had to make this change because
callback interfaces / functions are now using a different global object and can now
get called in cases when they previously couldn't.

* dom/TaskSource.h:
As Geolocation task source for the HTML5 event loop, as per the Geolocation
specification.

LayoutTests:

Update / rebaseline existing layout tests to reflect behavior change.

* fast/dom/Geolocation/callback-to-deleted-context-expected.txt:
* fast/dom/Geolocation/callback-to-deleted-context.html:
* fast/dom/Geolocation/disconnected-frame-already-expected.txt:
* fast/dom/Geolocation/disconnected-frame-already.html:
* fast/dom/Geolocation/disconnected-frame-expected.txt:
* fast/dom/Geolocation/disconnected-frame-permission-denied-expected.txt:
* fast/dom/Geolocation/disconnected-frame-permission-denied.html:
* fast/dom/Geolocation/disconnected-frame.html:
* fast/dom/Geolocation/resources/callback-to-deleted-context-inner1.html:
* fast/events/detached-svg-parent-window-events-expected.txt:
* fast/events/detached-svg-parent-window-events.html:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@281520 268f45cc-cd09-0410-ab3c-d52691b4dbfc
webkit-commit-queue pushed a commit to WebKit/WebKit that referenced this pull request Jan 27, 2022
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:
- w3c/geolocation#96
- w3c/geolocation#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.



Canonical link: https://commits.webkit.org/246504@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288707 268f45cc-cd09-0410-ab3c-d52691b4dbfc
annulen pushed a commit to qtwebkit/qtwebkit that referenced this pull request Jan 28, 2022
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:
- w3c/geolocation#96
- w3c/geolocation#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.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@288707 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants