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

Side by Side Diff: chrome/browser/ui/webui/settings/site_settings_handler_unittest.cc

Issue 1882793002: Site Settings: Use only string values for permissions on the JS side. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback Created 4 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/webui/settings/site_settings_handler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/ui/webui/settings/site_settings_handler.h" 5 #include "chrome/browser/ui/webui/settings/site_settings_handler.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "chrome/browser/ui/webui/site_settings_helper.h" 9 #include "chrome/browser/ui/webui/site_settings_helper.h"
10 #include "chrome/test/base/testing_profile.h" 10 #include "chrome/test/base/testing_profile.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // Test the JS -> C++ -> JS callback path for getting and setting defaults. 118 // Test the JS -> C++ -> JS callback path for getting and setting defaults.
119 base::ListValue getArgs; 119 base::ListValue getArgs;
120 getArgs.Append(new base::StringValue(kCallbackId)); 120 getArgs.Append(new base::StringValue(kCallbackId));
121 getArgs.Append(new base::FundamentalValue(type)); 121 getArgs.Append(new base::FundamentalValue(type));
122 handler.HandleGetDefaultValueForContentType(&getArgs); 122 handler.HandleGetDefaultValueForContentType(&getArgs);
123 ValidateDefault(true, 1U); 123 ValidateDefault(true, 1U);
124 124
125 // Set the default to 'Blocked'. 125 // Set the default to 'Blocked'.
126 base::ListValue setArgs; 126 base::ListValue setArgs;
127 setArgs.Append(new base::FundamentalValue(type)); 127 setArgs.Append(new base::FundamentalValue(type));
128 setArgs.Append(new base::FundamentalValue(CONTENT_SETTING_BLOCK)); 128 setArgs.Append(new base::StringValue("block"));
129 handler.HandleSetDefaultValueForContentType(&setArgs); 129 handler.HandleSetDefaultValueForContentType(&setArgs);
130 130
131 EXPECT_EQ(2U, web_ui()->call_data().size()); 131 EXPECT_EQ(2U, web_ui()->call_data().size());
132 132
133 // Verify that the default has been set to 'Blocked'. 133 // Verify that the default has been set to 'Blocked'.
134 handler.HandleGetDefaultValueForContentType(&getArgs); 134 handler.HandleGetDefaultValueForContentType(&getArgs);
135 ValidateDefault(false, 3U); 135 ValidateDefault(false, 3U);
136 } 136 }
137 137
138 TEST_F(SiteSettingsHandlerTest, Origins) { 138 TEST_F(SiteSettingsHandlerTest, Origins) {
139 SiteSettingsHandler handler(profile()); 139 SiteSettingsHandler handler(profile());
140 handler.set_web_ui(web_ui()); 140 handler.set_web_ui(web_ui());
141 141
142 ContentSettingsType type = CONTENT_SETTINGS_TYPE_NOTIFICATIONS; 142 ContentSettingsType type = CONTENT_SETTINGS_TYPE_NOTIFICATIONS;
143 143
144 // Test the JS -> C++ -> JS callback path for configuring origins, by setting 144 // Test the JS -> C++ -> JS callback path for configuring origins, by setting
145 // Google.com to blocked. 145 // Google.com to blocked.
146 base::ListValue setArgs; 146 base::ListValue setArgs;
147 std::string google("http://www.google.com"); 147 std::string google("http://www.google.com");
148 setArgs.Append(new base::StringValue(google)); // Primary pattern. 148 setArgs.Append(new base::StringValue(google)); // Primary pattern.
149 setArgs.Append(new base::StringValue(google)); // Secondary pattern. 149 setArgs.Append(new base::StringValue(google)); // Secondary pattern.
150 setArgs.Append(new base::FundamentalValue(type)); 150 setArgs.Append(new base::FundamentalValue(type));
151 setArgs.Append(new base::FundamentalValue(CONTENT_SETTING_BLOCK)); 151 setArgs.Append(new base::StringValue("block"));
152 handler.HandleSetCategoryPermissionForOrigin(&setArgs); 152 handler.HandleSetCategoryPermissionForOrigin(&setArgs);
153 EXPECT_EQ(1U, web_ui()->call_data().size()); 153 EXPECT_EQ(1U, web_ui()->call_data().size());
154 154
155 // Verify the change was successful. 155 // Verify the change was successful.
156 base::ListValue listArgs; 156 base::ListValue listArgs;
157 listArgs.Append(new base::StringValue(kCallbackId)); 157 listArgs.Append(new base::StringValue(kCallbackId));
158 listArgs.Append(new base::FundamentalValue(type)); 158 listArgs.Append(new base::FundamentalValue(type));
159 handler.HandleGetExceptionList(&listArgs); 159 handler.HandleGetExceptionList(&listArgs);
160 ValidateOrigin(google, google, "block", "preference", 2U); 160 ValidateOrigin(google, google, "block", "preference", 2U);
161 161
162 // Reset things back to how they were. 162 // Reset things back to how they were.
163 base::ListValue resetArgs; 163 base::ListValue resetArgs;
164 resetArgs.Append(new base::StringValue(google)); 164 resetArgs.Append(new base::StringValue(google));
165 resetArgs.Append(new base::StringValue(google)); 165 resetArgs.Append(new base::StringValue(google));
166 resetArgs.Append(new base::FundamentalValue(type)); 166 resetArgs.Append(new base::FundamentalValue(type));
167 handler.HandleResetCategoryPermissionForOrigin(&resetArgs); 167 handler.HandleResetCategoryPermissionForOrigin(&resetArgs);
168 EXPECT_EQ(3U, web_ui()->call_data().size()); 168 EXPECT_EQ(3U, web_ui()->call_data().size());
169 169
170 // Verify the reset was successful. 170 // Verify the reset was successful.
171 handler.HandleGetExceptionList(&listArgs); 171 handler.HandleGetExceptionList(&listArgs);
172 ValidateNoOrigin(4U); 172 ValidateNoOrigin(4U);
173 } 173 }
174 174
175 } // namespace settings 175 } // namespace settings
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/settings/site_settings_handler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698