summaryrefslogtreecommitdiffstats
path: root/android_webview/javatests/src
diff options
context:
space:
mode:
authorgrt <grt@chromium.org>2015-02-26 06:26:53 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-26 14:27:45 +0000
commitc2d96fa87b653355fc8335c0accecff8852cae5d (patch)
treef4c0a61e47ed90ba37f2b2b9ba4d78dad1d80677 /android_webview/javatests/src
parent49001892c02a5287233acc68edaaf2e0dc981163 (diff)
downloadchromium_src-c2d96fa87b653355fc8335c0accecff8852cae5d.zip
chromium_src-c2d96fa87b653355fc8335c0accecff8852cae5d.tar.gz
chromium_src-c2d96fa87b653355fc8335c0accecff8852cae5d.tar.bz2
Revert of [Android WebView] Synthesize a fake page loading event on page source modification (patchset #8 id:140001 of https://codereview.chromium.org/924833003/)
Reason for revert: Reverting to see if this caused AwContentsClientFullScreenTest#testPowerSaveBlockerIsTransferredToFullscreen failure here: http://crbug.com/462213. Original issue's description: > [Android WebView] Synthesize a fake page loading event on page source modification > > When a script modifies page source of a non-committed page, we need to > notify clients, so they can update the URL bar to avoid confusion. > > BUG=458569 > > Committed: https://crrev.com/e38bb6cdeb1170cb2cd7faae8507dc6c34c58c7d > Cr-Commit-Position: refs/heads/master@{#318222} TBR=torne@chromium.org,tedchoc@chromium.org,davidben@chromium.org,creis@chromium.org,mnaganov@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=458569 Review URL: https://codereview.chromium.org/958933002 Cr-Commit-Position: refs/heads/master@{#318231}
Diffstat (limited to 'android_webview/javatests/src')
-rw-r--r--android_webview/javatests/src/org/chromium/android_webview/test/PopupWindowTest.java74
1 files changed, 23 insertions, 51 deletions
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/PopupWindowTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/PopupWindowTest.java
index a59030d..a81e907 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/PopupWindowTest.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/PopupWindowTest.java
@@ -5,14 +5,13 @@
package org.chromium.android_webview.test;
import android.os.Build;
-import android.test.suitebuilder.annotation.MediumTest;
+import android.test.suitebuilder.annotation.SmallTest;
import org.chromium.android_webview.AwContents;
import org.chromium.android_webview.test.util.AwTestTouchUtils;
import org.chromium.android_webview.test.util.CommonResources;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.MinAndroidSdkLevel;
-import org.chromium.content.browser.test.util.TestCallbackHelperContainer;
import org.chromium.net.test.util.TestWebServer;
import java.util.concurrent.Callable;
@@ -39,9 +38,6 @@ public class PopupWindowTest extends AwTestBase {
mParentContentsClient = new TestAwContentsClient();
mParentContainerView = createAwTestContainerViewOnMainSync(mParentContentsClient);
mParentContents = mParentContainerView.getAwContents();
- mPopupContentsClient = new TestAwContentsClient();
- mPopupContainerView = createAwTestContainerViewOnMainSync(mPopupContentsClient);
- mPopupContents = mPopupContainerView.getAwContents();
mWebServer = TestWebServer.start();
}
@@ -53,9 +49,7 @@ public class PopupWindowTest extends AwTestBase {
super.tearDown();
}
- // It is expected that the parent page contains a link that opens a popup window,
- // and the test server is already pre-loaded with both parent and popup pages.
- private void triggerPopup(String parentUrl) throws Throwable {
+ private void triggerPopup() throws Throwable {
enableJavaScriptOnUiThread(mParentContents);
getInstrumentation().runOnMainSync(new Runnable() {
@Override
@@ -65,6 +59,21 @@ public class PopupWindowTest extends AwTestBase {
}
});
+ final String popupPath = "/popup.html";
+
+ final String parentPageHtml = CommonResources.makeHtmlPageFrom("",
+ "<script>"
+ + "function tryOpenWindow() {"
+ + " var newWindow = window.open('" + popupPath + "');"
+ + "}</script>"
+ + "<a class=\"full_view\" onclick=\"tryOpenWindow();\">Click me!</a>");
+ final String popupPageHtml = CommonResources.makeHtmlPageFrom(
+ "<title>" + POPUP_TITLE + "</title>",
+ "This is a popup window");
+
+ final String parentUrl = mWebServer.setResponse("/popupParent.html", parentPageHtml, null);
+ mWebServer.setResponse(popupPath, popupPageHtml, null);
+
mParentContentsClient.getOnCreateWindowHelper().setReturnValue(true);
loadUrlSync(mParentContents,
mParentContentsClient.getOnPageFinishedHelper(),
@@ -79,6 +88,10 @@ public class PopupWindowTest extends AwTestBase {
}
private void connectPendingPopup() throws Exception {
+ mPopupContentsClient = new TestAwContentsClient();
+ mPopupContainerView = createAwTestContainerViewOnMainSync(mPopupContentsClient);
+ mPopupContents = mPopupContainerView.getAwContents();
+
getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
@@ -87,22 +100,10 @@ public class PopupWindowTest extends AwTestBase {
});
}
- @MediumTest
+ @SmallTest
@Feature({"AndroidWebView"})
public void testPopupWindow() throws Throwable {
- final String popupPath = "/popup.html";
- final String parentPageHtml = CommonResources.makeHtmlPageFrom("",
- "<script>"
- + "function tryOpenWindow() {"
- + " var newWindow = window.open('" + popupPath + "');"
- + "}</script>"
- + "<a class=\"full_view\" onclick=\"tryOpenWindow();\">Click me!</a>");
- final String popupPageHtml = CommonResources.makeHtmlPageFrom(
- "<title>" + POPUP_TITLE + "</title>",
- "This is a popup window");
- final String parentUrl = mWebServer.setResponse("/popupParent.html", parentPageHtml, null);
- mWebServer.setResponse(popupPath, popupPageHtml, null);
- triggerPopup(parentUrl);
+ triggerPopup();
connectPendingPopup();
poll(new Callable<Boolean>() {
@Override
@@ -111,33 +112,4 @@ public class PopupWindowTest extends AwTestBase {
}
});
}
-
- @MediumTest
- @Feature({"AndroidWebView"})
- public void testOnPageFinishedCalledAfterModifyingPageSource() throws Throwable {
- final String popupPath = "/popup.html";
- final String popupUrl = mWebServer.setResponseWithNoContentStatus(popupPath);
- final String parentHtml = CommonResources.makeHtmlPageFrom("",
- "<script>"
- + "function tryOpenWindow() {"
- + " window.popupWindow = window.open('" + popupPath + "');"
- + "}"
- + "function modifyDomOfPopup() {"
- + " window.popupWindow.document.body.innerHTML = 'Hello from the parent!';"
- + "}</script>"
- + "<a class='full_view' onclick='tryOpenWindow();'>Click me!</a>");
- final String parentUrl = mWebServer.setResponse("/parent.html", parentHtml, null);
- triggerPopup(parentUrl);
- TestCallbackHelperContainer.OnPageFinishedHelper onPageFinishedHelper =
- mPopupContentsClient.getOnPageFinishedHelper();
- int onPageFinishedCallCount = onPageFinishedHelper.getCallCount();
- connectPendingPopup();
- onPageFinishedHelper.waitForCallback(onPageFinishedCallCount);
-
- onPageFinishedCallCount = onPageFinishedHelper.getCallCount();
- executeJavaScriptAndWaitForResult(mParentContents, mParentContentsClient,
- "modifyDomOfPopup()");
- onPageFinishedHelper.waitForCallback(onPageFinishedCallCount);
- assertEquals("about:blank", onPageFinishedHelper.getUrl());
- }
}