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

Side by Side Diff: chrome/browser/services/gcm/push_messaging_browsertest.cc

Issue 686133003: Reject push registrations when no sender Id has been provided. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 6 years, 1 month 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 | « no previous file | chrome/test/data/push_messaging/test.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <map> 5 #include <map>
6 #include <string> 6 #include <string>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); 161 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result));
162 ASSERT_EQ("ok - service worker registered", script_result); 162 ASSERT_EQ("ok - service worker registered", script_result);
163 163
164 InfoBarResponder cancelling_responder(browser(), false); 164 InfoBarResponder cancelling_responder(browser(), false);
165 165
166 ASSERT_TRUE(RunScript("registerPush()", &script_result)); 166 ASSERT_TRUE(RunScript("registerPush()", &script_result));
167 EXPECT_EQ("AbortError - Registration failed - permission denied", 167 EXPECT_EQ("AbortError - Registration failed - permission denied",
168 script_result); 168 script_result);
169 } 169 }
170 170
171 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, RegisterFailureNoSenderId) {
172 std::string script_result;
173
174 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result));
175 ASSERT_EQ("ok - service worker registered", script_result);
176
177 InfoBarResponder accepting_responder(browser(), true);
178
179 ASSERT_TRUE(RunScript("removeManifest()", &script_result));
180 ASSERT_EQ("manifest removed", script_result);
181
182 ASSERT_TRUE(RunScript("registerPush()", &script_result));
183 EXPECT_EQ("AbortError - Registration failed - no sender id provided",
184 script_result);
185 }
186
171 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PushEventSuccess) { 187 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PushEventSuccess) {
172 std::string script_result; 188 std::string script_result;
173 189
174 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); 190 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result));
175 ASSERT_EQ("ok - service worker registered", script_result); 191 ASSERT_EQ("ok - service worker registered", script_result);
176 192
177 InfoBarResponder accepting_responder(browser(), true); 193 InfoBarResponder accepting_responder(browser(), true);
178 194
179 ASSERT_TRUE(RunScript("registerPush()", &script_result)); 195 ASSERT_TRUE(RunScript("registerPush()", &script_result));
180 EXPECT_EQ(std::string(kPushMessagingEndpoint) + " - 1", script_result); 196 EXPECT_EQ(std::string(kPushMessagingEndpoint) + " - 1", script_result);
(...skipping 13 matching lines...) Expand all
194 GCMClient::IncomingMessage message; 210 GCMClient::IncomingMessage message;
195 GCMClient::MessageData messageData; 211 GCMClient::MessageData messageData;
196 messageData.insert(std::pair<std::string, std::string>("data", "testdata")); 212 messageData.insert(std::pair<std::string, std::string>("data", "testdata"));
197 message.data = messageData; 213 message.data = messageData;
198 push_service()->OnMessage(app_id.ToString(), message); 214 push_service()->OnMessage(app_id.ToString(), message);
199 ASSERT_TRUE(RunScript("pushData.get()", &script_result)); 215 ASSERT_TRUE(RunScript("pushData.get()", &script_result));
200 EXPECT_EQ("testdata", script_result); 216 EXPECT_EQ("testdata", script_result);
201 } 217 }
202 218
203 } // namespace gcm 219 } // namespace gcm
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/push_messaging/test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698