<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>128303</bug_id>
          
          <creation_ts>2014-02-06 03:14:27 -0800</creation_ts>
          <short_desc>REGRESSION (r160879): Replacing &apos;navigator&apos; doesn&apos;t work, breaks Cordova library</short_desc>
          <delta_ts>2014-07-02 09:56:00 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebCore JavaScript</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Mac (Intel)</rep_platform>
          <op_sys>OS X 10.9</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>Regression</keywords>
          <priority>P1</priority>
          <bug_severity>Major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Radek Pietruszewski">radexpl</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>apavlov</cc>
    
    <cc>ggaren</cc>
    
    <cc>oliver</cc>
    
    <cc>sam</cc>
    
    <cc>timothy</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>977309</commentid>
    <comment_count>0</comment_count>
    <who name="Radek Pietruszewski">radexpl</who>
    <bug_when>2014-02-06 03:14:27 -0800</bug_when>
    <thetext>Hello,

A library I&apos;m using (Cordova) does this:

&gt;    var CordovaNavigator = function() {};
&gt;    CordovaNavigator.prototype = window.navigator;
&gt;    window.navigator = new CordovaNavigator();

I&apos;m not sure why it does that (the comment above says: &quot;Replace navigator before any modules are required(), to ensure it happens as soon as possible. We replace it so that properties that can&apos;t be clobbered can instead be overridden.&quot;, but I&apos;m not sure what that means), but it&apos;s always worked fine. It works on Safari 6 and 7, on iOS 6, 7, 7.1b4 and on Android, but on the latest nightlies (r163498 is the newest I checked) it breaks. All method calls and property accesses throw TypeError and typing `navigator` in Inspector&apos;s console returns vague &quot;Error&quot;.

I&apos;m not a JS expert, but AFAICT it appears to be a WebKit bug.

I attached a test case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>977310</commentid>
    <comment_count>1</comment_count>
      <attachid>223323</attachid>
    <who name="Radek Pietruszewski">radexpl</who>
    <bug_when>2014-02-06 03:15:15 -0800</bug_when>
    <thetext>Created attachment 223323
test case</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>978957</commentid>
    <comment_count>2</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2014-02-10 10:35:39 -0800</bug_when>
    <thetext>This regressed in &lt;http://trac.webkit.org/r160879&gt;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1013632</commentid>
    <comment_count>3</comment_count>
    <who name="Radek Pietruszewski">radexpl</who>
    <bug_when>2014-06-05 13:16:35 -0700</bug_when>
    <thetext>This shipped in iOS 8 beta and breaks a lot of apps.

Hoping for a fix in seed 2!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1019989</commentid>
    <comment_count>4</comment_count>
    <who name="Radek Pietruszewski">radexpl</who>
    <bug_when>2014-07-02 09:54:43 -0700</bug_when>
    <thetext>Fixed (sometime between iOS 8 beta 1 and 2, apparently).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1019990</commentid>
    <comment_count>5</comment_count>
    <who name="Oliver Hunt">oliver</who>
    <bug_when>2014-07-02 09:56:00 -0700</bug_when>
    <thetext>(In reply to comment #4)
&gt; Fixed (sometime between iOS 8 beta 1 and 2, apparently).
Yeah, there&apos;s another similar bug that i should have duped this to - please file bugs on any other weirdness you encounter :D</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>223323</attachid>
            <date>2014-02-06 03:15:15 -0800</date>
            <delta_ts>2014-02-06 03:15:15 -0800</delta_ts>
            <desc>test case</desc>
            <filename>testcase.html</filename>
            <type>text/html</type>
            <size>521</size>
            <attacher name="Radek Pietruszewski">radexpl</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjxtZXRhIGNoYXJzZXQ9IlVURi04Ij4KCjxzY3JpcHQ+CgovLyBSZXBs
YWNlIG5hdmlnYXRvciBiZWZvcmUgYW55IG1vZHVsZXMgYXJlIHJlcXVpcmVkKCksIHRvIGVuc3Vy
ZSBpdCBoYXBwZW5zIGFzIHNvb24gYXMgcG9zc2libGUuCi8vIFdlIHJlcGxhY2UgaXQgc28gdGhh
dCBwcm9wZXJ0aWVzIHRoYXQgY2FuJ3QgYmUgY2xvYmJlcmVkIGNhbiBpbnN0ZWFkIGJlIG92ZXJy
aWRkZW4uCmlmICh3aW5kb3cubmF2aWdhdG9yKSB7CiAgICB2YXIgQ29yZG92YU5hdmlnYXRvciA9
IGZ1bmN0aW9uKCkge307CiAgICBDb3Jkb3ZhTmF2aWdhdG9yLnByb3RvdHlwZSA9IHdpbmRvdy5u
YXZpZ2F0b3I7CiAgICB3aW5kb3cubmF2aWdhdG9yID0gbmV3IENvcmRvdmFOYXZpZ2F0b3IoKTsK
fQoKLy8gVHlwZUVycm9yIG9uIHIxNjM0OTgKLy8gd29ya3MgZXZlcnl3aGVyZSBlbHNlCm5hdmln
YXRvci51c2VyQWdlbnQ7CgphbGVydCgidGhpcyB3b24ndCBzaG93IHVwIG9uIG5pZ2h0bHkiKQo8
L3NjcmlwdD4=
</data>

          </attachment>
      

    </bug>

</bugzilla>