Why? NPMethod called on non-NPObject
Reported by
goodmi...@gmail.com,
Nov 30 2016
|
||
Issue description
THIS TEMPLATE IS FOR FILING BUGS ON THE ANDROID SYSTEM WEBVIEW. GENERAL WEB
BUGS SHOULD BE FILED USING A DIFFERENT TEMPLATE!
Device name: hisilicon 3798mv100
Android version:android 4.4.2
WebView version (from system settings -> Apps -> Android System WebView):
Application:
Application version:
URLs (if applicable):
Steps to reproduce:
(1) please see this java script
==========================
var g_stb;
if (typeof(gSTB) == 'undefined'){
g_stb = {};
}else{
g_stb = gSTB;
}
webkit_xpcom.prototype = g_stb;
common_xpcom.prototype = new webkit_xpcom();
stb = new common_xpcom();
stb.InitPlayer();
==========================
(2) I use android webview.
==========================
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.addJavascriptInterface(new gSTB(MainActivity.this, mWebView), "gSTB");
public class gSTB {
...
@JavascriptInterface
public void InitPlayer() {
Log.v("gSTB", "InitPlayer");
}
...
}
==========================
(3) webview load this script.
when run stb.InitPlayer(), error "NPMethod called on non-NPObject" happen.
Expected result:
print log
Actual result:
,
Dec 21 2016
You cannot subclass a js object that's added by addJavascriptInterface. You can only call things on it directly. |
||
►
Sign in to add a comment |
||
Comment 1 by ti...@chromium.org
, Dec 16 2016