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

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

Issue 11192057: [Android] Add supportMultipleWindows setting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments addressed, moved fields in WebPreferences. Created 8 years, 2 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 | « no previous file | content/browser/android/content_settings.cc » ('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/AwSettingsTest.java
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwSettingsTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwSettingsTest.java
index 30a757bef955e8977e92ef6e9c49017fb087d345..c7d9e6fba0e4cebc5eae2bc28396995bc0abccb9 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/AwSettingsTest.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwSettingsTest.java
@@ -875,6 +875,72 @@ public class AwSettingsTest extends AndroidWebViewTestBase {
}
}
+ class AwSettingsJavaScriptPopupsTestHelper extends AwSettingsTestHelper<Boolean> {
+ static private final String POPUP_ENABLED = "Popup enabled";
+ static private final String POPUP_BLOCKED = "Popup blocked";
+
+ AwSettingsJavaScriptPopupsTestHelper(
+ AwContents awContents,
+ TestAwContentsClient contentViewClient,
+ int index) throws Throwable {
+ super(awContents, contentViewClient, true);
+ }
+
+ @Override
+ protected Boolean getAlteredValue() {
+ return ENABLED;
+ }
+
+ @Override
+ protected Boolean getInitialValue() {
+ return DISABLED;
+ }
+
+ @Override
+ protected Boolean getCurrentValue() {
+ return mContentSettings.getJavaScriptCanOpenWindowsAutomatically();
+ }
+
+ @Override
+ protected void setCurrentValue(Boolean value) {
+ mContentSettings.setJavaScriptCanOpenWindowsAutomatically(value);
+ }
+
+ @Override
+ protected void doEnsureSettingHasValue(Boolean value) throws Throwable {
+ loadDataSync(getData());
+ final boolean expectPopupEnabled = value;
+ assertTrue(CriteriaHelper.pollForCriteria(new Criteria() {
+ @Override
+ public boolean isSatisfied() {
+ try {
+ String title = getTitleOnUiThread();
+ return expectPopupEnabled ? POPUP_ENABLED.equals(title) :
+ POPUP_BLOCKED.equals(title);
+ } catch (Throwable t) {
+ t.printStackTrace();
+ fail("Failed to getTitleOnUiThread: " + t.toString());
+ return false;
+ }
+ }
+ }, TEST_TIMEOUT, CHECK_INTERVAL));
+ assertEquals(value ? POPUP_ENABLED : POPUP_BLOCKED, getTitleOnUiThread());
+ }
+
+ private String getData() {
+ return "<html><head>" +
+ "<script>" +
+ " function tryOpenWindow() {" +
+ " var newWindow = window.open(" +
+ " 'data:text/html;charset=utf-8," +
+ " <html><head><title>" + POPUP_ENABLED + "</title></head></html>');" +
+ " if (!newWindow) document.title = '" + POPUP_BLOCKED + "';" +
+ " }" +
+ "</script></head>" +
+ "<body onload='tryOpenWindow()'></body></html>";
+ }
+ }
+
// The test verifies that JavaScript is disabled upon WebView
// creation without accessing ContentSettings. If the test passes,
// it means that WebView-specific web preferences configuration
@@ -1825,6 +1891,27 @@ public class AwSettingsTest extends AndroidWebViewTestBase {
new AwSettingsTextZoomTestHelper(views.getContents1(), views.getClient1()));
}
+ public void testJavaScriptPopupsNormal() throws Throwable {
+ ViewPair views = createViews(NORMAL_VIEW, NORMAL_VIEW);
+ runPerViewSettingsTest(
+ new AwSettingsJavaScriptPopupsTestHelper(views.getContents0(), views.getClient0(), 0),
+ new AwSettingsJavaScriptPopupsTestHelper(views.getContents1(), views.getClient1(), 1));
+ }
+
+ public void testJavaScriptPopupsIncognito() throws Throwable {
+ ViewPair views = createViews(INCOGNITO_VIEW, INCOGNITO_VIEW);
+ runPerViewSettingsTest(
+ new AwSettingsJavaScriptPopupsTestHelper(views.getContents0(), views.getClient0(), 0),
+ new AwSettingsJavaScriptPopupsTestHelper(views.getContents1(), views.getClient1(), 1));
+ }
+
+ public void testJavaScriptPopupsBoth() throws Throwable {
+ ViewPair views = createViews(NORMAL_VIEW, INCOGNITO_VIEW);
+ runPerViewSettingsTest(
+ new AwSettingsJavaScriptPopupsTestHelper(views.getContents0(), views.getClient0(), 0),
+ new AwSettingsJavaScriptPopupsTestHelper(views.getContents1(), views.getClient1(), 1));
+ }
+
class ViewPair {
private final AwContents contents0;
private final TestAwContentsClient client0;
« no previous file with comments | « no previous file | content/browser/android/content_settings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698