Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2095)

Unified Diff: android_webview/javatests/src/org/chromium/android_webview/test/PopupWindowTest.java

Issue 958933002: Revert of [Android WebView] Synthesize a fake page loading event on page source modification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « android_webview/java_library_common.mk ('k') | android_webview/libwebviewchromium.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 a59030da71ac59acc63c087bd5110e0ca6f6aaef..a81e9070fd5577fddc9cde7cf413743f6c61260a 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 @@
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 @@
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
@@ -64,6 +58,21 @@
mParentContents.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
}
});
+
+ 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,
@@ -79,6 +88,10 @@
}
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 @@
});
}
- @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 @@
}
});
}
-
- @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());
- }
}
« no previous file with comments | « android_webview/java_library_common.mk ('k') | android_webview/libwebviewchromium.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698