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

Side by Side Diff: chrome/browser/push_messaging/push_messaging_browsertest.cc

Issue 1931843002: Ship Web Push subscription restrictions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 GetBrowser()->tab_strip_model()->GetActiveWebContents()); 193 GetBrowser()->tab_strip_model()->GetActiveWebContents());
194 } 194 }
195 195
196 void RequestAndAcceptPermission(); 196 void RequestAndAcceptPermission();
197 void RequestAndDenyPermission(); 197 void RequestAndDenyPermission();
198 198
199 void TryToSubscribeSuccessfully( 199 void TryToSubscribeSuccessfully(
200 const std::string& expected_push_subscription_info, 200 const std::string& expected_push_subscription_info,
201 bool use_key = true); 201 bool use_key = true);
202 202
203 std::string GetEndpointForSubscriptionId(const std::string& subscription_id) { 203 std::string GetEndpointForSubscriptionId(const std::string& subscription_id,
204 return std::string(kPushMessagingEndpoint) + "/" + subscription_id; 204 bool standard_protocol = true) {
205 return push_service()->GetEndpoint(standard_protocol).spec() +
206 subscription_id;
205 } 207 }
206 208
207 PushMessagingAppIdentifier GetAppIdentifierForServiceWorkerRegistration( 209 PushMessagingAppIdentifier GetAppIdentifierForServiceWorkerRegistration(
208 int64_t service_worker_registration_id); 210 int64_t service_worker_registration_id);
209 211
210 void SendMessageAndWaitUntilHandled( 212 void SendMessageAndWaitUntilHandled(
211 const PushMessagingAppIdentifier& app_identifier, 213 const PushMessagingAppIdentifier& app_identifier,
212 const gcm::IncomingMessage& message); 214 const gcm::IncomingMessage& message);
213 215
214 net::EmbeddedTestServer* https_server() const { return https_server_.get(); } 216 net::EmbeddedTestServer* https_server() const { return https_server_.get(); }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 if (use_key) { 295 if (use_key) {
294 ASSERT_TRUE(RunScript("removeManifest()", &script_result)); 296 ASSERT_TRUE(RunScript("removeManifest()", &script_result));
295 ASSERT_EQ("manifest removed", script_result); 297 ASSERT_EQ("manifest removed", script_result);
296 298
297 EXPECT_TRUE(RunScript("documentSubscribePush()", &script_result)); 299 EXPECT_TRUE(RunScript("documentSubscribePush()", &script_result));
298 } else { 300 } else {
299 // Test backwards compatibility with old ID based subscriptions. 301 // Test backwards compatibility with old ID based subscriptions.
300 EXPECT_TRUE(RunScript("documentSubscribePushWithoutKey()", &script_result)); 302 EXPECT_TRUE(RunScript("documentSubscribePushWithoutKey()", &script_result));
301 } 303 }
302 304
303 EXPECT_EQ(GetEndpointForSubscriptionId(expected_push_subscription_info), 305 EXPECT_EQ(
304 script_result); 306 GetEndpointForSubscriptionId(expected_push_subscription_info, use_key),
307 script_result);
305 } 308 }
306 309
307 PushMessagingAppIdentifier 310 PushMessagingAppIdentifier
308 PushMessagingBrowserTest::GetAppIdentifierForServiceWorkerRegistration( 311 PushMessagingBrowserTest::GetAppIdentifierForServiceWorkerRegistration(
309 int64_t service_worker_registration_id) { 312 int64_t service_worker_registration_id) {
310 GURL origin = https_server()->GetURL("/").GetOrigin(); 313 GURL origin = https_server()->GetURL("/").GetOrigin();
311 PushMessagingAppIdentifier app_identifier = 314 PushMessagingAppIdentifier app_identifier =
312 PushMessagingAppIdentifier::FindByServiceWorker( 315 PushMessagingAppIdentifier::FindByServiceWorker(
313 GetBrowser()->profile(), origin, service_worker_registration_id); 316 GetBrowser()->profile(), origin, service_worker_registration_id);
314 EXPECT_FALSE(app_identifier.is_null()); 317 EXPECT_FALSE(app_identifier.is_null());
(...skipping 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1455 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); 1458 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive());
1456 1459
1457 // After dropping the last subscription background mode is still inactive. 1460 // After dropping the last subscription background mode is still inactive.
1458 std::string script_result; 1461 std::string script_result;
1459 gcm_service()->AddExpectedUnregisterResponse(gcm::GCMClient::SUCCESS); 1462 gcm_service()->AddExpectedUnregisterResponse(gcm::GCMClient::SUCCESS);
1460 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); 1463 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result));
1461 EXPECT_EQ("unsubscribe result: true", script_result); 1464 EXPECT_EQ("unsubscribe result: true", script_result);
1462 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); 1465 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive());
1463 } 1466 }
1464 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) 1467 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698