Commit 7fb55612 authored by Tim Volodine's avatar Tim Volodine Committed by Commit Bot

[WebLayer] Update safe_browsing_browsertest

Add a kTypeForTesting to the safe_browsing_blocking_page and
a check in the browser test to make sure the correct
insterstitial is shown. Also remove unnecessary logging in
the test.

BUG=1015418,1034546,1071519
TEST=run_weblayer_browsertests --gtest_filter=SafeBrowsingBrowserTest*

Change-Id: Ia184557ab08f811dcd0903ba06b185b3d6c2d896
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2142273
Commit-Queue: Tim Volodine <timvolodine@chromium.org>
Reviewed-by: default avatarTobias Sargeant <tobiasjs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#759764}
parent 2f287811
......@@ -11,6 +11,11 @@
namespace weblayer {
// static
const content::InterstitialPageDelegate::TypeID
SafeBrowsingBlockingPage::kTypeForTesting =
&SafeBrowsingBlockingPage::kTypeForTesting;
SafeBrowsingBlockingPage::SafeBrowsingBlockingPage(
SafeBrowsingUIManager* ui_manager,
content::WebContents* web_contents,
......@@ -45,4 +50,9 @@ SafeBrowsingBlockingPage* SafeBrowsingBlockingPage::CreateBlockingPage(
BaseBlockingPage::CreateDefaultDisplayOptions(unsafe_resources));
}
content::InterstitialPageDelegate::TypeID
SafeBrowsingBlockingPage::GetTypeForTesting() {
return SafeBrowsingBlockingPage::kTypeForTesting;
}
} // namespace weblayer
......@@ -22,12 +22,18 @@ class SafeBrowsingBlockingPage : public safe_browsing::BaseBlockingPage {
public:
typedef security_interstitials::UnsafeResource UnsafeResource;
// Interstitial type, used in tests.
static const content::InterstitialPageDelegate::TypeID kTypeForTesting;
static SafeBrowsingBlockingPage* CreateBlockingPage(
SafeBrowsingUIManager* ui_manager,
content::WebContents* web_contents,
const GURL& main_frame_url,
const UnsafeResource& unsafe_resource);
// InterstitialPageDelegate methods:
content::InterstitialPageDelegate::TypeID GetTypeForTesting() override;
private:
SafeBrowsingBlockingPage(
SafeBrowsingUIManager* ui_manager,
......
......@@ -17,6 +17,7 @@
#include "content/public/browser/web_contents.h"
#include "content/public/test/test_utils.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "weblayer/browser/safe_browsing/safe_browsing_blocking_page.h"
#include "weblayer/browser/tab_impl.h"
#include "weblayer/public/navigation.h"
#include "weblayer/public/navigation_controller.h"
......@@ -50,7 +51,6 @@ class FakeSafeBrowsingApiHandler
std::unique_ptr<URLCheckCallbackMeta> callback,
const GURL& url,
const safe_browsing::SBThreatTypeSet& threat_types) override {
LOG(INFO) << "BLA test handler url=" + url.spec();
RunCallbackOnIOThread(std::move(callback), GetSafeBrowsingRestriction(url),
safe_browsing::ThreatMetadata());
}
......@@ -111,6 +111,11 @@ class SafeBrowsingBrowserTest : public WebLayerBrowserTest,
load_observer.Wait();
EXPECT_EQ(expect_interstitial, HasInterstitial());
if (expect_interstitial) {
if (base::FeatureList::IsEnabled(
safe_browsing::kCommittedSBInterstitials)) {
ASSERT_EQ(SafeBrowsingBlockingPage::kTypeForTesting,
GetSecurityInterstitialPage()->GetTypeForTesting());
}
EXPECT_TRUE(GetSecurityInterstitialPage()->GetHTMLContents().length() >
0);
}
......
......@@ -160,6 +160,7 @@ test("weblayer_browsertests") {
"//ui/android:android",
"//ui/touch_selection:touch_selection",
"//weblayer:locale_pak_assets",
"//weblayer/browser/safe_browsing:safe_browsing",
# Needed for WebLayerImpl.
"//weblayer/browser/java",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment