You could check the ardrone_video example, https://github.com/crosswalk-project/crosswalk-android-extensions/blob/master/ardrone_video/ardrone_video.js#L264, window.requestAnimFrame(), window.requestInterval() and window.clearRequestInterval() are added and available to called. I presume your code(navigator.myfunction = …) should work, if not work, I need figure out why.
One more thing I want to mention the extension has lazy binding mechanism, the extension Javascript code will only be executed when the extension object first-time invoked. If your application never call this object, the object you added (navigator.myfunction) will be never valid. Thanks, Halton. On Feb 6, 2016, at 04:31, Iker Jamardo <[email protected]<mailto:[email protected]>> wrote: Hello Halton, First of all, thank you very much for your reply. Let me explain what I am trying to accomplish: I would like to add a function to the navigator object from an extension. It is easy to do in JS code: navigator.myfunction = function() {...} But in the XWlkExtension js code I cannot access the navigator object (or can I?). All my attempts are futile. Of course, I could do something like this in the extension jscode: exports.init() { navigator.myfunction = function() {...} } But it would require from the final application js code to make the call: myextension.init(); And I would like to have the navigator.myfunction injected without having to modify the main application (like it is magically injected, similarly to what happens to myextension object that is magically available in my final application code). Is this possible with XWalkExtension-s? My attempt has been to try to somehow post a message automatically from the Java code to be able to inject the necessary code into the navigator object once the Java XWalkExtension is created but all my attempts haven't worked so far. Entrypoints do not work either as far as I know because I want to modify the navigator object instance. Please, if the problem is still not very much clear, please, do not hesitate to let me know. Regards, Iker On Fri, Feb 5, 2016 at 8:16 AM, Huo, Halton <[email protected]<mailto:[email protected]>> wrote: Iker, Please check my comments inline. On Feb 5, 2016, at 05:39, Iker Jamardo <[email protected]<mailto:[email protected]><mailto:[email protected]<mailto:[email protected]>>> wrote: Hello eveyrone, I am playing around with Crosswalk embed extensions and I was wondering if it could be possible to call to postMessage inside the onInstanceCreated inherited from the base class XWalkExtension. My initial tests are crashing, but as I already have the instanceID, it would be great to be able to make the call. I presume you’re trying the external C++ extension from your context. No, you can not use PostMessage inside OnInstanceCreated because the instance is not created and initiated yet. You could check https://github.com/crosswalk-project/tizen-extensions-crosswalk/blob/master/src/common/extension.cc#L149 If this is not an option, I would be very interested in knowing how to inject DOM manipulation code from a XWalkExtension. I know how to export functions to the extension object that will be present in the window object, but how about if I would like to modify something outside of the scope of the extension JS code? To be honest, I do not quite sure I understand your requirement correctly. https://github.com/crosswalk-project/crosswalk-android-extensions/blob/master/ardrone_video/ardrone_video.js#L63 is an example to modify a canvas element. I have seen also de entryPoints parameter of the XWalkExtension, but as far as I understand, these values are only to be able to expose the extension instance inside a global object, similar to a renaming of the extension instance. Is this right? Haven't been able to find much information about this constructor parameter to be honest. Thanks, Halton. -- Iker Jamardo CTO @ Ludei http://ludei.com<http://ludei.com/> 156 2nd Street San Francisco CA, 94105 +1 415-340-9102 _______________________________________________ Crosswalk-help mailing list [email protected] https://lists.crosswalk-project.org/mailman/listinfo/crosswalk-help
