Repository navigation
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