Merge "Fix for bug 8656892: remove WebView before calling destroy()" into jb-mr2-dev
diff --git a/tests/src/android/webkit/cts/WebViewStubActivity.java b/tests/src/android/webkit/cts/WebViewStubActivity.java
index fcf260f..6a51bbe 100644
--- a/tests/src/android/webkit/cts/WebViewStubActivity.java
+++ b/tests/src/android/webkit/cts/WebViewStubActivity.java
@@ -20,6 +20,8 @@
 
 import android.app.Activity;
 import android.os.Bundle;
+import android.view.ViewGroup;
+import android.view.ViewParent;
 import android.webkit.WebView;
 
 public class WebViewStubActivity extends Activity {
@@ -38,6 +40,10 @@
 
     @Override
     public void onDestroy() {
+        ViewParent parent =  mWebView.getParent();
+        if (parent instanceof ViewGroup) {
+            ((ViewGroup) parent).removeView(mWebView);
+        }
         mWebView.destroy();
         super.onDestroy();
     }