| Index: chrome/browser/push_messaging/push_messaging_browsertest.cc
|
| diff --git a/chrome/browser/push_messaging/push_messaging_browsertest.cc b/chrome/browser/push_messaging/push_messaging_browsertest.cc
|
| index 020c9a0516b8695cc62064f5926b497e41e6f8c0..d4f38f2a6f161cbeacd9b94537734bfa1e10745f 100644
|
| --- a/chrome/browser/push_messaging/push_messaging_browsertest.cc
|
| +++ b/chrome/browser/push_messaging/push_messaging_browsertest.cc
|
| @@ -172,7 +172,8 @@ class PushMessagingBrowserTest : public InProcessBrowserTest {
|
| void RequestAndDenyPermission();
|
|
|
| void TryToSubscribeSuccessfully(
|
| - const std::string& expected_push_subscription_id);
|
| + const std::string& expected_push_subscription_info,
|
| + bool use_key = true);
|
|
|
| std::string GetEndpointForSubscriptionId(const std::string& subscription_id) {
|
| return std::string(kPushMessagingEndpoint) + "/" + subscription_id;
|
| @@ -254,7 +255,8 @@ void PushMessagingBrowserTest::RequestAndDenyPermission() {
|
| }
|
|
|
| void PushMessagingBrowserTest::TryToSubscribeSuccessfully(
|
| - const std::string& expected_push_subscription_id) {
|
| + const std::string& expected_push_subscription_info,
|
| + bool use_key) {
|
| std::string script_result;
|
|
|
| EXPECT_TRUE(RunScript("registerServiceWorker()", &script_result));
|
| @@ -262,8 +264,14 @@ void PushMessagingBrowserTest::TryToSubscribeSuccessfully(
|
|
|
| RequestAndAcceptPermission();
|
|
|
| - EXPECT_TRUE(RunScript("subscribePush()", &script_result));
|
| - EXPECT_EQ(GetEndpointForSubscriptionId(expected_push_subscription_id),
|
| + if (use_key) {
|
| + EXPECT_TRUE(RunScript("subscribePush()", &script_result));
|
| + } else {
|
| + // Test backwards compatibility with old ID based subscriptions.
|
| + EXPECT_TRUE(RunScript("subscribePushWithoutKey()", &script_result));
|
| + }
|
| +
|
| + EXPECT_EQ(GetEndpointForSubscriptionId(expected_push_subscription_info),
|
| script_result);
|
| }
|
|
|
| @@ -288,6 +296,16 @@ void PushMessagingBrowserTest::SendMessageAndWaitUntilHandled(
|
| }
|
|
|
| IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest,
|
| + SubscribeWithoutKeySuccessNotificationsGranted) {
|
| + TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */, false);
|
| +
|
| + PushMessagingAppIdentifier app_identifier =
|
| + GetAppIdentifierForServiceWorkerRegistration(0LL);
|
| + EXPECT_EQ(app_identifier.app_id(), gcm_service()->last_registered_app_id());
|
| + EXPECT_EQ("1234567890", gcm_service()->last_registered_sender_ids()[0]);
|
| +}
|
| +
|
| +IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest,
|
| SubscribeSuccessNotificationsGranted) {
|
| TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */);
|
|
|
|
|