Roman 

Just a heads up that the onScriptMessage feature landed in Nightly, so you can 
use it without needing the patches. That said, the patches changed during the 
review process, so the API is a little different. The main change is the use of 
Bundles instead of JSONObjects in the Java side. 

I updated my GeckoBrowser example here: 
https://github.com/mfinkle/geckobrowser 

Changes are: 
1. Added script.js and test.html to the assets folder 
2. Inject script.js into GeckoView in onGeckoReady 
3. Load resource://android/assets/test.html to show how the injected script can 
work 

The example script.js creates a simple JS object and injects it into the 
content scope for any newly created DOM content window. That JS object can be 
used from web content JS. As an additional example, I also listen for new page 
loads and get access to the <browser> element hosting the web content. 

I hope this helps, 
Finkle 

----- Original Message -----

> On Fri, Oct 3, 2014 at 6:56 PM, James Willcox <[email protected]> wrote:
> > Roman,
> > Mark recently posted about this[0]. A lot of folks want this, so hopefully
> > something will happen soonish.

> I compiled GeckoView library with Mark's patches from [1].

> I use geckoView.importScript("resource://android/assets/android.js")
> to load initialization script:
> ---
> function load(params) {
> console.log("window", params.toString());
> console.log("window", params.window.toString());
> console.log("window.document", params.window.document.toString());
> console.log("android.js loaded");
> }
> --

> How can I add custom JavaScript function available in all browsers
> tabs like, say, `window' or `console'?
> I want to use this custom API from my web app...

> Thanks!

> [1] https://bugzilla.mozilla.org/show_bug.cgi?id=1035420

> --
> WBR,
> Roman Tsisyk <[email protected]>
> _______________________________________________
> mobile-firefox-dev mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/mobile-firefox-dev
_______________________________________________
mobile-firefox-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/mobile-firefox-dev

Reply via email to