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

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

Issue 2152823003: Push: Update sender ID missing error messages for applicationServerKey (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Also fix PUSH_REGISTRATION_STATUS_MANIFEST_EMPTY_OR_MISSING Created 4 years, 5 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
« no previous file with comments | « no previous file | content/public/common/push_messaging_status.cc » ('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 <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
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
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
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
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)
OLDNEW
« no previous file with comments | « no previous file | content/public/common/push_messaging_status.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698