Index: chrome/browser/push_messaging/push_messaging_browsertest.cc |
diff --git a/chrome/browser/push_messaging/push_messaging_browsertest.cc b/chrome/browser/push_messaging/push_messaging_browsertest.cc |
index 7ab3987d556d7a96e05afef681ed81488e4d0f44..dc03247f5ef7b64a60ba1c12bbcdbc59f305c19b 100644 |
--- a/chrome/browser/push_messaging/push_messaging_browsertest.cc |
+++ b/chrome/browser/push_messaging/push_messaging_browsertest.cc |
@@ -6,6 +6,7 @@ |
#include <string> |
#include "base/bind.h" |
+#include "base/bind_helpers.h" |
#include "base/command_line.h" |
#include "base/message_loop/message_loop.h" |
#include "base/strings/utf_string_conversions.h" |
@@ -240,6 +241,8 @@ class PushMessagingBrowserTest : public InProcessBrowserTest { |
PushMessagingApplicationId GetServiceWorkerAppId( |
int64 service_worker_registration_id); |
+ void WaitForGetUserDataRoundTrip(int64 service_worker_registration_id); |
+ |
net::SpawnedTestServer* https_server() const { return https_server_.get(); } |
gcm::FakeGCMProfileService* gcm_service() const { return gcm_service_; } |
@@ -315,6 +318,22 @@ PushMessagingApplicationId PushMessagingBrowserTest::GetServiceWorkerAppId( |
return application_id; |
} |
+static void WaitForGetUserDataRoundTripCallback( |
+ const std::string& data, bool success, bool not_found) { |
+ base::MessageLoop::current()->Quit(); |
+} |
+ |
+void PushMessagingBrowserTest::WaitForGetUserDataRoundTrip( |
+ int64 service_worker_registration_id) { |
+ PushMessagingApplicationId app_id = |
+ GetServiceWorkerAppId(service_worker_registration_id); |
+ push_service()->GetSenderId( |
+ browser()->profile(), |
+ app_id.origin(), app_id.service_worker_registration_id(), |
+ base::Bind(&WaitForGetUserDataRoundTripCallback)); |
+ content::RunMessageLoop(); |
+} |
+ |
IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
RegisterSuccessNotificationsGranted) { |
if (!IsPushSupported()) |
@@ -786,6 +805,9 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
browser()->profile()->GetHostContentSettingsMap()-> |
ClearSettingsForOneType(CONTENT_SETTINGS_TYPE_PUSH_MESSAGING); |
+ WaitForGetUserDataRoundTrip(0LL); |
+ WaitForGetUserDataRoundTrip(0LL); |
+ |
ASSERT_TRUE(RunScript("hasPermission()", &script_result)); |
EXPECT_EQ("permission status - default", script_result); |
@@ -813,6 +835,9 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
std::string(), |
CONTENT_SETTING_DEFAULT); |
+ WaitForGetUserDataRoundTrip(0LL); |
+ WaitForGetUserDataRoundTrip(0LL); |
+ |
ASSERT_TRUE(RunScript("hasPermission()", &script_result)); |
EXPECT_EQ("permission status - default", script_result); |
@@ -840,6 +865,9 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
std::string(), |
CONTENT_SETTING_BLOCK); |
+ WaitForGetUserDataRoundTrip(0LL); |
+ WaitForGetUserDataRoundTrip(0LL); |
+ |
ASSERT_TRUE(RunScript("hasPermission()", &script_result)); |
EXPECT_EQ("permission status - denied", script_result); |
@@ -862,6 +890,9 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
browser()->profile()->GetHostContentSettingsMap()-> |
ClearSettingsForOneType(CONTENT_SETTINGS_TYPE_NOTIFICATIONS); |
+ WaitForGetUserDataRoundTrip(0LL); |
+ WaitForGetUserDataRoundTrip(0LL); |
+ |
ASSERT_TRUE(RunScript("hasPermission()", &script_result)); |
EXPECT_EQ("permission status - default", script_result); |
@@ -889,6 +920,9 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
std::string(), |
CONTENT_SETTING_DEFAULT); |
+ WaitForGetUserDataRoundTrip(0LL); |
+ WaitForGetUserDataRoundTrip(0LL); |
+ |
ASSERT_TRUE(RunScript("hasPermission()", &script_result)); |
EXPECT_EQ("permission status - default", script_result); |
@@ -916,6 +950,9 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
std::string(), |
CONTENT_SETTING_BLOCK); |
+ WaitForGetUserDataRoundTrip(0LL); |
+ WaitForGetUserDataRoundTrip(0LL); |
+ |
ASSERT_TRUE(RunScript("hasPermission()", &script_result)); |
EXPECT_EQ("permission status - denied", script_result); |
@@ -949,6 +986,9 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
std::string(), |
CONTENT_SETTING_ALLOW); |
+ WaitForGetUserDataRoundTrip(0LL); |
+ WaitForGetUserDataRoundTrip(0LL); |
+ |
ASSERT_TRUE(RunScript("hasPermission()", &script_result)); |
EXPECT_EQ("permission status - granted", script_result); |
@@ -1003,6 +1043,9 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
// The Push service should not unsubcribe |origin| because at no point it was |
// left without permission to use Push. |
+ WaitForGetUserDataRoundTrip(0LL); |
+ WaitForGetUserDataRoundTrip(0LL); |
+ |
ASSERT_TRUE(RunScript("hasPermission()", &script_result)); |
EXPECT_EQ("permission status - granted", script_result); |