From 02458309d7a490450e8ca2cf8e4ef3f48670ef90 Mon Sep 17 00:00:00 2001 From: "mnaganov@chromium.org" <mnaganov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> Date: Fri, 13 Sep 2013 10:50:50 +0000 Subject: [Android WebView] Wire up Blink's WideViewportQuirkEnabled setting This setting should be always enabled by now, independently of other quirks. Added tests to ensure that UseWideViewport works regardless of whether quirks are enabled or not. The WideViewport quirk is to maintain compatibility with Android apps, and is required so long as WebSettings.{get|set}UseWideViewPort is supported. Also enabled AwSettingsTest#testUseWideViewportLayoutWidth since the fix in Blink has been rolled in. BUG=285995,288037 Review URL: https://chromiumcodereview.appspot.com/23496047 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@223027 0039d316-1c4b-4281-b951-d872f2087c98 --- .../android_webview/test/AwSettingsTest.java | 51 ++++++++++++++++------ .../chromium/android_webview/test/AwTestBase.java | 23 ++++++++-- android_webview/native/aw_settings.cc | 1 + 3 files changed, 58 insertions(+), 17 deletions(-) (limited to 'android_webview') 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 c63f699..04d7502 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 @@ -2240,19 +2240,18 @@ public class AwSettingsTest extends AwTestBase { new AwSettingsUseWideViewportTestHelper(views.getContents1(), views.getClient1())); } - /* - * @SmallTest - * @Feature({"AndroidWebView", "Preferences"}) - * Failing after Blink r157293, see crbug.com/285995 - */ - @DisabledTest - public void testUseWideViewportLayoutWidth() throws Throwable { - final TestAwContentsClient contentClient = new TestAwContentsClient(); - final AwTestContainerView testContainerView = - createAwTestContainerViewOnMainSync(contentClient); - final AwContents awContents = testContainerView.getAwContents(); + @SmallTest + @Feature({"AndroidWebView", "Preferences"}) + public void testUseWideViewportWithTwoViewsNoQuirks() throws Throwable { + ViewPair views = createViews(false); + runPerViewSettingsTest( + new AwSettingsUseWideViewportTestHelper(views.getContents0(), views.getClient0()), + new AwSettingsUseWideViewportTestHelper(views.getContents1(), views.getClient1())); + } + + private void useWideViewportLayoutWidthTest( + final AwContents awContents, CallbackHelper onPageFinishedHelper) throws Throwable { AwSettings settings = getAwSettingsOnUiThread(awContents); - CallbackHelper onPageFinishedHelper = contentClient.getOnPageFinishedHelper(); final String pageTemplate = "<html><head>%s</head>" + "<body onload='document.title=document.body.clientWidth'></body></html>"; @@ -2305,6 +2304,26 @@ public class AwSettingsTest extends AwTestBase { assertEquals(viewportTagSpecifiedWidth, getTitleOnUiThread(awContents)); } + @SmallTest + @Feature({"AndroidWebView", "Preferences"}) + public void testUseWideViewportLayoutWidth() throws Throwable { + TestAwContentsClient contentClient = new TestAwContentsClient(); + AwTestContainerView testContainerView = + createAwTestContainerViewOnMainSync(contentClient); + useWideViewportLayoutWidthTest(testContainerView.getAwContents(), + contentClient.getOnPageFinishedHelper()); + } + + @SmallTest + @Feature({"AndroidWebView", "Preferences"}) + public void testUseWideViewportLayoutWidthNoQuirks() throws Throwable { + TestAwContentsClient contentClient = new TestAwContentsClient(); + AwTestContainerView testContainerView = + createAwTestContainerViewOnMainSync(contentClient, false); + useWideViewportLayoutWidthTest(testContainerView.getAwContents(), + contentClient.getOnPageFinishedHelper()); + } + /* @MediumTest @Feature({"AndroidWebView", "Preferences"}) @@ -2619,12 +2638,16 @@ public class AwSettingsTest extends AwTestBase { } private ViewPair createViews() throws Throwable { + return createViews(true); + } + + private ViewPair createViews(boolean supportsLegacyQuirks) throws Throwable { TestAwContentsClient client0 = new TestAwContentsClient(); TestAwContentsClient client1 = new TestAwContentsClient(); return new ViewPair( - createAwTestContainerViewOnMainSync(client0).getAwContents(), + createAwTestContainerViewOnMainSync(client0, supportsLegacyQuirks).getAwContents(), client0, - createAwTestContainerViewOnMainSync(client1).getAwContents(), + createAwTestContainerViewOnMainSync(client1, supportsLegacyQuirks).getAwContents(), client1); } diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java index c0f6387..cfc9b17 100644 --- a/android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java +++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java @@ -211,7 +211,13 @@ public class AwTestBase protected AwTestContainerView createAwTestContainerView( final AwContentsClient awContentsClient) { - AwTestContainerView testContainerView = createDetachedAwTestContainerView(awContentsClient); + return createAwTestContainerView(awContentsClient, true); + } + + protected AwTestContainerView createAwTestContainerView( + final AwContentsClient awContentsClient, boolean supportsLegacyQuirks) { + AwTestContainerView testContainerView = + createDetachedAwTestContainerView(awContentsClient, supportsLegacyQuirks); getActivity().addView(testContainerView); testContainerView.requestFocus(); return testContainerView; @@ -223,6 +229,11 @@ public class AwTestBase protected AwTestContainerView createDetachedAwTestContainerView( final AwContentsClient awContentsClient) { + return createDetachedAwTestContainerView(awContentsClient, true); + } + + protected AwTestContainerView createDetachedAwTestContainerView( + final AwContentsClient awContentsClient, boolean supportsLegacyQuirks) { final TestDependencyFactory testDependencyFactory = createTestDependencyFactory(); final AwTestContainerView testContainerView = testDependencyFactory.createAwTestContainerView(getActivity()); @@ -230,18 +241,24 @@ public class AwTestBase // See http://crbug.com/278106 testContainerView.initialize(new AwContents( mBrowserContext, testContainerView, testContainerView.getInternalAccessDelegate(), - awContentsClient, false, testDependencyFactory.createLayoutSizer(), true)); + awContentsClient, false, testDependencyFactory.createLayoutSizer(), + supportsLegacyQuirks)); return testContainerView; } protected AwTestContainerView createAwTestContainerViewOnMainSync( final AwContentsClient client) throws Exception { + return createAwTestContainerViewOnMainSync(client, true); + } + + protected AwTestContainerView createAwTestContainerViewOnMainSync( + final AwContentsClient client, final boolean supportsLegacyQuirks) throws Exception { final AtomicReference<AwTestContainerView> testContainerView = new AtomicReference<AwTestContainerView>(); getInstrumentation().runOnMainSync(new Runnable() { @Override public void run() { - testContainerView.set(createAwTestContainerView(client)); + testContainerView.set(createAwTestContainerView(client, supportsLegacyQuirks)); } }); return testContainerView.get(); diff --git a/android_webview/native/aw_settings.cc b/android_webview/native/aw_settings.cc index 46651f3..1be87d8 100644 --- a/android_webview/native/aw_settings.cc +++ b/android_webview/native/aw_settings.cc @@ -189,6 +189,7 @@ void AwSettings::UpdateWebkitPreferencesLocked(JNIEnv* env, jobject obj) { prefs.databases_enabled = Java_AwSettings_getDatabaseEnabledLocked(env, obj); + prefs.wide_viewport_quirk = true; prefs.double_tap_to_zoom_enabled = prefs.use_wide_viewport = Java_AwSettings_getUseWideViewportLocked(env, obj); -- cgit v1.1