| OLD | NEW |
| 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 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 | 477 |
| 478 gcm::IncomingMessage message; | 478 gcm::IncomingMessage message; |
| 479 message.sender_id = "1234567890"; | 479 message.sender_id = "1234567890"; |
| 480 message.raw_data = "testdata"; | 480 message.raw_data = "testdata"; |
| 481 message.decrypted = true; | 481 message.decrypted = true; |
| 482 push_service()->OnMessage(app_identifier.app_id(), message); | 482 push_service()->OnMessage(app_identifier.app_id(), message); |
| 483 ASSERT_TRUE(RunScript("resultQueue.pop()", &script_result)); | 483 ASSERT_TRUE(RunScript("resultQueue.pop()", &script_result)); |
| 484 EXPECT_EQ("testdata", script_result); | 484 EXPECT_EQ("testdata", script_result); |
| 485 } | 485 } |
| 486 | 486 |
| 487 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PushEventWithoutPayload) { |
| 488 std::string script_result; |
| 489 |
| 490 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); |
| 491 |
| 492 PushMessagingAppIdentifier app_identifier = |
| 493 GetAppIdentifierForServiceWorkerRegistration(0LL); |
| 494 EXPECT_EQ(app_identifier.app_id(), gcm_service()->last_registered_app_id()); |
| 495 EXPECT_EQ("1234567890", gcm_service()->last_registered_sender_ids()[0]); |
| 496 |
| 497 ASSERT_TRUE(RunScript("isControlled()", &script_result)); |
| 498 ASSERT_EQ("false - is not controlled", script_result); |
| 499 |
| 500 LoadTestPage(); // Reload to become controlled. |
| 501 |
| 502 ASSERT_TRUE(RunScript("isControlled()", &script_result)); |
| 503 ASSERT_EQ("true - is controlled", script_result); |
| 504 |
| 505 gcm::IncomingMessage message; |
| 506 message.sender_id = "1234567890"; |
| 507 message.decrypted = false; |
| 508 |
| 509 push_service()->OnMessage(app_identifier.app_id(), message); |
| 510 ASSERT_TRUE(RunScript("resultQueue.pop()", &script_result)); |
| 511 EXPECT_EQ("[NULL]", script_result); |
| 512 } |
| 513 |
| 487 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PushEventNoServiceWorker) { | 514 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PushEventNoServiceWorker) { |
| 488 std::string script_result; | 515 std::string script_result; |
| 489 | 516 |
| 490 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); | 517 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); |
| 491 | 518 |
| 492 PushMessagingAppIdentifier app_identifier = | 519 PushMessagingAppIdentifier app_identifier = |
| 493 GetAppIdentifierForServiceWorkerRegistration(0LL); | 520 GetAppIdentifierForServiceWorkerRegistration(0LL); |
| 494 EXPECT_EQ(app_identifier.app_id(), gcm_service()->last_registered_app_id()); | 521 EXPECT_EQ(app_identifier.app_id(), gcm_service()->last_registered_app_id()); |
| 495 EXPECT_EQ("1234567890", gcm_service()->last_registered_sender_ids()[0]); | 522 EXPECT_EQ("1234567890", gcm_service()->last_registered_sender_ids()[0]); |
| 496 | 523 |
| (...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1275 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 1302 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
| 1276 | 1303 |
| 1277 // After dropping the last subscription background mode is still inactive. | 1304 // After dropping the last subscription background mode is still inactive. |
| 1278 std::string script_result; | 1305 std::string script_result; |
| 1279 gcm_service()->AddExpectedUnregisterResponse(gcm::GCMClient::SUCCESS); | 1306 gcm_service()->AddExpectedUnregisterResponse(gcm::GCMClient::SUCCESS); |
| 1280 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 1307 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
| 1281 EXPECT_EQ("unsubscribe result: true", script_result); | 1308 EXPECT_EQ("unsubscribe result: true", script_result); |
| 1282 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 1309 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
| 1283 } | 1310 } |
| 1284 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) | 1311 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) |
| OLD | NEW |