some improvements for browser test harness

* intercept JavaScript onUnload confirmation, no dialog shown
* using null download manager to avoid actual downloading during
  random url test

Change-Id: I41758a87a0c5de5b42d34db8a403bb6d6ca053b2
diff --git a/tests/src/com/android/browser/PopularUrlsTest.java b/tests/src/com/android/browser/PopularUrlsTest.java
index ac9a90e..86ce94d 100644
--- a/tests/src/com/android/browser/PopularUrlsTest.java
+++ b/tests/src/com/android/browser/PopularUrlsTest.java
@@ -17,7 +17,6 @@
 package com.android.browser;
 
 import android.app.Instrumentation;
-import android.content.Context;
 import android.content.Intent;
 import android.net.Uri;
 import android.net.http.SslError;
@@ -25,6 +24,7 @@
 import android.test.ActivityInstrumentationTestCase2;
 import android.text.TextUtils;
 import android.util.Log;
+import android.webkit.DownloadListener;
 import android.webkit.HttpAuthHandler;
 import android.webkit.JsPromptResult;
 import android.webkit.JsResult;
@@ -188,6 +188,16 @@
 
                 return true;
             }
+
+            /*
+             * Skip the unload confirmation
+             */
+            @Override
+            public boolean onJsBeforeUnload(
+                    WebView view, String url, String message, JsResult result) {
+                result.confirm();
+                return true;
+            }
         });
 
         webView.setWebViewClient(new TestWebViewClient(webView.getWebViewClient()) {
@@ -238,6 +248,15 @@
             }
 
         });
+
+        webView.setDownloadListener(new DownloadListener() {
+
+            @Override
+            public void onDownloadStart(String url, String userAgent, String contentDisposition,
+                    String mimetype, long contentLength) {
+                Log.v(TAG, String.format("Download request ignored: %s", url));
+            }
+        });
     }
 
     void resetLatch() {