### Question:
WXWebView implements IWebView { @Override public void postMessage(Object msg) { if (getWebView() == null) return; try { JSONObject initData = new JSONObject(); initData.put("type", "message"); initData.put("data", msg); initData.put("origin", mOrigin); evaluateJS("javascript:(function () {" + "var initData = " + initData.toString() + ";" + "try {" + "var event = new MessageEvent('message', initData);" + "window.dispatchEvent(event);" + "} catch (e) {}" + "})();"); } catch (JSONException e) { throw new RuntimeException(e); } } WXWebView(Context context, String origin); @Override View getView(); @Override void destroy(); @Override void loadUrl(String url); @Override void loadDataWithBaseURL(String source); @Override void reload(); @Override void goBack(); @Override void goForward(); @Override void postMessage(Object msg); @Override void setShowLoading(boolean shown); @Override void setOnErrorListener(OnErrorListener listener); @Override void setOnPageListener(OnPageListener listener); @Override void setOnMessageListener(OnMessageListener listener);  }### Answer:
@Test public void testPostMessage() throws Exception { Map<String, Object> msg = new HashMap<>(); msg.put("test1", 1); msg.put("test2", "2"); view.postMessage(msg); }