Bug 133648 - First assignment to [Replaceable] navigator.geolocation is ignored
Summary: First assignment to [Replaceable] navigator.geolocation is ignored
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Bindings (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-09 11:01 PDT by Daniel Bates
Modified: 2014-06-10 10:02 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Bates 2014-06-09 11:01:47 PDT
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?).