OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" | 5 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" |
6 | 6 |
7 #include "chrome/common/pref_names.h" | 7 #include "chrome/common/pref_names.h" |
8 #include "chrome/test/testing_profile.h" | 8 #include "chrome/test/testing_profile.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 profile.GetGeolocationContentSettingsMap(); | 116 profile.GetGeolocationContentSettingsMap(); |
117 GURL top_level("http://www.toplevel0.com/foo/bar"); | 117 GURL top_level("http://www.toplevel0.com/foo/bar"); |
118 map->SetContentSetting(top_level, top_level, CONTENT_SETTING_ALLOW); | 118 map->SetContentSetting(top_level, top_level, CONTENT_SETTING_ALLOW); |
119 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 119 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
120 map->GetContentSetting(top_level, top_level)); | 120 map->GetContentSetting(top_level, top_level)); |
121 // Set to CONTENT_SETTING_DEFAULT and check the actual value has changed. | 121 // Set to CONTENT_SETTING_DEFAULT and check the actual value has changed. |
122 map->SetContentSetting(top_level, top_level, CONTENT_SETTING_DEFAULT); | 122 map->SetContentSetting(top_level, top_level, CONTENT_SETTING_DEFAULT); |
123 EXPECT_EQ(CONTENT_SETTING_ASK, map->GetContentSetting(top_level, top_level)); | 123 EXPECT_EQ(CONTENT_SETTING_ASK, map->GetContentSetting(top_level, top_level)); |
124 } | 124 } |
125 | 125 |
126 TEST_F(GeolocationContentSettingsMapTests, ClearOneOrigin) { | |
127 TestingProfile profile; | |
128 GeolocationContentSettingsMap* map = | |
129 profile.GetGeolocationContentSettingsMap(); | |
130 GURL requester_0("http://www.iframe0.com/foo/bar"); | |
131 GURL requester_1("http://www.iframe1.com/foo/bar"); | |
132 GURL embedder_0("http://www.toplevel0.com/foo/bar"); | |
133 map->SetContentSetting(requester_0, embedder_0, CONTENT_SETTING_ALLOW); | |
134 map->SetContentSetting(requester_1, embedder_0, CONTENT_SETTING_ALLOW); | |
135 EXPECT_EQ(CONTENT_SETTING_ALLOW, | |
136 map->GetContentSetting(requester_0, embedder_0)); | |
137 EXPECT_EQ(CONTENT_SETTING_ALLOW, | |
138 map->GetContentSetting(requester_1, embedder_0)); | |
139 | |
140 map->ClearOneRequestingOrigin(requester_0.GetOrigin()); | |
141 EXPECT_EQ(CONTENT_SETTING_ASK, | |
142 map->GetContentSetting(requester_0, embedder_0)); | |
143 | |
144 // Passing a non-origin shouldn't do anything. | |
145 map->ClearOneRequestingOrigin(requester_1); | |
146 EXPECT_EQ(CONTENT_SETTING_ALLOW, | |
147 map->GetContentSetting(requester_1, embedder_0)); | |
148 } | |
149 | |
150 TEST_F(GeolocationContentSettingsMapTests, Reset) { | 126 TEST_F(GeolocationContentSettingsMapTests, Reset) { |
151 TestingProfile profile; | 127 TestingProfile profile; |
152 GeolocationContentSettingsMap* map = | 128 GeolocationContentSettingsMap* map = |
153 profile.GetGeolocationContentSettingsMap(); | 129 profile.GetGeolocationContentSettingsMap(); |
154 GURL requester_0("http://www.iframe0.com/foo/bar"); | 130 GURL requester_0("http://www.iframe0.com/foo/bar"); |
155 GURL embedder_0("http://www.toplevel0.com/foo/bar"); | 131 GURL embedder_0("http://www.toplevel0.com/foo/bar"); |
156 map->SetContentSetting(requester_0, embedder_0, CONTENT_SETTING_ALLOW); | 132 map->SetContentSetting(requester_0, embedder_0, CONTENT_SETTING_ALLOW); |
157 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 133 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
158 map->GetContentSetting(requester_0, embedder_0)); | 134 map->GetContentSetting(requester_0, embedder_0)); |
159 GeolocationContentSettingsMap::AllOriginsSettings content_settings( | 135 GeolocationContentSettingsMap::AllOriginsSettings content_settings( |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 GURL("http://bad-embedder"))); | 232 GURL("http://bad-embedder"))); |
257 EXPECT_EQ(CONTENT_SETTING_ASK, | 233 EXPECT_EQ(CONTENT_SETTING_ASK, |
258 map->GetContentSetting(GURL("http://a/"), | 234 map->GetContentSetting(GURL("http://a/"), |
259 GURL("http://example.com"))); | 235 GURL("http://example.com"))); |
260 EXPECT_EQ(CONTENT_SETTING_ASK, | 236 EXPECT_EQ(CONTENT_SETTING_ASK, |
261 map->GetContentSetting(GURL("http://bad_requester/"), | 237 map->GetContentSetting(GURL("http://bad_requester/"), |
262 GURL("http://b/"))); | 238 GURL("http://b/"))); |
263 } | 239 } |
264 | 240 |
265 } // namespace | 241 } // namespace |
OLD | NEW |