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/extensions/service_worker_apitest.cc

Issue 1851423003: Make Web Push use InstanceID tokens instead of GCM registrations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@iid4default
Patch Set: Rebase (main conflics in browsertest and PMMF) Created 4 years, 7 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/bind_helpers.h" 7 #include "base/bind_helpers.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 736
737 // Start the ServiceWorker. 737 // Start the ServiceWorker.
738 ExtensionTestMessageListener ready_listener("SERVICE_WORKER_READY", false); 738 ExtensionTestMessageListener ready_listener("SERVICE_WORKER_READY", false);
739 ready_listener.set_failure_message("SERVICE_WORKER_FAILURE"); 739 ready_listener.set_failure_message("SERVICE_WORKER_FAILURE");
740 const char* kScript = "window.runServiceWorker()"; 740 const char* kScript = "window.runServiceWorker()";
741 EXPECT_TRUE(content::ExecuteScript(web_contents->GetMainFrame(), kScript)); 741 EXPECT_TRUE(content::ExecuteScript(web_contents->GetMainFrame(), kScript));
742 EXPECT_TRUE(ready_listener.WaitUntilSatisfied()); 742 EXPECT_TRUE(ready_listener.WaitUntilSatisfied());
743 743
744 PushMessagingAppIdentifier app_identifier = 744 PushMessagingAppIdentifier app_identifier =
745 GetAppIdentifierForServiceWorkerRegistration(0LL, extension_url); 745 GetAppIdentifierForServiceWorkerRegistration(0LL, extension_url);
746 ASSERT_EQ(app_identifier.app_id(), gcm_service()->last_registered_app_id());
747 EXPECT_EQ("1234567890", gcm_service()->last_registered_sender_ids()[0]);
748 746
749 base::RunLoop run_loop; 747 base::RunLoop run_loop;
750 // Send a push message via gcm and expect the ServiceWorker to receive it. 748 // Send a push message via gcm and expect the ServiceWorker to receive it.
751 ExtensionTestMessageListener push_message_listener("OK", false); 749 ExtensionTestMessageListener push_message_listener("OK", false);
752 push_message_listener.set_failure_message("FAIL"); 750 push_message_listener.set_failure_message("FAIL");
753 gcm::IncomingMessage message; 751 gcm::IncomingMessage message;
754 message.sender_id = "1234567890"; 752 message.sender_id = "1234567890";
755 message.raw_data = "testdata"; 753 message.raw_data = "testdata";
756 message.decrypted = true; 754 message.decrypted = true;
757 push_service()->SetMessageCallbackForTesting(run_loop.QuitClosure()); 755 push_service()->SetMessageCallbackForTesting(run_loop.QuitClosure());
758 push_service()->OnMessage(app_identifier.app_id(), message); 756 push_service()->OnMessage(app_identifier.app_id(), message);
759 EXPECT_TRUE(push_message_listener.WaitUntilSatisfied()); 757 EXPECT_TRUE(push_message_listener.WaitUntilSatisfied());
760 run_loop.Run(); // Wait until the message is handled by push service. 758 run_loop.Run(); // Wait until the message is handled by push service.
761 } 759 }
762 760
763 } // namespace extensions 761 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698