diff options
author | Nate Fischer <ntfschr@google.com> | 2019-01-22 17:39:15 -0800 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2019-01-22 17:39:15 -0800 |
commit | c0cf778b111fd698d813694f51ff330aff96f2c4 (patch) | |
tree | ddcd470c6d66b716e7a5b0c3eb2add1f787149d5 | |
parent | 3584e0abe6c36477104e17b49cee196832b23641 (diff) | |
parent | 8b4721b9de0d8b8f6cc920a0cc699f372d2fe0eb (diff) | |
download | cts-c0cf778b111fd698d813694f51ff330aff96f2c4.tar.gz |
Merge "WebView: fix broken WebViewSslTest" into nougat-cts-dev
am: 8b4721b9de
Change-Id: I2be44a3e99cfd21e992825d256f736c2abf7cdd8
-rw-r--r-- | tests/tests/webkit/src/android/webkit/cts/WebViewSslTest.java | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebViewSslTest.java b/tests/tests/webkit/src/android/webkit/cts/WebViewSslTest.java index e07267fc5f5..3c65a862501 100644 --- a/tests/tests/webkit/src/android/webkit/cts/WebViewSslTest.java +++ b/tests/tests/webkit/src/android/webkit/cts/WebViewSslTest.java @@ -730,12 +730,23 @@ public class WebViewSslTest extends ActivityInstrumentationTestCase2<WebViewCtsA mOnUiThread.clearSslPreferences(); mOnUiThread.loadUrlAndWaitForCompletion(url); // Page NOT loaded OK... - // In this case, we must NOT have received the onReceivedSslError callback as that is for - // recoverable (e.g. server auth) errors, whereas failing mandatory client auth is non- - // recoverable and should drop straight through to a load error. - assertFalse(webViewClient.wasOnReceivedSslErrorCalled()); - assertFalse(TestHtmlConstants.HELLO_WORLD_TITLE.equals(mOnUiThread.getTitle())); - assertEquals(WebViewClient.ERROR_FAILED_SSL_HANDSHAKE, webViewClient.onReceivedErrorCode()); + // + // In this test, we expect both a recoverable and non-recoverable error: + // + // 1. WebView does not trust the test server's certificate. This is a recoverable error, so + // WebView invokes #onReceivedSslError (and the WebViewClient calls #proceed). We don't + // specifically intend to test this part of the scenario, but we can't easily mock out + // WebView's certificate roots. + // 2. WebView proceeds with the handshake without providing client authentication. The + // server fails the client. This is non-recoverable, so WebView invokes + // #onReceivedError. + // + // We only assert the second error, since earlier WebView versions had a bug in which + // WebView hit error 2 first, which prevented it from hitting error 1. + assertFalse("Title should not be updated, since page load should have failed", + TestHtmlConstants.HELLO_WORLD_TITLE.equals(mOnUiThread.getTitle())); + assertEquals("Expected ERROR_FAILED_SSL_HANDSHAKE in onReceivedError", + WebViewClient.ERROR_FAILED_SSL_HANDSHAKE, webViewClient.onReceivedErrorCode()); } public void testProceedClientCertRequest() throws Throwable { |