From a40c8dbc97b4a8f8499b703300da65fe053e95c2 Mon Sep 17 00:00:00 2001 From: "bulach@chromium.org" Date: Fri, 2 Jul 2010 12:05:02 +0000 Subject: URLs with repeated domain names requesting tracking information Check URLs for repeated domain names then if there are any repeated show the port information of the URL as before if you had two of the same domain allowed/blocked only one would show in the bubble. Also added some unit tests for it. (landing on behalf of allanwoj. original review at http://codereview.chromium.org/2832044/show). BUG=40163 TEST=Two requests within a tab for tracking information with same domain but different port eg http://www.example.com and https://www.example.com A test fixture called ShowPortOnSameDomain is in GeolocationSettingsStateTests Review URL: http://codereview.chromium.org/2847045 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51521 0039d316-1c4b-4281-b951-d872f2087c98 --- .../geolocation_settings_state_unittest.cc | 63 ++++++++++++++++++++++ 1 file changed, 63 insertions(+) (limited to 'chrome/browser/geolocation/geolocation_settings_state_unittest.cc') diff --git a/chrome/browser/geolocation/geolocation_settings_state_unittest.cc b/chrome/browser/geolocation/geolocation_settings_state_unittest.cc index f7c9c17..f001ed2 100644 --- a/chrome/browser/geolocation/geolocation_settings_state_unittest.cc +++ b/chrome/browser/geolocation/geolocation_settings_state_unittest.cc @@ -119,4 +119,67 @@ TEST_F(GeolocationSettingsStateTests, ClearOnNewOrigin) { EXPECT_EQ(0U, tab_state_flags); } +TEST_F(GeolocationSettingsStateTests, ShowPortOnSameHost) { + TestingProfile profile; + GeolocationSettingsState state(&profile); + GURL url_0("http://www.example.com"); + + NavigationEntry entry; + entry.set_url(url_0); + NavigationController::LoadCommittedDetails load_committed_details; + load_committed_details.entry = &entry; + state.DidNavigate(load_committed_details); + + profile.GetGeolocationContentSettingsMap()->SetContentSetting( + url_0, url_0, CONTENT_SETTING_ALLOW); + state.OnGeolocationPermissionSet(url_0, true); + + GURL url_1("https://www.example.com"); + profile.GetGeolocationContentSettingsMap()->SetContentSetting( + url_1, url_0, CONTENT_SETTING_ALLOW); + state.OnGeolocationPermissionSet(url_1, true); + + GURL url_2("http://www.example1.com"); + profile.GetGeolocationContentSettingsMap()->SetContentSetting( + url_2, url_0, CONTENT_SETTING_ALLOW); + state.OnGeolocationPermissionSet(url_2, true); + + GeolocationSettingsState::StateMap state_map = + state.state_map(); + EXPECT_EQ(3U, state_map.size()); + + GeolocationSettingsState::FormattedHostsPerState formatted_host_per_state; + unsigned int tab_state_flags = 0; + state.GetDetailedInfo(&formatted_host_per_state, &tab_state_flags); + + EXPECT_EQ(3U, formatted_host_per_state[CONTENT_SETTING_ALLOW].size()); + EXPECT_EQ(1U, + formatted_host_per_state[CONTENT_SETTING_ALLOW].count( + url_0.spec())); + EXPECT_EQ(1U, + formatted_host_per_state[CONTENT_SETTING_ALLOW].count( + url_1.spec())); + EXPECT_EQ(1U, + formatted_host_per_state[CONTENT_SETTING_ALLOW].count( + url_2.host())); + + state.OnGeolocationPermissionSet(url_1, false); + formatted_host_per_state.clear(); + tab_state_flags = 0; + state.GetDetailedInfo(&formatted_host_per_state, &tab_state_flags); + + EXPECT_EQ(2U, formatted_host_per_state[CONTENT_SETTING_ALLOW].size()); + EXPECT_EQ(1U, + formatted_host_per_state[CONTENT_SETTING_ALLOW].count( + url_0.spec())); + EXPECT_EQ(1U, + formatted_host_per_state[CONTENT_SETTING_ALLOW].count( + url_2.host())); + EXPECT_EQ(1U, formatted_host_per_state[CONTENT_SETTING_BLOCK].size()); + EXPECT_EQ(1U, + formatted_host_per_state[CONTENT_SETTING_BLOCK].count( + url_1.spec())); +} + + } // namespace -- cgit v1.1