protected void doReload() throws Throwable { String url = mServer.setResponse("/form", LOAD_RESPONSE, null); String postData = "content=blabla"; byte[] data = EncodingUtils.getBytes(postData, "BASE64"); postUrlSync(mAwContents, mContentsClient.getOnPageFinishedHelper(), url, data); assertEquals(0, mContentsClient.getResubmissions()); assertEquals("Load", getTitleOnUiThread(mAwContents)); // Verify reload works as expected. mServer.setResponse("/form", RELOAD_RESPONSE, null); TestCallbackHelperContainer.OnPageFinishedHelper onPageFinishedHelper = mContentsClient.getOnPageFinishedHelper(); int callCount = onPageFinishedHelper.getCallCount(); // Run reload on UI thread. getInstrumentation() .runOnMainSync( new Runnable() { @Override public void run() { mAwContents.getContentViewCore().reload(true); } }); try { // Wait for page finished callback, or a timeout. A timeout is necessary // to detect a dontResend response. onPageFinishedHelper.waitForCallback(callCount, 1, TIMEOUT, TimeUnit.SECONDS); } catch (TimeoutException e) { } }
@MediumTest @Feature({"AndroidWebView"}) public void testNoErrorOnFailedSubresourceLoad() throws Throwable { TestCallbackHelperContainer.OnReceivedErrorHelper onReceivedErrorHelper = mContentsClient.getOnReceivedErrorHelper(); TestCallbackHelperContainer.OnPageFinishedHelper onPageFinishedHelper = mContentsClient.getOnPageFinishedHelper(); int currentCallCount = onPageFinishedHelper.getCallCount(); loadDataAsync( mAwContents, "<html><iframe src=\"http//invalid.url.co/\" /></html>", "text/html", false); onPageFinishedHelper.waitForCallback(currentCallCount); assertEquals(0, onReceivedErrorHelper.getCallCount()); }