From ffbd3db61bce21b9332f7783086fce703706031f Mon Sep 17 00:00:00 2001 From: Adam Comella Date: Sat, 19 Aug 2017 00:52:49 -0700 Subject: [PATCH] Android WebView: Only fire onLoadStart for toplevel page loads Summary: Currently, `onLoadStart` fires for a couple of cases: 1. toplevel page loads (e.g. initial page load, clicking links) 2. loading of pages within an iframe The fact that `onLoadStart` fires for case (2) causes some problems. For example, it makes it difficult for the code that uses the WebView to know what URL the WebView is currently rendering. This is because the listener can't distinguish between the toplevel URL and the URL of an iframe. Additionally, this behavior is inconsistent with the behavior on iOS. On iOS, `onLoadStart` only fires for toplevel page loads. To fix these issues, this change deletes the `doUpdateVisitedHistory` handler so that `onLoadStart` only fires for case (1). **Test Plan** Created a test page that has an iframe and loaded it in the WebView. Verified that `onLoadStart` only fires for toplevel page loads. Adam Comella Microsoft Corp. Closes https://github.com/facebook/react-native/pull/15554 Differential Revision: D5665979 Pulled By: hramos fbshipit-source-id: a52e473bc5691a6e180f45f0728e4ad89a7d354f --- .../react/views/webview/ReactWebViewManager.java | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/webview/ReactWebViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/webview/ReactWebViewManager.java index 73b6a4564..3377bda0d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/webview/ReactWebViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/webview/ReactWebViewManager.java @@ -189,17 +189,6 @@ public class ReactWebViewManager extends SimpleViewManager { new TopLoadingErrorEvent(webView.getId(), eventData)); } - @Override - public void doUpdateVisitedHistory(WebView webView, String url, boolean isReload) { - super.doUpdateVisitedHistory(webView, url, isReload); - - dispatchEvent( - webView, - new TopLoadingStartEvent( - webView.getId(), - createWebViewEvent(webView, url))); - } - protected void emitFinishEvent(WebView webView, String url) { dispatchEvent( webView,