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

Unified Diff: chrome/browser/extensions/webstore_inline_installer_browsertest.cc

Issue 2854763002: Revert of Use new SafeBrowsing redirect tracking code in CWS pings. (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/webstore_inline_installer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/webstore_inline_installer_browsertest.cc
diff --git a/chrome/browser/extensions/webstore_inline_installer_browsertest.cc b/chrome/browser/extensions/webstore_inline_installer_browsertest.cc
index 32a4bb5b72457b90beb2fab2bdf3fbc3c26911c8..7d71fb4a0bffe71e614aaff45f16d7b010a73690 100644
--- a/chrome/browser/extensions/webstore_inline_installer_browsertest.cc
+++ b/chrome/browser/extensions/webstore_inline_installer_browsertest.cc
@@ -118,8 +118,7 @@
content::RenderFrameHost* host,
const std::string& extension_id,
const GURL& requestor_url,
- const Callback& callback,
- bool enable_safebrowsing_redirects)
+ const Callback& callback)
: WebstoreInlineInstaller(
contents,
host,
@@ -140,10 +139,6 @@
return WebstoreInlineInstaller::CheckRequestorAlive();
}
- bool SafeBrowsingNavigationEventsEnabled() const override {
- return enable_safebrowsing_redirects_;
- }
-
// Tests that care about the actual arguments to the install callback can use
// this to receive a copy in |install_result_target|.
void set_install_result_target(
@@ -171,22 +166,13 @@
// arguments.
std::unique_ptr<InstallResult>* install_result_target_;
- // This can be set by tests that want to use the new SafeBrowsing redirect
- // tracker.
- bool enable_safebrowsing_redirects_;
-
ProgrammableInstallPrompt* programmable_prompt_;
};
class WebstoreInlineInstallerForTestFactory :
public WebstoreInlineInstallerFactory {
public:
- WebstoreInlineInstallerForTestFactory()
- : last_installer_(nullptr), enable_safebrowsing_redirects_(false) {}
- explicit WebstoreInlineInstallerForTestFactory(
- bool enable_safebrowsing_redirects)
- : last_installer_(nullptr),
- enable_safebrowsing_redirects_(enable_safebrowsing_redirects) {}
+ WebstoreInlineInstallerForTestFactory() : last_installer_(nullptr) {}
~WebstoreInlineInstallerForTestFactory() override {}
WebstoreInlineInstallerForTest* last_installer() { return last_installer_; }
@@ -198,16 +184,13 @@
const GURL& requestor_url,
const WebstoreStandaloneInstaller::Callback& callback) override {
last_installer_ = new WebstoreInlineInstallerForTest(
- contents, host, webstore_item_id, requestor_url, callback,
- enable_safebrowsing_redirects_);
+ contents, host, webstore_item_id, requestor_url, callback);
return last_installer_;
}
private:
// The last installer that was created.
WebstoreInlineInstallerForTest* last_installer_;
-
- bool enable_safebrowsing_redirects_;
};
IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerTest,
@@ -390,9 +373,7 @@
RunTest("runTest");
}
-class WebstoreInlineInstallerRedirectTest
- : public WebstoreInlineInstallerTest,
- public ::testing::WithParamInterface<bool> {
+class WebstoreInlineInstallerRedirectTest : public WebstoreInlineInstallerTest {
public:
WebstoreInlineInstallerRedirectTest() : cws_request_received_(false) {}
~WebstoreInlineInstallerRedirectTest() override {}
@@ -420,16 +401,8 @@
// Test that an install from a page arrived at via redirects includes the
// redirect information in the webstore request.
-IN_PROC_BROWSER_TEST_P(WebstoreInlineInstallerRedirectTest,
+IN_PROC_BROWSER_TEST_F(WebstoreInlineInstallerRedirectTest,
IncludesRedirectData) {
- const bool using_safe_browsing_tracker = GetParam();
- WebContents* web_contents =
- browser()->tab_strip_model()->GetActiveWebContents();
- TabHelper* tab_helper = TabHelper::FromWebContents(web_contents);
- WebstoreInlineInstallerForTestFactory* factory =
- new WebstoreInlineInstallerForTestFactory(using_safe_browsing_tracker);
- tab_helper->SetWebstoreInlineInstallerFactoryForTests(factory);
-
// Hand craft a url that will cause the test server to issue redirects.
const std::vector<std::string> redirects = {kRedirect1Domain,
kRedirect2Domain};
@@ -446,11 +419,7 @@
AutoAcceptInstall();
ui_test_utils::NavigateToURL(browser(), install_url);
-
- RunTestAsync("runTest");
- while (!ProgrammableInstallPrompt::Ready())
- base::RunLoop().RunUntilIdle();
- web_contents->Close();
+ RunTest("runTest");
EXPECT_TRUE(cws_request_received_);
ASSERT_NE(nullptr, cws_request_json_data_);
@@ -460,21 +429,15 @@
ASSERT_NE(nullptr, redirect_list);
// Check that the expected domains are in the redirect list.
- const std::set<std::string> expected_redirect_domains = {
+ const std::vector<std::string> expected_redirect_domains = {
kRedirect1Domain, kRedirect2Domain, kAppDomain};
-
- // The SafeBrowsing tracker has a much more liberal definition of "redirect"
- // and it may (based on timing) pick up additional navigations that occur
- // shortly before the navigation we mainly care about here. Be somewhat
- // permissive in what we accept as redirect results.
- ASSERT_LE(expected_redirect_domains.size(), redirect_list->GetSize());
-
+ ASSERT_EQ(expected_redirect_domains.size(), redirect_list->GetSize());
+ int i = 0;
for (const auto& value : *redirect_list) {
std::string value_string;
ASSERT_TRUE(value.GetAsString(&value_string));
GURL redirect_url(value_string);
- EXPECT_TRUE(expected_redirect_domains.find(redirect_url.host()) !=
- expected_redirect_domains.end());
+ EXPECT_EQ(expected_redirect_domains[i++], redirect_url.host());
}
}
@@ -509,13 +472,6 @@
EXPECT_TRUE(cws_request_received_);
ASSERT_EQ(nullptr, cws_request_json_data_);
}
-
-INSTANTIATE_TEST_CASE_P(NetRedirectTracking,
- WebstoreInlineInstallerRedirectTest,
- testing::Values(false));
-INSTANTIATE_TEST_CASE_P(SafeBrowsingRedirectTracking,
- WebstoreInlineInstallerRedirectTest,
- testing::Values(true));
class WebstoreInlineInstallerListenerTest : public WebstoreInlineInstallerTest {
public:
« no previous file with comments | « chrome/browser/extensions/webstore_inline_installer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698