Closed Bug 904693 Opened 11 years ago Closed 11 years ago

[Cordova] Workaround for window.navigator bug

Categories

(Developer Ecosystem :: Dev Kit, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: wenzel, Assigned: zalun)

References

Details

Enumerating window.navigator on FxOS 1.1 throws a security error (bug 894335). Cordova does exactly that while initializing. If possible, we should identify a workaround for this. Potentially, this could work like this: 1) phonegap initializes and hits the bug, throwing a security error 2) we catch the error, and flip a flag. We connect the APIs to a separate object (window.cordova?) rather than the navigator object instead. 3) developer checks for the flag and if it's present, they talk to the window.cordova object as opposed to window.navigator. That's just one option how it could work.
Assignee: nobody → zaloon
The first attempt is to try/catch on each key. This fails on 'mozTime' and is transparent for other browsers - https://github.com/zalun/cordova-firefoxos-take-one/blob/232be947289667448ec5c5c54f1611ff247dc4df/framework/cordova-2.6.0.js#L6052
I have finished this. The firefoxos platform in cordova-js now has its own init.js file which overrides the main one, and it adds the try/catch which makes it work. All new projects will get this fix now: https://github.com/jlongster/cordova-js/blob/master/lib/firefoxos/init.js
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.