You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Jonathan Bond-Caron (JIRA)" <ji...@apache.org> on 2013/04/08 18:35:17 UTC

[jira] [Created] (CB-2956) Illegal invocation - CordovaNavigator

Jonathan Bond-Caron created CB-2956:
---------------------------------------

             Summary: 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: Filip Maj
            Priority: Critical


In Cordova 1.4 (possibly a lower version), the following code was added:
 
var CordovaNavigator = function() {};
CordovaNavigator.prototype = context.navigator;
context.navigator = new CordovaNavigator();

----

That breaks the following existing code :

navigator.getUserMedia({video: true}, function(stream){
   MV.camera._stream = stream;
   video.src = window.URL.createObjectURL(stream);
}, 
   function(error){ errorCallback.call(MV.camera, error); }
);

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:

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); }
);

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