Bug 128303 - REGRESSION (r160879): Replacing 'navigator' doesn't work, breaks Cordova library
Summary: REGRESSION (r160879): Replacing 'navigator' doesn't work, breaks Cordova library
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore JavaScript (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac (Intel) OS X 10.9
: P1 Major
Assignee: Nobody
URL:
Keywords: Regression
Depends on:
Blocks:
 
Reported: 2014-02-06 03:14 PST by Radek Pietruszewski
Modified: 2014-07-02 09:56 PDT (History)
6 users (show)

See Also:


Attachments
test case (521 bytes, text/html)
2014-02-06 03:15 PST, Radek Pietruszewski
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Radek Pietruszewski 2014-02-06 03:14:27 PST
Hello,

A library I'm using (Cordova) does this:

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

I'm not sure why it does that (the comment above says: "Replace navigator before any modules are required(), to ensure it happens as soon as possible. We replace it so that properties that can't be clobbered can instead be overridden.", but I'm not sure what that means), but it'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's console returns vague "Error".

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

I attached a test case.
Comment 1 Radek Pietruszewski 2014-02-06 03:15:15 PST
Created attachment 223323 [details]
test case
Comment 2 Alexey Proskuryakov 2014-02-10 10:35:39 PST
This regressed in <http://trac.webkit.org/r160879>.
Comment 3 Radek Pietruszewski 2014-06-05 13:16:35 PDT
This shipped in iOS 8 beta and breaks a lot of apps.

Hoping for a fix in seed 2!
Comment 4 Radek Pietruszewski 2014-07-02 09:54:43 PDT
Fixed (sometime between iOS 8 beta 1 and 2, apparently).
Comment 5 Oliver Hunt 2014-07-02 09:56:00 PDT
(In reply to comment #4)
> Fixed (sometime between iOS 8 beta 1 and 2, apparently).
Yeah, there's another similar bug that i should have duped this to - please file bugs on any other weirdness you encounter :D