When the document is not fully active the error callback passed to navigator.geolocation.getCurrentPosition() or watchPosition() is not invoked. This behavior can be reproduced by creating an iframe, capturing a reference to navigator.geolocation from its global scope, removing it from the DOM and then attempting to call one of these methods. The behavior of calling the error callback has been proposed in the specification. Specification issue: https://github.com/w3c/geolocation-api/issues/96 Specification pull request: https://github.com/w3c/geolocation-api/pull/97 Web platform test: https://github.com/web-platform-tests/wpt/pull/29799 PS: any chance of getting a "Geolocation" bug component in here in the bug tracker? 🙏
<rdar://problem/81450315>
There are quite a few issues causing the new test not to run, besides Geolocation issues: - Lack of a <body> even though the test relies on document.body - After re-adding the iframe to the document, it does: ``` document.body.appendChild(iframe); iframe.contentWindow.opener = window; await new Promise((resolve) => window.addEventListener("load", resolve, { once: true }) ); ``` I think this should be: ``` document.body.appendChild(iframe); iframe.contentWindow.opener = window; await new Promise((resolve) => iframe.addEventListener("load", resolve, { once: true }) ); ``` Why would the main frame's load event fire again?
(In reply to Chris Dumez from comment #2) > There are quite a few issues causing the new test not to run, besides > Geolocation issues: > - Lack of a <body> even though the test relies on document.body > - After re-adding the iframe to the document, it does: > ``` > document.body.appendChild(iframe); > iframe.contentWindow.opener = window; > await new Promise((resolve) => > window.addEventListener("load", resolve, { once: true }) > ); > ``` > > I think this should be: > ``` > document.body.appendChild(iframe); > iframe.contentWindow.opener = window; > await new Promise((resolve) => > iframe.addEventListener("load", resolve, { once: true }) > ); > ``` > > Why would the main frame's load event fire again? And I think we need this test change too: - assert_true(position, "Expected a position"); + assert_true(Boolean(position), "Expected a position");
Created attachment 436254 [details] WIP patch
This patch modifies the imported WPT tests. Please ensure that any changes on the tests (not coming from a WPT import) are exported to WPT. Please see https://trac.webkit.org/wiki/WPTExportProcess
The C++ side should be good. More work is needed to either make the WPT test run nicely with our infra or write our own test.
(In reply to Chris Dumez from comment #2) > There are quite a few issues causing the new test not to run, besides > Geolocation issues: > - Lack of a <body> even though the test relies on document.body > - After re-adding the iframe to the document, it does: > ``` > document.body.appendChild(iframe); > iframe.contentWindow.opener = window; > await new Promise((resolve) => > window.addEventListener("load", resolve, { once: true }) > ); > ``` > > I think this should be: > ``` > document.body.appendChild(iframe); > iframe.contentWindow.opener = window; > await new Promise((resolve) => > iframe.addEventListener("load", resolve, { once: true }) > ); > ``` > > Why would the main frame's load event fire again? Oops! Good catch! Let me know if you want me to fix this over on the WTP side.
Sent fix for WPT: https://github.com/web-platform-tests/wpt/pull/30143 Happy to fix anything else you spot.
Created attachment 436293 [details] WIP patch
Created attachment 436297 [details] Patch
Created attachment 436315 [details] Patch
Committed r281520 (240893@main): <https://commits.webkit.org/240893@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 436315 [details].
Reopening since the change was reverted.
Created attachment 449481 [details] Patch Re-land on top of r288197.
Comment on attachment 449481 [details] Patch https://bugs.webkit.org/show_bug.cgi?id=235368 needs to be investigated first.
Comment on attachment 449481 [details] Patch r288307 seems alright.
Committed r288707 (246504@main): <https://commits.webkit.org/246504@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 449481 [details].
Reopening as it has regressed: the callbacks are no longer called.