- From: Timothy Guan-tin Chien <notifications@github.com>
- Date: Fri, 08 Nov 2019 12:41:58 -0800
- To: heycam/webidl <webidl@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <heycam/webidl/issues/820@github.com>
Here is something I observed on modern browsers Navigator: ``` > window.Navigator < function Navigator() { [native code] } > window.navigator < Navigator {...} > window.navigator instanceof window.Navigator < true > window.navigator.constructor === window.navigator < false > Navigator.prototype === navigator.constructor.prototype < true ``` Geolocation (Chrome): ``` > navigator.geolocation < Geolocation {...} > navigator.geolocation.constructor < function Geolocation() { [native code] } > window.Geolocation < undefined ``` Geolocation (Safari and Firefox): ``` > navigator.geolocation.constructor < function Object() { [native code] } < navigator.geolocation.constructor === Object > true ``` There are a few issues here: 1. Constructors are not available on the global (`window`). When I look up the WebIDLs of these interfaces, I don't see there are being defined differently. They are both defined with `[Exposed=Window]` extended attribute. Isn't this what `Exposed` do — to make the constructor available on `window`? 2. In Chrome's case for `navigator`, `<instance>.constructor` seems to point to different version of that, even when `<instance>.constructor.prototype` is pointing to the same object. Is this a bug in the implementation, or something not defined in WebIDL? 3. In Safari & Firefox's case, `Geolocation` constructor is not exposed, and `navigator.geolocation.constructor` simply gives me the `Object` constructor. Is this a bug in the implementation, or something not defined in WebIDL? Use case: The `Navigator` and `Geolocation` constructors are bad examples — they are not useful. But for instances of objects that can only be accessed via a callback, for example, `GeolocationCoordinates`, having access to `GeolocationCoordinates.prototype` allow me to look at the available properties without invoke a geolocation request. Let me know if I should file an issue to browsers or redirect the issue to other spec. Thanks. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/heycam/webidl/issues/820
Received on Friday, 8 November 2019 20:42:00 UTC