Index: android_webview/javatests/src/org/chromium/android_webview/test/PopupWindowTest.java |
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 a81e9070fd5577fddc9cde7cf413743f6c61260a..3044ddc5917a36b87d0d47d08314d70a7bb02781 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 |
@@ -8,15 +8,11 @@ import android.os.Build; |
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.net.test.util.TestWebServer; |
-import java.util.concurrent.Callable; |
-import java.util.concurrent.TimeUnit; |
- |
/** |
* Tests for pop up window flow. |
*/ |
@@ -25,9 +21,6 @@ public class PopupWindowTest extends AwTestBase { |
private TestAwContentsClient mParentContentsClient; |
private AwTestContainerView mParentContainerView; |
private AwContents mParentContents; |
- private TestAwContentsClient mPopupContentsClient; |
- private AwTestContainerView mPopupContainerView; |
- private AwContents mPopupContents; |
private TestWebServer mWebServer; |
private static final String POPUP_TITLE = "Popup Window"; |
@@ -49,67 +42,22 @@ public class PopupWindowTest extends AwTestBase { |
super.tearDown(); |
} |
- private void triggerPopup() throws Throwable { |
- enableJavaScriptOnUiThread(mParentContents); |
- getInstrumentation().runOnMainSync(new Runnable() { |
- @Override |
- public void run() { |
- mParentContents.getSettings().setSupportMultipleWindows(true); |
- mParentContents.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); |
- } |
- }); |
- |
+ @SmallTest |
+ @Feature({"AndroidWebView"}) |
+ public void testPopupWindow() throws Throwable { |
final String popupPath = "/popup.html"; |
- |
- final String parentPageHtml = CommonResources.makeHtmlPageFrom("", |
- "<script>" |
+ final String parentPageHtml = CommonResources.makeHtmlPageFrom("", "<script>" |
+ "function tryOpenWindow() {" |
+ " var newWindow = window.open('" + popupPath + "');" |
- + "}</script>" |
- + "<a class=\"full_view\" onclick=\"tryOpenWindow();\">Click me!</a>"); |
+ + "}</script>"); |
+ |
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(), |
- parentUrl); |
- |
- TestAwContentsClient.OnCreateWindowHelper onCreateWindowHelper = |
- mParentContentsClient.getOnCreateWindowHelper(); |
- int currentCallCount = onCreateWindowHelper.getCallCount(); |
- AwTestTouchUtils.simulateTouchCenterOfView(mParentContainerView); |
- onCreateWindowHelper.waitForCallback(currentCallCount, 1, WAIT_TIMEOUT_MS, |
- TimeUnit.MILLISECONDS); |
- } |
- |
- private void connectPendingPopup() throws Exception { |
- mPopupContentsClient = new TestAwContentsClient(); |
- mPopupContainerView = createAwTestContainerViewOnMainSync(mPopupContentsClient); |
- mPopupContents = mPopupContainerView.getAwContents(); |
- |
- getInstrumentation().runOnMainSync(new Runnable() { |
- @Override |
- public void run() { |
- mParentContents.supplyContentsForPopup(mPopupContents); |
- } |
- }); |
- } |
- |
- @SmallTest |
- @Feature({"AndroidWebView"}) |
- public void testPopupWindow() throws Throwable { |
- triggerPopup(); |
- connectPendingPopup(); |
- poll(new Callable<Boolean>() { |
- @Override |
- public Boolean call() throws Exception { |
- return POPUP_TITLE.equals(getTitleOnUiThread(mPopupContents)); |
- } |
- }); |
+ triggerPopup(mParentContents, mParentContentsClient, mWebServer, parentPageHtml, |
+ popupPageHtml, "/popup.html", "tryOpenWindow()"); |
+ AwContents popupContents = connectPendingPopup(mParentContents); |
+ assertEquals(POPUP_TITLE, getTitleOnUiThread(popupContents)); |
} |
} |