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

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

Issue 2411733002: Check the format of an applicationServerKey when used to register a push subscription. (Closed)
Patch Set: More formatting Created 4 years, 2 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 | chrome/test/data/push_messaging/push_test.js » ('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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 ASSERT_EQ("ok - service worker registered", script_result); 440 ASSERT_EQ("ok - service worker registered", script_result);
441 441
442 GetPermissionRequestManager()->set_auto_response_for_test( 442 GetPermissionRequestManager()->set_auto_response_for_test(
443 PermissionRequestManager::ACCEPT_ALL); 443 PermissionRequestManager::ACCEPT_ALL);
444 ASSERT_TRUE(RunScript("documentSubscribePush()", &script_result)); 444 ASSERT_TRUE(RunScript("documentSubscribePush()", &script_result));
445 // Both of these methods EXPECT that they succeed. 445 // Both of these methods EXPECT that they succeed.
446 ASSERT_NO_FATAL_FAILURE(EndpointToToken(script_result)); 446 ASSERT_NO_FATAL_FAILURE(EndpointToToken(script_result));
447 GetAppIdentifierForServiceWorkerRegistration(0LL); 447 GetAppIdentifierForServiceWorkerRegistration(0LL);
448 } 448 }
449 449
450 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, SubscribeFailureBadKey) {
451 std::string script_result;
452
453 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result));
454 ASSERT_EQ("ok - service worker registered", script_result);
455
456 ASSERT_NO_FATAL_FAILURE(RequestAndAcceptPermission());
457
458 ASSERT_TRUE(RunScript("documentSubscribePushBadKey()", &script_result));
459 EXPECT_EQ(
460 "InvalidAccessError - Failed to execute 'subscribe' on 'PushManager': "
461 "The provided applicationServerKey is not valid.",
462 script_result);
463 }
464
465 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, 450 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest,
466 SubscribeFailureNotificationsBlocked) { 451 SubscribeFailureNotificationsBlocked) {
467 std::string script_result; 452 std::string script_result;
468 453
469 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); 454 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result));
470 ASSERT_EQ("ok - service worker registered", script_result); 455 ASSERT_EQ("ok - service worker registered", script_result);
471 456
472 ASSERT_NO_FATAL_FAILURE(RequestAndDenyPermission()); 457 ASSERT_NO_FATAL_FAILURE(RequestAndDenyPermission());
473 458
474 ASSERT_TRUE(RunScript("documentSubscribePush()", &script_result)); 459 ASSERT_TRUE(RunScript("documentSubscribePush()", &script_result));
(...skipping 1409 matching lines...) Expand 10 before | Expand all | Expand 10 after
1884 ASSERT_NO_FATAL_FAILURE(SubscribeSuccessfully()); 1869 ASSERT_NO_FATAL_FAILURE(SubscribeSuccessfully());
1885 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); 1870 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive());
1886 1871
1887 // After dropping the last subscription background mode is still inactive. 1872 // After dropping the last subscription background mode is still inactive.
1888 std::string script_result; 1873 std::string script_result;
1889 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); 1874 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result));
1890 EXPECT_EQ("unsubscribe result: true", script_result); 1875 EXPECT_EQ("unsubscribe result: true", script_result);
1891 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); 1876 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive());
1892 } 1877 }
1893 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) 1878 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS)
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/push_messaging/push_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698