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

Side by Side Diff: chrome/browser/tab_contents/tab_specific_content_settings_unittest.cc

Issue 5318002: Also register read cookies in the content settings delegate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 10 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/tab_contents/tab_specific_content_settings.h" 5 #include "chrome/browser/tab_contents/tab_specific_content_settings.h"
6 6
7 #include "chrome/test/testing_profile.h" 7 #include "chrome/test/testing_profile.h"
8 #include "net/base/cookie_options.h" 8 #include "net/base/cookie_options.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 EXPECT_FALSE(content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES)); 46 EXPECT_FALSE(content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES));
47 EXPECT_FALSE( 47 EXPECT_FALSE(
48 content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_JAVASCRIPT)); 48 content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_JAVASCRIPT));
49 EXPECT_FALSE( 49 EXPECT_FALSE(
50 content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_PLUGINS)); 50 content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_PLUGINS));
51 EXPECT_FALSE( 51 EXPECT_FALSE(
52 content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES)); 52 content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES));
53 EXPECT_FALSE(content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_POPUPS)); 53 EXPECT_FALSE(content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_POPUPS));
54 54
55 // Set a cookie, block access to images, block a popup. 55 // Set a cookie, block access to images, block a popup.
56 content_settings.OnCookieAccessed( 56 content_settings.OnCookieChanged(
57 GURL("http://google.com"), "A=B", options, false); 57 GURL("http://google.com"), "A=B", options, false);
58 EXPECT_TRUE(test_delegate.SettingsChanged()); 58 EXPECT_TRUE(test_delegate.SettingsChanged());
59 EXPECT_FALSE(test_delegate.ContentBlocked()); 59 EXPECT_FALSE(test_delegate.ContentBlocked());
60 test_delegate.Reset(); 60 test_delegate.Reset();
61 content_settings.OnContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES, 61 content_settings.OnContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES,
62 std::string()); 62 std::string());
63 EXPECT_TRUE(test_delegate.SettingsChanged()); 63 EXPECT_TRUE(test_delegate.SettingsChanged());
64 EXPECT_TRUE(test_delegate.ContentBlocked()); 64 EXPECT_TRUE(test_delegate.ContentBlocked());
65 test_delegate.Reset(); 65 test_delegate.Reset();
66 content_settings.SetPopupsBlocked(true); 66 content_settings.SetPopupsBlocked(true);
67 EXPECT_TRUE(test_delegate.SettingsChanged()); 67 EXPECT_TRUE(test_delegate.SettingsChanged());
68 EXPECT_TRUE(test_delegate.ContentBlocked()); 68 EXPECT_TRUE(test_delegate.ContentBlocked());
69 test_delegate.Reset(); 69 test_delegate.Reset();
70 70
71 // Check that only the respective content types are affected. 71 // Check that only the respective content types are affected.
72 EXPECT_TRUE(content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES)); 72 EXPECT_TRUE(content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES));
73 EXPECT_FALSE( 73 EXPECT_FALSE(
74 content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_JAVASCRIPT)); 74 content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_JAVASCRIPT));
75 EXPECT_FALSE( 75 EXPECT_FALSE(
76 content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_PLUGINS)); 76 content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_PLUGINS));
77 EXPECT_FALSE( 77 EXPECT_FALSE(
78 content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES)); 78 content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES));
79 EXPECT_TRUE(content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_POPUPS)); 79 EXPECT_TRUE(content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_POPUPS));
80 content_settings.OnCookieAccessed( 80 content_settings.OnCookieChanged(
81 GURL("http://google.com"), "A=B", options, false); 81 GURL("http://google.com"), "A=B", options, false);
82 82
83 // Block a cookie. 83 // Block a cookie.
84 content_settings.OnCookieAccessed( 84 content_settings.OnCookieChanged(
85 GURL("http://google.com"), "C=D", options, true); 85 GURL("http://google.com"), "C=D", options, true);
86 EXPECT_TRUE( 86 EXPECT_TRUE(
87 content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES)); 87 content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES));
88 88
89 // Reset blocked content settings. 89 // Reset blocked content settings.
90 content_settings.ClearBlockedContentSettingsExceptForCookies(); 90 content_settings.ClearBlockedContentSettingsExceptForCookies();
91 EXPECT_TRUE(test_delegate.SettingsChanged()); 91 EXPECT_TRUE(test_delegate.SettingsChanged());
92 EXPECT_FALSE(test_delegate.ContentBlocked()); 92 EXPECT_FALSE(test_delegate.ContentBlocked());
93 EXPECT_FALSE(content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES)); 93 EXPECT_FALSE(content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES));
94 EXPECT_FALSE( 94 EXPECT_FALSE(
(...skipping 22 matching lines...) Expand all
117 TestingProfile profile; 117 TestingProfile profile;
118 TabSpecificContentSettings content_settings(&test_delegate, &profile); 118 TabSpecificContentSettings content_settings(&test_delegate, &profile);
119 net::CookieOptions options; 119 net::CookieOptions options;
120 120
121 ASSERT_FALSE( 121 ASSERT_FALSE(
122 content_settings.IsContentAccessed(CONTENT_SETTINGS_TYPE_IMAGES)); 122 content_settings.IsContentAccessed(CONTENT_SETTINGS_TYPE_IMAGES));
123 ASSERT_FALSE( 123 ASSERT_FALSE(
124 content_settings.IsContentAccessed(CONTENT_SETTINGS_TYPE_COOKIES)); 124 content_settings.IsContentAccessed(CONTENT_SETTINGS_TYPE_COOKIES));
125 ASSERT_FALSE( 125 ASSERT_FALSE(
126 content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES)); 126 content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES));
127 content_settings.OnCookieAccessed( 127 content_settings.OnCookieChanged(
128 GURL("http://google.com"), "A=B", options, false); 128 GURL("http://google.com"), "A=B", options, false);
129 ASSERT_TRUE( 129 ASSERT_TRUE(
130 content_settings.IsContentAccessed(CONTENT_SETTINGS_TYPE_COOKIES)); 130 content_settings.IsContentAccessed(CONTENT_SETTINGS_TYPE_COOKIES));
131 ASSERT_FALSE( 131 ASSERT_FALSE(
132 content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES)); 132 content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES));
133 content_settings.OnCookieAccessed( 133 content_settings.OnCookieChanged(
134 GURL("http://google.com"), "C=D", options, true); 134 GURL("http://google.com"), "C=D", options, true);
135 ASSERT_TRUE( 135 ASSERT_TRUE(
136 content_settings.IsContentAccessed(CONTENT_SETTINGS_TYPE_COOKIES)); 136 content_settings.IsContentAccessed(CONTENT_SETTINGS_TYPE_COOKIES));
137 ASSERT_TRUE( 137 ASSERT_TRUE(
138 content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES)); 138 content_settings.IsContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES));
139 } 139 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698