Skip to content

Commit

Permalink
aw: Add test for onPageStarted with history API
Browse files Browse the repository at this point in the history
The expected though surprising behavior is that history API does not
trigger onPageStarted or onPageFinished.

Bug: 1027165
Change-Id: I26163f98fe87184719d5ca4e195d5577496c5b00
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1940747
Commit-Queue: Bo <boliu@chromium.org>
Reviewed-by: Nate Fischer <ntfschr@chromium.org>
Auto-Submit: Bo <boliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#719715}
  • Loading branch information
Bo Liu authored and Commit Bot committed Nov 27, 2019
1 parent 63a8d71 commit 96681c2
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ public void testNotCalledForValidSubresources() throws Throwable {
@MediumTest
@Feature({"AndroidWebView"})
public void testNotCalledForHistoryApi() throws Throwable {
TestCallbackHelperContainer.OnPageStartedHelper onPageStartedHelper =
mContentsClient.getOnPageStartedHelper();
TestCallbackHelperContainer.OnPageFinishedHelper onPageFinishedHelper =
mContentsClient.getOnPageFinishedHelper();
AwActivityTestRule.enableJavaScriptOnUiThread(mAwContents);
Expand All @@ -222,6 +224,7 @@ public void testNotCalledForHistoryApi() throws Throwable {
final String historyUrl = webServer.getResponseUrl(historyPath);
final String syncUrl = webServer.setResponse(syncPath, testHtml, null);

Assert.assertEquals(0, onPageStartedHelper.getCallCount());
Assert.assertEquals(0, onPageFinishedHelper.getCallCount());
mActivityTestRule.loadUrlSync(mAwContents, onPageFinishedHelper, testUrl);

Expand All @@ -232,10 +235,14 @@ public void testNotCalledForHistoryApi() throws Throwable {
// we load another valid page. Since callbacks arrive sequentially if the next callback
// we get is for the synchronizationUrl we know that the previous load did not schedule
// a callback for the iframe.
final int synchronizationPageCallCount = onPageFinishedHelper.getCallCount();
final int synchronizationPageStartedCallCount = onPageStartedHelper.getCallCount();
final int synchronizationPageFinishedCallCount = onPageFinishedHelper.getCallCount();
mActivityTestRule.loadUrlAsync(mAwContents, syncUrl);

onPageFinishedHelper.waitForCallback(synchronizationPageCallCount);
onPageStartedHelper.waitForCallback(synchronizationPageStartedCallCount);
onPageFinishedHelper.waitForCallback(synchronizationPageFinishedCallCount);
Assert.assertEquals(syncUrl, onPageStartedHelper.getUrl());
Assert.assertEquals(2, onPageStartedHelper.getCallCount());
Assert.assertEquals(syncUrl, onPageFinishedHelper.getUrl());
Assert.assertEquals(2, onPageFinishedHelper.getCallCount());
} finally {
Expand Down

0 comments on commit 96681c2

Please sign in to comment.