New issue
Advanced search Search tips

Issue 915339 link

Starred by 2 users

Issue metadata

Status: Unconfirmed
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 2
Type: Bug-Regression



Sign in to add a comment

Injected javascript fails to call the JavascriptInterface set on WebView on (Android 7.0 + Chrome 71 (71.0.3578.83) )

Reported by cambeka...@gmail.com, Dec 14

Issue description

Steps to reproduce the problem:
1. Create a Class that has a public method that is annotated with @JavascriptInterface
Eg:

class MyJavaScriptInterface {
        private static final String TAG = "MyJavaScriptInterface”;
        @SuppressWarnings("unused")
        @JavascriptInterface
        public void myCallback() {
            Log.d(TAG, "myCallback received");
        }
    }

2. Create a Webview and set an instance of this class on WebView by using the following method, eg: addJavascriptInterface(new MyJavaScriptInterface(), "javaScriptInterface");
https://developer.android.com/reference/android/webkit/WebView.html#addJavascriptInterface(java.lang.Object,%20java.lang.String) 
3. Enable javascript on the above instance of WebView WebView.getSettings().setJavaScriptEnabled(true)
4. Set a WebViewClient on this WebView instance and override the method shouldOverrideUrlLoading and return true. 
5. Load a Url in this WebView. 
6. In onPageFinished of this WebViewClient webView.loadUrl("javascript:window.javaScriptInterface.myCallback();");

What is the expected behavior?
The javascriptInterface added to the webview must be called from the the javascript that is injected in loadUrl. 

What went wrong?
1) The myCallback is not called on Android 7.0 + Chrome 71 (71.0.3578.83) 
2) The myCallback is called on Android 8.0 + Chrome 71 (71.0.3578.83) 
Chrome released a new version 71 (71.0.3578.83) on Dec 4th
(https://chromereleases.googleblog.com/2018/12/chrome-for-android-update.html).
Starting with Android 7.0  the Chrome APK on your device is used to provide and
render Android System WebViews.

This issue is reproduced on Android 7.0 + Chrome 71 (71.0.3578.83) because with
this combination the injected javascript fails to call the JavascriptInterface
method.

I uninstalled and re-installed + updated the Chrome apk on this Android 7.0
device and it only updated to the previous Chrome 70.0.3538.110 and does not
update to 71. This issue is not reproducible on  Android 7.0 + Chrome
70.0.3538.110

Did this work before? Yes 70.0.3538.110

Chrome version: 71.0.3578.83  Channel: n/a
OS Version: Android 7.0
Flash Version:
 

Comment 1 Deleted

Comment 2 Deleted

Components: -Blink Mobile>WebView
Labels: Needs-triage-Mobile
Cc: chelamcherla@chromium.org
Labels: WV-Triaged Needs-Feedback
@ cambekar84: Please provide test apk file with code mentioned in c#0 to reproduce this issue. Screencast of issue would be helpful in further triaging.

Thanks!
Just an FYI, it might be the same to  issue 902622 , which is not yet being fixed.

Sign in to add a comment