[android] Execute javascript from different application in chrome on open tab

1,061 views
Skip to first unread message

lee.o

unread,
Jul 18, 2014, 9:47:52 AM7/18/14
to chromi...@chromium.org
Hi everybody,

i'm developing an AccessibilityService for android, which helps the user to fill forms with saved data in an separate app. In addition to Forms in Activities, i want to fill web forms in an open browser.
After some research i found 2 possibilities, but i for thous one need a reference to the WebView which i don't have, since i just got the AccessibilityNodeInfo received by the AccessibilityService.

The 2 possibilities would be:
- WebViewInstance.loadUrl() and 
- use sendMessage-Methode via reflection-API [1]

Additionally i saw, that one could inject code via AccessibilityNodeInfoInstance.performAction() Methode. Unfortunately, its just possible to communicate with chromevox.
Is there another way, to execute javascript code on the currently open Tab? Is it possible to use c2dm-broadcasts to execute javascript?

Thanks in advance, (and sorry for the double post)
best regards

Leo

Isiah Meadows

unread,
Jul 19, 2014, 2:10:03 PM7/19/14
to chromi...@chromium.org
This is probably a better question to ask on the Chromium Apps list.

PhistucK

unread,
Jul 19, 2014, 2:15:30 PM7/19/14
to Isiah Meadows, Chromium-dev
I think lee.o does not refer to Chrome Applications, but a way to control Chrome using accessibility APIs (or the like) from another (unrelated to Chrome nor Chrome Applications).
(This is the second post from here regarding the matter and the mentioning of the accessibility APIs hints that lee.o is looking to control Chrome at the Java or C++ level or something like that)


PhistucK


--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.

Dominic Mazzoni

unread,
Jul 21, 2014, 12:20:21 PM7/21/14
to leonhard....@gmail.com, chromium-dev
Hi Leo,

You can't use an AccessibilityService to inject JavaScript. While some WebViews currently inject ChromeVox javascript code for accessibility, that's gone in Android L, as Chrome and WebViews implement native accessibility instead.

With the latest version of Chrome on Android 4.1 and higher, if you have an accessibility service running you should get an AccessibilityNodeInfo for every node in the web page, not just the Web View. From your service you can find text fields and focus them. Try running with TalkBack enabled; it's possible that your service isn't triggering this mode currently.

How are you changing the values of text fields in other apps using accessibility APIs? If there are APIs that would do this in other apps and we don't support them in Chrome, we could look into adding support. Maybe you put the text you want to enter in the clipboard and send a "paste" action?

There are no plans to support javascript extensions or any other method of injecting javascript in Chrome or a WebView.

- Dominic

--

Yoshio

unread,
Oct 28, 2015, 9:17:36 PM10/28/15
to Chromium-dev
Hi, I am developing an accessibility service and it doesn't work with Chrome unless, as you suggest, TalkBack is enabled. How does Chrome determine it needs to send accessibility events? How do services 'trigger the mode?' I have tried 'requesting enhanced web accessibility.' I could find no other description of this behavior anywhere...

Dominic Mazzoni

unread,
Oct 29, 2015, 12:44:28 PM10/29/15
to yoshi...@gmail.com, Chromium-dev
Chrome doesn't check if TalkBack is running, but accessibility for the WebView loads lazily. From your accessibility service, recursively explore the whole tree of views and make sure you find the WebView. If you do that, and if accessibility is enabled, Chrome should start sending accessibility events. If you just load the Chrome activity and the accessibility service never fetches the accessible views, Chrome won't ever initialize its accessibility support.

- Dominic

Reply all
Reply to author
Forward
0 new messages