Fix flaky WebChromeClientTest.testOnJsBeforeUnload.

 Bug 5737291
 testOnJsBeforeUnload wasn't waiting for a load prior to loading
 the next URL. It was possible that the first URL hadn't started
 loading yet and so the unload didn't get called.

Change-Id: Idbf6b6b13ffe283183e086cdc488f3b3dbd278fa
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebChromeClientTest.java b/tests/tests/webkit/src/android/webkit/cts/WebChromeClientTest.java
index b40bfc9..eb9af77 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebChromeClientTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebChromeClientTest.java
@@ -48,6 +48,7 @@
     protected void setUp() throws Exception {
         super.setUp();
         mWebView = getActivity().getWebView();
+        WaitForLoadUrl.initializeWebView(mWebView);
         mWebServer = new CtsTestServer(getActivity());
     }
 
@@ -213,8 +214,10 @@
         assertFalse(webChromeClient.hadOnJsBeforeUnload());
 
         loadUrl(mWebServer.getAssetUrl(TestHtmlConstants.JS_UNLOAD_URL));
+        WaitForLoadUrl.waitForLoadComplete(TEST_TIMEOUT);
         // unload should trigger when we try to navigate away
         loadUrl(mWebServer.getAssetUrl(TestHtmlConstants.HELLO_WORLD_URL));
+        WaitForLoadUrl.waitForLoadComplete(TEST_TIMEOUT);
 
         new PollingCheck(TEST_TIMEOUT) {
             @Override