| 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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 | 429 |
| 430 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 430 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
| 431 ASSERT_EQ("ok - service worker registered", script_result); | 431 ASSERT_EQ("ok - service worker registered", script_result); |
| 432 | 432 |
| 433 RequestAndAcceptPermission(); | 433 RequestAndAcceptPermission(); |
| 434 | 434 |
| 435 ASSERT_TRUE(RunScript("removeManifest()", &script_result)); | 435 ASSERT_TRUE(RunScript("removeManifest()", &script_result)); |
| 436 ASSERT_EQ("manifest removed", script_result); | 436 ASSERT_EQ("manifest removed", script_result); |
| 437 | 437 |
| 438 ASSERT_TRUE(RunScript("documentSubscribePushWithoutKey()", &script_result)); | 438 ASSERT_TRUE(RunScript("documentSubscribePushWithoutKey()", &script_result)); |
| 439 EXPECT_EQ("AbortError - Registration failed - manifest empty or missing", | 439 EXPECT_EQ( |
| 440 script_result); | 440 "AbortError - Registration failed - missing applicationServerKey, and " |
| 441 "manifest empty or missing", |
| 442 script_result); |
| 441 } | 443 } |
| 442 | 444 |
| 443 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, SubscribeFailureNoSenderId) { | 445 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, SubscribeFailureNoSenderId) { |
| 444 std::string script_result; | 446 std::string script_result; |
| 445 | 447 |
| 446 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 448 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
| 447 ASSERT_EQ("ok - service worker registered", script_result); | 449 ASSERT_EQ("ok - service worker registered", script_result); |
| 448 | 450 |
| 449 RequestAndAcceptPermission(); | 451 RequestAndAcceptPermission(); |
| 450 | 452 |
| 451 ASSERT_TRUE(RunScript("swapManifestNoSenderId()", &script_result)); | 453 ASSERT_TRUE(RunScript("swapManifestNoSenderId()", &script_result)); |
| 452 ASSERT_EQ("sender id removed from manifest", script_result); | 454 ASSERT_EQ("sender id removed from manifest", script_result); |
| 453 | 455 |
| 454 ASSERT_TRUE(RunScript("documentSubscribePushWithoutKey()", &script_result)); | 456 ASSERT_TRUE(RunScript("documentSubscribePushWithoutKey()", &script_result)); |
| 455 EXPECT_EQ( | 457 EXPECT_EQ( |
| 456 "AbortError - Registration failed - gcm_sender_id not found in manifest", | 458 "AbortError - Registration failed - missing applicationServerKey, and " |
| 459 "gcm_sender_id not found in manifest", |
| 457 script_result); | 460 script_result); |
| 458 } | 461 } |
| 459 | 462 |
| 460 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTestEmptySubscriptionOptions, | 463 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTestEmptySubscriptionOptions, |
| 461 RegisterFailureEmptyPushSubscriptionOptions) { | 464 RegisterFailureEmptyPushSubscriptionOptions) { |
| 462 std::string script_result; | 465 std::string script_result; |
| 463 | 466 |
| 464 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 467 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
| 465 ASSERT_EQ("ok - service worker registered", script_result); | 468 ASSERT_EQ("ok - service worker registered", script_result); |
| 466 | 469 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 480 RequestAndAcceptPermission(); | 483 RequestAndAcceptPermission(); |
| 481 | 484 |
| 482 LoadTestPage(); // Reload to become controlled. | 485 LoadTestPage(); // Reload to become controlled. |
| 483 | 486 |
| 484 ASSERT_TRUE(RunScript("isControlled()", &script_result)); | 487 ASSERT_TRUE(RunScript("isControlled()", &script_result)); |
| 485 ASSERT_EQ("true - is controlled", script_result); | 488 ASSERT_EQ("true - is controlled", script_result); |
| 486 | 489 |
| 487 // Try to subscribe from a worker without a key. This should fail. | 490 // Try to subscribe from a worker without a key. This should fail. |
| 488 ASSERT_TRUE(RunScript("workerSubscribePushNoKey()", &script_result)); | 491 ASSERT_TRUE(RunScript("workerSubscribePushNoKey()", &script_result)); |
| 489 EXPECT_EQ( | 492 EXPECT_EQ( |
| 490 "AbortError - Registration failed - gcm_sender_id not found in manifest", | 493 "AbortError - Registration failed - missing applicationServerKey, and " |
| 494 "gcm_sender_id not found in manifest", |
| 491 script_result); | 495 script_result); |
| 492 // Now run the subscribe from the service worker with a key. This | 496 // Now run the subscribe from the service worker with a key. This |
| 493 // should succeed, and write the key to the datastore. | 497 // should succeed, and write the key to the datastore. |
| 494 ASSERT_TRUE(RunScript("workerSubscribePush()", &script_result)); | 498 ASSERT_TRUE(RunScript("workerSubscribePush()", &script_result)); |
| 495 EXPECT_EQ(GetEndpointForSubscriptionId("1-0"), script_result); | 499 EXPECT_EQ(GetEndpointForSubscriptionId("1-0"), script_result); |
| 496 | 500 |
| 497 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 501 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
| 498 EXPECT_EQ("unsubscribe result: true", script_result); | 502 EXPECT_EQ("unsubscribe result: true", script_result); |
| 499 EXPECT_NE(push_service(), GetAppHandler()); | 503 EXPECT_NE(push_service(), GetAppHandler()); |
| 500 | 504 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 517 RequestAndAcceptPermission(); | 521 RequestAndAcceptPermission(); |
| 518 | 522 |
| 519 LoadTestPage(); // Reload to become controlled. | 523 LoadTestPage(); // Reload to become controlled. |
| 520 | 524 |
| 521 ASSERT_TRUE(RunScript("isControlled()", &script_result)); | 525 ASSERT_TRUE(RunScript("isControlled()", &script_result)); |
| 522 ASSERT_EQ("true - is controlled", script_result); | 526 ASSERT_EQ("true - is controlled", script_result); |
| 523 | 527 |
| 524 // Try to subscribe from a worker without a key. This should fail. | 528 // Try to subscribe from a worker without a key. This should fail. |
| 525 ASSERT_TRUE(RunScript("workerSubscribePushNoKey()", &script_result)); | 529 ASSERT_TRUE(RunScript("workerSubscribePushNoKey()", &script_result)); |
| 526 EXPECT_EQ( | 530 EXPECT_EQ( |
| 527 "AbortError - Registration failed - gcm_sender_id not found in manifest", | 531 "AbortError - Registration failed - missing applicationServerKey, and " |
| 532 "gcm_sender_id not found in manifest", |
| 528 script_result); | 533 script_result); |
| 529 EXPECT_NE(push_service(), GetAppHandler()); | 534 EXPECT_NE(push_service(), GetAppHandler()); |
| 530 | 535 |
| 531 // Run the subscription from the document without a key, this will trigger | 536 // Run the subscription from the document without a key, this will trigger |
| 532 // the code to read sender id from the manifest and will write it to the | 537 // the code to read sender id from the manifest and will write it to the |
| 533 // datastore. | 538 // datastore. |
| 534 ASSERT_TRUE(RunScript("documentSubscribePushWithoutKey()", &script_result)); | 539 ASSERT_TRUE(RunScript("documentSubscribePushWithoutKey()", &script_result)); |
| 535 EXPECT_EQ(GetEndpointForSubscriptionId("1-0", false), script_result); | 540 EXPECT_EQ(GetEndpointForSubscriptionId("1-0", false), script_result); |
| 536 | 541 |
| 537 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 542 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
| (...skipping 1053 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1591 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 1596 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
| 1592 | 1597 |
| 1593 // After dropping the last subscription background mode is still inactive. | 1598 // After dropping the last subscription background mode is still inactive. |
| 1594 std::string script_result; | 1599 std::string script_result; |
| 1595 gcm_service()->AddExpectedUnregisterResponse(gcm::GCMClient::SUCCESS); | 1600 gcm_service()->AddExpectedUnregisterResponse(gcm::GCMClient::SUCCESS); |
| 1596 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 1601 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
| 1597 EXPECT_EQ("unsubscribe result: true", script_result); | 1602 EXPECT_EQ("unsubscribe result: true", script_result); |
| 1598 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 1603 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
| 1599 } | 1604 } |
| 1600 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) | 1605 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) |
| OLD | NEW |