-
Notifications
You must be signed in to change notification settings - Fork 56
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
Addition: expose .toJSON() on GeolocationCoordinates + GeolocationPosition #147
Conversation
I filed a Chromium issue to track this. Please file issues for WebKit and Gecko. |
Filed Gecko and WebKit bugs: @saschanaz, would you be the right person to comment on this? |
Sent a PR for WebKit WebKit/WebKit#27063 |
👍 from Mozilla. |
https://bugs.webkit.org/show_bug.cgi?id=272434 rdar://126183686 Reviewed by Ryosuke Niwa. Implements and tests the toJSON() method for the GeolocationCoordinates interface, as proposed: w3c/geolocation#147 * LayoutTests/fast/dom/Geolocation/coordinates-interface-toJSON-expected.txt: Added. * LayoutTests/fast/dom/Geolocation/coordinates-interface-toJSON.html: Added. * Source/WebCore/Modules/geolocation/GeolocationCoordinates.idl: Canonical link: https://commits.webkit.org/277347@main
@reillyeon, if all looks good, could you give it a ✅ 🙏 Patches ready to land on the WebKit side. |
I'm writing up the "Intent to Prototype and Ship" email for the Blink launch process and I just want to make sure I understand the motivation for this change. Are tests planning to use I noted when I was writing tests for this change in Chromium that the output of |
The primary motivation was to make it easier for developers to (re)use and serialize these objects. await position = new Promise(r => navigator.geolocation.getCurrentPosition(r));
await fetch('https://example.com/api/positions', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(position, null, 2)
}); And then it just happens that we can potentially reuse
It's simpler to compare object's expected values than JSON.stringify() for the reasons you discovered.
Yeah, I concluded the same thing. You can see how I tested in WebKit: But the only interesting part is (overlook the fact that they are on the global object, that's just a WebKit testing framework thing): // We use "actual" for future proofing on purpose, in case more properties get added to the interface.
for (const key in window.actual) {
shouldBe(`window.actual.${key}`, `window.expected.${key}`);
} |
https://bugs.webkit.org/show_bug.cgi?id=272501 rdar://problem/126247408 Reviewed by Ryosuke Niwa. Implements .toJSON() method on GeolocationPosition, as per spec change: w3c/geolocation#147 * LayoutTests/fast/dom/Geolocation/position-interface-toJSON-expected.txt: Added. * LayoutTests/fast/dom/Geolocation/position-interface-toJSON.html: Added. * Source/WebCore/Modules/geolocation/GeolocationPosition.idl: Canonical link: https://commits.webkit.org/277413@main
Do we have context about why GeolocationPosition is not a dictionary? 🤔 |
Just because of legacy, @saschanaz (given the API is like 10+ years old). If we were doing the API today, it would definitely just have been a dictionary. |
Closes #145
The following tasks have been completed:
Implementation commitment:
Preview | Diff