Index: android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java |
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java |
index ac9a1df2040d3aca3684f89b441c19418f852822..e75f535bba26c9ea8943c86cf58c24d79f0de4bb 100644 |
--- a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java |
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java |
@@ -500,7 +500,7 @@ public class AwContentsTest extends AwTestBase { |
} |
} |
- // This is a meta test that we don't accidentally turn of hardware |
+ // This is a meta test that we don't accidentally turn off hardware |
// acceleration in instrumentation tests without notice. Do not add the |
// @DisableHardwareAccelerationForTest annotation for this test. |
@Feature({"AndroidWebView"}) |
@@ -511,4 +511,72 @@ public class AwContentsTest extends AwTestBase { |
assertTrue(testContainer.isHardwareAccelerated()); |
assertTrue(testContainer.isBackedByHardwareView()); |
} |
+ |
+ @Feature({"AndroidWebView"}) |
+ @SmallTest |
+ // TODO(hush): more ssl tests. And put the ssl tests into a separate test |
+ // class. |
+ public void testClearSslPreferences() throws Throwable { |
sgurun-gerrit only
2014/12/12 04:23:10
There is a great deal of overlap between tests, tr
hush (inactive)
2014/12/12 19:43:40
Ok.
I just merged the 2 tests.
|
+ final AwTestContainerView testContainer = |
+ createAwTestContainerViewOnMainSync(mContentsClient); |
+ final AwContents awContents = testContainer.getAwContents(); |
+ TestWebServer webServer = TestWebServer.startSsl(); |
+ final String pagePath = "/hello.html"; |
+ final String pageUrl = |
+ webServer.setResponse(pagePath, "<html><body>hello world</body></html>", null); |
+ final CallbackHelper onReceivedSslErrorHelper = |
+ mContentsClient.getOnReceivedSslErrorHelper(); |
+ int onSslErrorCallCount = onReceivedSslErrorHelper.getCallCount(); |
+ |
+ loadUrlSync(awContents, mContentsClient.getOnPageFinishedHelper(), pageUrl); |
+ |
+ assertEquals(onSslErrorCallCount + 1, onReceivedSslErrorHelper.getCallCount()); |
+ assertEquals(1, webServer.getRequestCount(pagePath)); |
+ |
+ // Now load the page again. This time, we expect no ssl error, because |
+ // user's decision should be remembered. |
+ onSslErrorCallCount = onReceivedSslErrorHelper.getCallCount(); |
+ loadUrlSync(awContents, mContentsClient.getOnPageFinishedHelper(), pageUrl); |
+ assertEquals(onSslErrorCallCount, onReceivedSslErrorHelper.getCallCount()); |
+ |
+ // Now clear the ssl preferences then load the same url again. Expect to see |
+ // onReceivedSslError getting called again. |
+ awContents.clearSslPreferences(); |
+ onSslErrorCallCount = onReceivedSslErrorHelper.getCallCount(); |
+ loadUrlSync(awContents, mContentsClient.getOnPageFinishedHelper(), pageUrl); |
+ assertEquals(onSslErrorCallCount + 1, onReceivedSslErrorHelper.getCallCount()); |
+ } |
+ |
+ @Feature({"AndroidWebView"}) |
+ @SmallTest |
+ public void testDenySslErrorNotRememebered() throws Throwable { |
sgurun-gerrit only
2014/12/12 04:23:10
nit: Remembered
hush (inactive)
2014/12/12 19:43:40
Done.
|
+ final AwTestContainerView testContainer = |
+ createAwTestContainerViewOnMainSync(mContentsClient); |
+ final AwContents awContents = testContainer.getAwContents(); |
+ TestWebServer webServer = TestWebServer.startSsl(); |
+ final String pagePath = "/hello.html"; |
+ final String pageUrl = |
+ webServer.setResponse(pagePath, "<html><body>hello world</body></html>", null); |
+ final CallbackHelper onReceivedSslErrorHelper = |
+ mContentsClient.getOnReceivedSslErrorHelper(); |
+ mContentsClient.setAllowSslError(false); |
+ int onSslErrorCallCount = onReceivedSslErrorHelper.getCallCount(); |
+ |
+ loadUrlSync(awContents, mContentsClient.getOnPageFinishedHelper(), pageUrl); |
+ |
+ assertEquals(onSslErrorCallCount + 1, onReceivedSslErrorHelper.getCallCount()); |
+ |
+ // Now load the same page again. This time, we still expect onReceivedSslError, |
+ // because we only remember user's decision if it is "allow". |
+ onSslErrorCallCount = onReceivedSslErrorHelper.getCallCount(); |
+ loadUrlSync(awContents, mContentsClient.getOnPageFinishedHelper(), pageUrl); |
+ assertEquals(onSslErrorCallCount + 1, onReceivedSslErrorHelper.getCallCount()); |
+ |
+ // Now clear the ssl preferences then load the same url again. Expect to see |
sgurun-gerrit only
2014/12/12 04:23:10
himm, don't think this part adds any value here.
hush (inactive)
2014/12/12 19:43:39
removed.
|
+ // onReceivedSslError getting called again. |
+ awContents.clearSslPreferences(); |
+ onSslErrorCallCount = onReceivedSslErrorHelper.getCallCount(); |
+ loadUrlSync(awContents, mContentsClient.getOnPageFinishedHelper(), pageUrl); |
+ assertEquals(onSslErrorCallCount + 1, onReceivedSslErrorHelper.getCallCount()); |
+ } |
} |