Commit 79f092fc authored by Nate Fischer's avatar Nate Fischer Committed by Commit Bot

AW: add back-to-safety SafeBrowsing test

This test ensures that back-to-safety navigates backward for the main
frame case. This functionality was landed in crrev/474038.

BUG=684710

Change-Id: I2ff0223bdd6212d65afe6848894ce2d74cfae7ae
Reviewed-on: https://chromium-review.googlesource.com/516508Reviewed-by: default avatarBo Liu <boliu@chromium.org>
Commit-Queue: Nate Fischer <ntfschr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#474918}
parent e38092a8
......@@ -30,6 +30,8 @@ import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.InMemorySharedPreferences;
import org.chromium.components.safe_browsing.SafeBrowsingApiBridge;
import org.chromium.components.safe_browsing.SafeBrowsingApiHandler;
import org.chromium.content.browser.test.util.Criteria;
import org.chromium.content.browser.test.util.CriteriaHelper;
import org.chromium.content_public.browser.WebContents;
import org.chromium.net.test.EmbeddedTestServer;
......@@ -65,6 +67,8 @@ public class SafeBrowsingTest extends AwTestBase {
// A gray page with an iframe to MALWARE_HTML_PATH
private static final String IFRAME_HTML_PATH = RESOURCE_PATH + "/iframe.html";
private static final String INTERSTITIAL_PAGE_TITLE = "Security error";
/**
* A fake SafeBrowsingApiHandler which treats URLs ending in MALWARE_HTML_PATH as malicious URLs
* that should be blocked.
......@@ -241,6 +245,15 @@ public class SafeBrowsingTest extends AwTestBase {
});
}
private void waitForInterstitialToChangeTitle() {
CriteriaHelper.pollUiThread(new Criteria() {
@Override
public boolean isSatisfied() {
return INTERSTITIAL_PAGE_TITLE.equals(mAwContents.getTitle());
}
});
}
@SmallTest
@Feature({"AndroidWebView"})
@CommandLineFlags.Add(AwSwitches.WEBVIEW_ENABLE_SAFEBROWSING_SUPPORT)
......@@ -369,6 +382,29 @@ public class SafeBrowsingTest extends AwTestBase {
assertFalse(errorHelper.getRequest().isMainFrame);
}
@SmallTest
@Feature({"AndroidWebView"})
@CommandLineFlags.Add(AwSwitches.WEBVIEW_ENABLE_SAFEBROWSING_SUPPORT)
public void testSafeBrowsingDontProceedNavigatesBackForMainFrame() throws Throwable {
loadGreenPage();
final String originalTitle = getTitleOnUiThread(mAwContents);
int interstitialCount =
mWebContentsObserver.getAttachedInterstitialPageHelper().getCallCount();
final String responseUrl = mTestServer.getURL(MALWARE_HTML_PATH);
loadUrlAsync(mAwContents, responseUrl);
mWebContentsObserver.getAttachedInterstitialPageHelper().waitForCallback(interstitialCount);
waitForInterstitialToChangeTitle();
dontProceedThroughInterstitial();
// Make sure we navigate back to previous page
CriteriaHelper.pollUiThread(new Criteria() {
@Override
public boolean isSatisfied() {
return originalTitle.equals(mAwContents.getTitle());
}
});
}
@SmallTest
@Feature({"AndroidWebView"})
@CommandLineFlags.Add(AwSwitches.WEBVIEW_ENABLE_SAFEBROWSING_SUPPORT)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment