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

Unified Diff: chrome/browser/content_settings/host_content_settings_map_unittest.cc

Issue 2054623002: Refactor HostContentSettingsMap::SetWebsiteSettingDefaultScope to take a std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing reviewer comments Created 4 years, 6 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
Index: chrome/browser/content_settings/host_content_settings_map_unittest.cc
diff --git a/chrome/browser/content_settings/host_content_settings_map_unittest.cc b/chrome/browser/content_settings/host_content_settings_map_unittest.cc
index 1532e97e05c277bbe8f931f0b235ccf1b60acab3..5b230f9fa3c6dc752aefbc93574a2407ffc50c1d 100644
--- a/chrome/browser/content_settings/host_content_settings_map_unittest.cc
+++ b/chrome/browser/content_settings/host_content_settings_map_unittest.cc
@@ -9,6 +9,7 @@
#include "base/command_line.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
+#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
#include "chrome/browser/content_settings/content_settings_mock_observer.h"
#include "chrome/browser/content_settings/cookie_settings_factory.h"
@@ -851,7 +852,7 @@ TEST_F(HostContentSettingsMapTest, OffTheRecordDontInheritSetting) {
test_value.SetString("test", "value");
host_content_settings_map->SetWebsiteSettingDefaultScope(
host, host, CONTENT_SETTINGS_TYPE_USB_CHOOSER_DATA, std::string(),
- test_value.DeepCopy());
+ base::WrapUnique(test_value.DeepCopy()));
// The setting is not inherted by |otr_map|.
std::unique_ptr<base::Value> stored_value =
@@ -1317,3 +1318,22 @@ TEST_F(HostContentSettingsMapTest, MigrateKeygenSettings) {
host_content_settings_map->GetContentSetting(
host, host, CONTENT_SETTINGS_TYPE_KEYGEN, std::string()));
}
+
+TEST_F(HostContentSettingsMapTest, InvalidPattern) {
+ // This is a regression test for crbug.com/618529, which fixed a memory leak
+ // when a website setting was set under a URL that mapped to an invalid
+ // pattern.
+ TestingProfile profile;
+ HostContentSettingsMap* host_content_settings_map =
+ HostContentSettingsMapFactory::GetForProfile(&profile);
+ GURL unsupported_url = GURL("view-source:http://www.google.com");
+ base::DictionaryValue test_value;
+ test_value.SetString("test", "value");
+ host_content_settings_map->SetWebsiteSettingDefaultScope(
+ unsupported_url, unsupported_url, CONTENT_SETTINGS_TYPE_APP_BANNER,
+ std::string(), base::WrapUnique(test_value.DeepCopy()));
+ EXPECT_EQ(nullptr,
+ host_content_settings_map->GetWebsiteSetting(
+ unsupported_url, unsupported_url,
+ CONTENT_SETTINGS_TYPE_APP_BANNER, std::string(), nullptr));
+}
« no previous file with comments | « chrome/browser/browsing_data/browsing_data_remover_unittest.cc ('k') | chrome/browser/engagement/site_engagement_score.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698