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

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

Issue 2814593002: WebView: add {set,get}SafeBrowsingEnabled per WebView (Closed)
Patch Set: Add comment about getSafeBrowsingEnabled() Created 3 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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.content.SharedPreferences; 8 import android.content.SharedPreferences;
9 import android.graphics.Bitmap; 9 import android.graphics.Bitmap;
10 import android.graphics.Color; 10 import android.graphics.Color;
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 mWebContentsObserver.getAttachedInterstitialPageHelper().waitForCallback (interstitialCount); 306 mWebContentsObserver.getAttachedInterstitialPageHelper().waitForCallback (interstitialCount);
307 OnReceivedError2Helper errorHelper = mContentsClient.getOnReceivedError2 Helper(); 307 OnReceivedError2Helper errorHelper = mContentsClient.getOnReceivedError2 Helper();
308 int errorCount = errorHelper.getCallCount(); 308 int errorCount = errorHelper.getCallCount();
309 dontProceedThroughInterstitial(); 309 dontProceedThroughInterstitial();
310 errorHelper.waitForCallback(errorCount); 310 errorHelper.waitForCallback(errorCount);
311 assertEquals(ErrorCodeConversionHelper.ERROR_UNKNOWN, errorHelper.getErr or().errorCode); 311 assertEquals(ErrorCodeConversionHelper.ERROR_UNKNOWN, errorHelper.getErr or().errorCode);
312 final String subresourceUrl = mTestServer.getURL(MALWARE_HTML_PATH); 312 final String subresourceUrl = mTestServer.getURL(MALWARE_HTML_PATH);
313 assertEquals(subresourceUrl, errorHelper.getRequest().url); 313 assertEquals(subresourceUrl, errorHelper.getRequest().url);
314 assertFalse(errorHelper.getRequest().isMainFrame); 314 assertFalse(errorHelper.getRequest().isMainFrame);
315 } 315 }
316
317 @SmallTest
318 @Feature({"AndroidWebView"})
319 @CommandLineFlags.Add(AwSwitches.WEBVIEW_ENABLE_SAFEBROWSING_SUPPORT)
320 public void testSafeBrowsingCanBeDisabledPerWebview() throws Throwable {
321 getAwSettingsOnUiThread(mAwContents).setSafeBrowsingEnabled(false);
322
323 final String responseUrl = mTestServer.getURL(MALWARE_HTML_PATH);
324 loadUrlSync(mAwContents, mContentsClient.getOnPageFinishedHelper(), resp onseUrl);
325 waitForVisualStateCallback(mAwContents);
326 assertEquals("Target page should be visible", MALWARE_PAGE_BACKGROUND_CO LOR,
327 GraphicsTestUtils.getPixelColorAtCenterOfView(mAwContents, mCont ainerView));
328 }
329
330 @SmallTest
331 @Feature({"AndroidWebView"})
332 public void testSafeBrowsingCanBeEnabledPerWebview() throws Throwable {
333 final String responseUrl = mTestServer.getURL(MALWARE_HTML_PATH);
334 loadUrlSync(mAwContents, mContentsClient.getOnPageFinishedHelper(), resp onseUrl);
335 waitForVisualStateCallback(mAwContents);
336 assertEquals("Target page should be visible", MALWARE_PAGE_BACKGROUND_CO LOR,
337 GraphicsTestUtils.getPixelColorAtCenterOfView(mAwContents, mCont ainerView));
338
339 getAwSettingsOnUiThread(mAwContents).setSafeBrowsingEnabled(true);
340
341 loadGreenPage();
342 int count = mWebContentsObserver.getAttachedInterstitialPageHelper().get CallCount();
343 loadUrlAsync(mAwContents, responseUrl);
344 mWebContentsObserver.getAttachedInterstitialPageHelper().waitForCallback (count);
345 assertTrue("Original page should not be showing",
346 GREEN_PAGE_BACKGROUND_COLOR
347 != GraphicsTestUtils.getPixelColorAtCenterOfView(
348 mAwContents, mContainerView));
349 assertTrue("Target page should not be visible",
350 MALWARE_PAGE_BACKGROUND_COLOR
351 != GraphicsTestUtils.getPixelColorAtCenterOfView(
352 mAwContents, mContainerView));
353 }
316 } 354 }
OLDNEW
« no previous file with comments | « android_webview/java/src/org/chromium/android_webview/AwSettings.java ('k') | android_webview/lib/main/aw_main_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698