[
https://issues.apache.org/jira/browse/CB-2956?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Andrew Grieve resolved CB-2956.
-------------------------------
Resolution: Duplicate
Assignee: Andrew Grieve (was: Filip Maj)
Dupe of CB-2526 (already fixed)
> Illegal invocation - CordovaNavigator
> -------------------------------------
>
> Key: CB-2956
> URL: https://issues.apache.org/jira/browse/CB-2956
> Project: Apache Cordova
> Issue Type: Bug
> Components: CordovaJS
> Affects Versions: 2.4.0
> Environment: Cordova 1.4 running in Chrome Version 26.0.1410.43 m
> Reporter: Jonathan Bond-Caron
> Assignee: Andrew Grieve
> Priority: Critical
>
> In Cordova 1.4 (possibly a lower version), the following code was added:
>
> {code}
> var CordovaNavigator = function() {};
> CordovaNavigator.prototype = context.navigator;
> context.navigator = new CordovaNavigator();
> {code}
> ----
> That breaks the following existing code :
> {code}
> navigator.getUserMedia({video: true}, function(stream){
> MV.camera._stream = stream;
> video.src = window.URL.createObjectURL(stream);
> },
> function(error){ errorCallback.call(MV.camera, error); }
> );
> {code}
> Chrome complains with 'Illegal invocation' since getUserMedia() is expected
> to be executed within the scope of the original window.navigator.
> To fix my code, I have to use:
> {code}
> navigator.getUserMedia.call(Object.getPrototypeOf(navigator), {video: true},
> function(stream){
> MV.camera._stream = stream;
> video.src = window.URL.createObjectURL(stream);
> },
> function(error){ errorCallback.call(MV.camera, error); }
> );
> {code}
> I don't think Cordova JS should override any of the default native objects.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira