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

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

Issue 2460223004: Fix potential bug in push_test.js - do not cache subscription options (Closed)
Patch Set: rebase Created 4 years, 1 month 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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 PushMessagingServiceImpl* push_service_; 282 PushMessagingServiceImpl* push_service_;
283 283
284 #if defined(ENABLE_NOTIFICATIONS) 284 #if defined(ENABLE_NOTIFICATIONS)
285 std::unique_ptr<StubNotificationUIManager> notification_manager_; 285 std::unique_ptr<StubNotificationUIManager> notification_manager_;
286 std::unique_ptr<MessageCenterDisplayService> display_service_; 286 std::unique_ptr<MessageCenterDisplayService> display_service_;
287 #endif 287 #endif
288 288
289 DISALLOW_COPY_AND_ASSIGN(PushMessagingBrowserTest); 289 DISALLOW_COPY_AND_ASSIGN(PushMessagingBrowserTest);
290 }; 290 };
291 291
292 class PushMessagingBrowserTestEmptySubscriptionOptions
293 : public PushMessagingBrowserTest {
294 std::string GetTestURL() override {
295 return "/push_messaging/test_no_subscription_options.html";
296 }
297 };
298
299 void PushMessagingBrowserTest::RequestAndAcceptPermission() { 292 void PushMessagingBrowserTest::RequestAndAcceptPermission() {
300 std::string script_result; 293 std::string script_result;
301 GetPermissionRequestManager()->set_auto_response_for_test( 294 GetPermissionRequestManager()->set_auto_response_for_test(
302 PermissionRequestManager::ACCEPT_ALL); 295 PermissionRequestManager::ACCEPT_ALL);
303 ASSERT_TRUE(RunScript("requestNotificationPermission();", &script_result)); 296 ASSERT_TRUE(RunScript("requestNotificationPermission();", &script_result));
304 ASSERT_EQ("permission status - granted", script_result); 297 ASSERT_EQ("permission status - granted", script_result);
305 } 298 }
306 299
307 void PushMessagingBrowserTest::RequestAndDenyPermission() { 300 void PushMessagingBrowserTest::RequestAndDenyPermission() {
308 std::string script_result; 301 std::string script_result;
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 ASSERT_TRUE(RunScript("swapManifestNoSenderId()", &script_result)); 483 ASSERT_TRUE(RunScript("swapManifestNoSenderId()", &script_result));
491 ASSERT_EQ("sender id removed from manifest", script_result); 484 ASSERT_EQ("sender id removed from manifest", script_result);
492 485
493 ASSERT_TRUE(RunScript("documentSubscribePushWithoutKey()", &script_result)); 486 ASSERT_TRUE(RunScript("documentSubscribePushWithoutKey()", &script_result));
494 EXPECT_EQ( 487 EXPECT_EQ(
495 "AbortError - Registration failed - missing applicationServerKey, and " 488 "AbortError - Registration failed - missing applicationServerKey, and "
496 "gcm_sender_id not found in manifest", 489 "gcm_sender_id not found in manifest",
497 script_result); 490 script_result);
498 } 491 }
499 492
500 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTestEmptySubscriptionOptions, 493 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest,
501 RegisterFailureEmptyPushSubscriptionOptions) { 494 RegisterFailureEmptyPushSubscriptionOptions) {
502 std::string script_result; 495 std::string script_result;
503 496
504 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); 497 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result));
505 ASSERT_EQ("ok - service worker registered", script_result); 498 ASSERT_EQ("ok - service worker registered", script_result);
506 499
507 ASSERT_NO_FATAL_FAILURE(RequestAndAcceptPermission()); 500 ASSERT_NO_FATAL_FAILURE(RequestAndAcceptPermission());
508 501
509 ASSERT_TRUE(RunScript("documentSubscribePush()", &script_result)); 502 ASSERT_TRUE(
503 RunScript("documentSubscribePushWithEmptyOptions()", &script_result));
510 EXPECT_EQ("NotAllowedError - Registration failed - permission denied", 504 EXPECT_EQ("NotAllowedError - Registration failed - permission denied",
511 script_result); 505 script_result);
512 } 506 }
513 507
514 // Flaky on ChromeOS and Linux. See http://crbug.com/657202. 508 // Flaky on ChromeOS and Linux. See http://crbug.com/657202.
515 #if defined(OS_CHROMEOS) || defined(OS_LINUX) 509 #if defined(OS_CHROMEOS) || defined(OS_LINUX)
516 #define MAYBE_SubscribeWorker DISABLED_SubscribeWorker 510 #define MAYBE_SubscribeWorker DISABLED_SubscribeWorker
517 #else 511 #else
518 #define MAYBE_SubscribeWorker SubscribeWorker 512 #define MAYBE_SubscribeWorker SubscribeWorker
519 #endif 513 #endif
(...skipping 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after
1882 ASSERT_NO_FATAL_FAILURE(SubscribeSuccessfully()); 1876 ASSERT_NO_FATAL_FAILURE(SubscribeSuccessfully());
1883 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); 1877 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive());
1884 1878
1885 // After dropping the last subscription background mode is still inactive. 1879 // After dropping the last subscription background mode is still inactive.
1886 std::string script_result; 1880 std::string script_result;
1887 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); 1881 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result));
1888 EXPECT_EQ("unsubscribe result: true", script_result); 1882 EXPECT_EQ("unsubscribe result: true", script_result);
1889 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); 1883 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive());
1890 } 1884 }
1891 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) 1885 #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