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

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

Issue 1859163002: android webview: setShouldReuseGlobalForUnownedMainFrame (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add test Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.android_webview.test; 5 package org.chromium.android_webview.test;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.graphics.Point; 8 import android.graphics.Point;
9 import android.net.http.SslError; 9 import android.net.http.SslError;
10 import android.os.Build; 10 import android.os.Build;
11 import android.os.SystemClock; 11 import android.os.SystemClock;
12 import android.test.suitebuilder.annotation.LargeTest; 12 import android.test.suitebuilder.annotation.LargeTest;
13 import android.test.suitebuilder.annotation.MediumTest; 13 import android.test.suitebuilder.annotation.MediumTest;
14 import android.test.suitebuilder.annotation.SmallTest; 14 import android.test.suitebuilder.annotation.SmallTest;
15 import android.view.WindowManager; 15 import android.view.WindowManager;
16 import android.webkit.JavascriptInterface; 16 import android.webkit.JavascriptInterface;
17 import android.webkit.ValueCallback; 17 import android.webkit.ValueCallback;
18 import android.webkit.WebSettings; 18 import android.webkit.WebSettings;
19 import android.webkit.WebSettings.LayoutAlgorithm; 19 import android.webkit.WebSettings.LayoutAlgorithm;
20 20
21 import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout; 21 import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout;
22 22
23 import org.apache.http.Header; 23 import org.apache.http.Header;
24 import org.apache.http.HttpRequest; 24 import org.apache.http.HttpRequest;
25 import org.chromium.android_webview.AwContents; 25 import org.chromium.android_webview.AwContents;
26 import org.chromium.android_webview.AwSettings; 26 import org.chromium.android_webview.AwSettings;
27 import org.chromium.android_webview.AwWebResourceResponse; 27 import org.chromium.android_webview.AwWebResourceResponse;
28 import org.chromium.android_webview.test.util.CommonResources; 28 import org.chromium.android_webview.test.util.CommonResources;
29 import org.chromium.android_webview.test.util.ImagePageGenerator; 29 import org.chromium.android_webview.test.util.ImagePageGenerator;
30 import org.chromium.android_webview.test.util.JSUtils;
30 import org.chromium.android_webview.test.util.VideoTestUtil; 31 import org.chromium.android_webview.test.util.VideoTestUtil;
31 import org.chromium.android_webview.test.util.VideoTestWebServer; 32 import org.chromium.android_webview.test.util.VideoTestWebServer;
32 import org.chromium.base.test.util.DisabledTest; 33 import org.chromium.base.test.util.DisabledTest;
33 import org.chromium.base.test.util.Feature; 34 import org.chromium.base.test.util.Feature;
34 import org.chromium.base.test.util.TestFileUtil; 35 import org.chromium.base.test.util.TestFileUtil;
35 import org.chromium.base.test.util.UrlUtils; 36 import org.chromium.base.test.util.UrlUtils;
36 import org.chromium.content.browser.test.util.CallbackHelper; 37 import org.chromium.content.browser.test.util.CallbackHelper;
37 import org.chromium.content.browser.test.util.HistoryUtils; 38 import org.chromium.content.browser.test.util.HistoryUtils;
38 import org.chromium.content.browser.test.util.TestCallbackHelperContainer; 39 import org.chromium.content.browser.test.util.TestCallbackHelperContainer;
39 import org.chromium.content_public.browser.WebContents; 40 import org.chromium.content_public.browser.WebContents;
(...skipping 2826 matching lines...) Expand 10 before | Expand all | Expand 10 after
2866 onPageFinishedHelper.waitForCallback(initialCallCount + 1, 1, WAIT_T IMEOUT_MS, 2867 onPageFinishedHelper.waitForCallback(initialCallCount + 1, 1, WAIT_T IMEOUT_MS,
2867 TimeUnit.MILLISECONDS); 2868 TimeUnit.MILLISECONDS);
2868 assertEquals(url, onPageFinishedHelper.getUrl()); 2869 assertEquals(url, onPageFinishedHelper.getUrl());
2869 } finally { 2870 } finally {
2870 if (httpServer != null) { 2871 if (httpServer != null) {
2871 httpServer.shutdown(); 2872 httpServer.shutdown();
2872 } 2873 }
2873 } 2874 }
2874 } 2875 }
2875 2876
2877 private TestDependencyFactory mOverridenFactory;
2878
2879 @Override
2880 public void tearDown() throws Exception {
2881 mOverridenFactory = null;
2882 super.tearDown();
2883 }
2884
2885 @Override
2886 protected TestDependencyFactory createTestDependencyFactory() {
2887 if (mOverridenFactory == null) {
2888 return new TestDependencyFactory();
2889 } else {
2890 return mOverridenFactory;
2891 }
2892 }
2893
2894 private static class EmptyDocumentPeristenceTestDependencyFactory
2895 extends TestDependencyFactory {
2896 private boolean mAllow;
2897 public EmptyDocumentPeristenceTestDependencyFactory(boolean allow) {
2898 mAllow = allow;
2899 }
2900
2901 @Override
2902 public AwSettings createAwSettings(Context context, boolean supportsLega cyQuirks) {
2903 return new AwSettings(context, false /* isAccessFromFileURLsGrantedB yDefault */,
2904 supportsLegacyQuirks, mAllow);
2905 }
2906 }
2907
2908 private void doAllowEmptyDocumentPersistenceTest(boolean allow) throws Throw able {
2909 mOverridenFactory = new EmptyDocumentPeristenceTestDependencyFactory(all ow);
2910
2911 final TestAwContentsClient client = new TestAwContentsClient();
2912 final AwTestContainerView mContainerView = createAwTestContainerViewOnMa inSync(client);
2913 final AwContents awContents = mContainerView.getAwContents();
2914 enableJavaScriptOnUiThread(awContents);
2915 JSUtils.executeJavaScriptAndWaitForResult(this, awContents,
2916 client.getOnEvaluateJavaScriptResultHelper(),
2917 "window.emptyDocumentPersistenceTest = true;");
2918 loadUrlSync(awContents, client.getOnPageFinishedHelper(), "about:blank") ;
2919 String result = JSUtils.executeJavaScriptAndWaitForResult(this, awConten ts,
2920 client.getOnEvaluateJavaScriptResultHelper(),
2921 "window.emptyDocumentPersistenceTest ? 'set' : 'not set';");
2922 assertEquals(allow ? "\"set\"" : "\"not set\"", result);
2923 }
2924
2925 @SmallTest
2926 @Feature({"AndroidWebView", "Preferences"})
2927 public void testAllowEmptyDocumentPersistence() throws Throwable {
2928 doAllowEmptyDocumentPersistenceTest(true);
2929 }
2930
2931 @SmallTest
2932 @Feature({"AndroidWebView", "Preferences"})
2933 public void testDisallowEmptyDocumentPersistence() throws Throwable {
2934 doAllowEmptyDocumentPersistenceTest(false);
2935 }
2936
2876 static class ViewPair { 2937 static class ViewPair {
2877 private final AwTestContainerView mContainer0; 2938 private final AwTestContainerView mContainer0;
2878 private final TestAwContentsClient mClient0; 2939 private final TestAwContentsClient mClient0;
2879 private final AwTestContainerView mContainer1; 2940 private final AwTestContainerView mContainer1;
2880 private final TestAwContentsClient mClient1; 2941 private final TestAwContentsClient mClient1;
2881 2942
2882 ViewPair(AwTestContainerView container0, TestAwContentsClient client0, 2943 ViewPair(AwTestContainerView container0, TestAwContentsClient client0,
2883 AwTestContainerView container1, TestAwContentsClient client1) { 2944 AwTestContainerView container1, TestAwContentsClient client1) {
2884 this.mContainer0 = container0; 2945 this.mContainer0 = container0;
2885 this.mClient0 = client0; 2946 this.mClient0 = client0;
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
3014 final AwContents awContents = webView.getAwContents(); 3075 final AwContents awContents = webView.getAwContents();
3015 runTestOnUiThread(new Runnable() { 3076 runTestOnUiThread(new Runnable() {
3016 @Override 3077 @Override
3017 public void run() { 3078 public void run() {
3018 awContents.getContentViewCore().sendDoubleTapForTest( 3079 awContents.getContentViewCore().sendDoubleTapForTest(
3019 SystemClock.uptimeMillis(), x, y); 3080 SystemClock.uptimeMillis(), x, y);
3020 } 3081 }
3021 }); 3082 });
3022 } 3083 }
3023 } 3084 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698