Bug 133648
| Summary: | First assignment to [Replaceable] navigator.geolocation is ignored | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Daniel Bates <dbates> |
| Component: | Bindings | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED CONFIGURATION CHANGED | ||
| Severity: | Normal | CC: | ashvayka, ggaren, mhahnenberg, oliver |
| Priority: | P2 | ||
| Version: | 528+ (Nightly build) | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
Daniel Bates
Attachment #232707 [details] for bug #133559 marks attribute navigator.geolocation as [Replaceable]. As mentioned in bug #133559, comment 14, the tests included in this attachment don't pass "because the first assignment to an instance attribute called geolocation that shadows navigator.geolocation is ignored." Marking attribute navigator.geolocation as [Replaceable] should make it replaceable and hence the first assignment to an instance attribute that shadows navigator.geolocation should take effect.
You can observe this issue by following the steps in bug #133559, comment 15, reproduced here:
You can see this issue by applying the patch, attachment #232707 [details], and [opening] the following URL in Safari linked against the built WebKit:
data:text/html,<script>'use strict'; var MyNavigator = function() {}; MyNavigator.prototype = window.navigator; var myNavigator = new MyNavigator(); myNavigator.geolocation = 1; alert(myNavigator.geolocation);</script>
Then the alert message text is "[object Geolocation]" (*). But should be "1". Modify the above URL to assign some arbitrary value to myNavigator.geolocation, say the string literal "dummy", before the statement that assigns 1 to it, such that it reads:
data:text/html,<script>'use strict'; var MyNavigator = function() {}; MyNavigator.prototype = window.navigator; var myNavigator = new MyNavigator(); myNavigator.geolocation = 'dummy'; myNavigator.geolocation = 1; alert(myNavigator.geolocation);</script>
Open this URL. Then the alert message reads "1" as expected.
(*) I noticed that executing a similar script directly in the Web Inspector console will cause the alert message text to read "1" as expected (why?).
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Alexey Shvayka
As of 2022, WebKit implements navigator.geolocation as readonly attribute, w/o [Replaceable], per spec (https://www.w3.org/TR/geolocation/#navigator_interface). The readonly-ness is covered by WPT's idlharness.js.