OLD | NEW |
---|---|
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 30 matching lines...) Expand all Loading... | |
41 #include "components/content_settings/core/browser/host_content_settings_map.h" | 41 #include "components/content_settings/core/browser/host_content_settings_map.h" |
42 #include "components/content_settings/core/common/content_settings.h" | 42 #include "components/content_settings/core/common/content_settings.h" |
43 #include "components/content_settings/core/common/content_settings_types.h" | 43 #include "components/content_settings/core/common/content_settings_types.h" |
44 #include "components/gcm_driver/common/gcm_messages.h" | 44 #include "components/gcm_driver/common/gcm_messages.h" |
45 #include "components/gcm_driver/gcm_client.h" | 45 #include "components/gcm_driver/gcm_client.h" |
46 #include "content/public/browser/web_contents.h" | 46 #include "content/public/browser/web_contents.h" |
47 #include "content/public/common/content_switches.h" | 47 #include "content/public/common/content_switches.h" |
48 #include "content/public/test/browser_test_utils.h" | 48 #include "content/public/test/browser_test_utils.h" |
49 #include "content/public/test/test_utils.h" | 49 #include "content/public/test/test_utils.h" |
50 #include "net/test/embedded_test_server/embedded_test_server.h" | 50 #include "net/test/embedded_test_server/embedded_test_server.h" |
51 #include "testing/gmock/include/gmock/gmock.h" | |
51 #include "ui/base/window_open_disposition.h" | 52 #include "ui/base/window_open_disposition.h" |
52 | 53 |
53 #if BUILDFLAG(ENABLE_BACKGROUND) | 54 #if BUILDFLAG(ENABLE_BACKGROUND) |
54 #include "chrome/browser/background/background_mode_manager.h" | 55 #include "chrome/browser/background/background_mode_manager.h" |
55 #endif | 56 #endif |
56 | 57 |
57 namespace { | 58 namespace { |
58 | 59 |
59 // NIST P-256 public key made available to tests. Must be an uncompressed | 60 // NIST P-256 public key made available to tests. Must be an uncompressed |
60 // point in accordance with SEC1 2.3.3. | 61 // point in accordance with SEC1 2.3.3. |
61 // Note: Although the key itself is only 65 bytes, we pad it with a 0x00 to | 62 // Note: Although the key itself is only 65 bytes, we pad it with a 0x00 to |
62 // make dcheck happy when it compares input and output as strings. | 63 // make dcheck happy when it compares input and output as strings. |
63 const uint8_t kApplicationServerKey[66] = { | 64 const uint8_t kApplicationServerKey[66] = { |
64 0x04, 0x55, 0x52, 0x6A, 0xA5, 0x6E, 0x8E, 0xAA, 0x47, 0x97, 0x36, | 65 0x04, 0x55, 0x52, 0x6A, 0xA5, 0x6E, 0x8E, 0xAA, 0x47, 0x97, 0x36, |
65 0x10, 0xC1, 0x66, 0x3C, 0x1E, 0x65, 0xBF, 0xA1, 0x7B, 0xEE, 0x48, | 66 0x10, 0xC1, 0x66, 0x3C, 0x1E, 0x65, 0xBF, 0xA1, 0x7B, 0xEE, 0x48, |
66 0xC9, 0xC6, 0xBB, 0xBF, 0x02, 0x18, 0x53, 0x72, 0x1D, 0x0C, 0x7B, | 67 0xC9, 0xC6, 0xBB, 0xBF, 0x02, 0x18, 0x53, 0x72, 0x1D, 0x0C, 0x7B, |
67 0xA9, 0xE3, 0x11, 0xB7, 0x03, 0x52, 0x21, 0xD3, 0x71, 0x90, 0x13, | 68 0xA9, 0xE3, 0x11, 0xB7, 0x03, 0x52, 0x21, 0xD3, 0x71, 0x90, 0x13, |
68 0xA8, 0xC1, 0xCF, 0xED, 0x20, 0xF7, 0x1F, 0xD1, 0x7F, 0xF2, 0x76, | 69 0xA8, 0xC1, 0xCF, 0xED, 0x20, 0xF7, 0x1F, 0xD1, 0x7F, 0xF2, 0x76, |
69 0xB6, 0x01, 0x20, 0xD8, 0x35, 0xA5, 0xD9, 0x3C, 0x43, 0xFD, 0x00}; | 70 0xB6, 0x01, 0x20, 0xD8, 0x35, 0xA5, 0xD9, 0x3C, 0x43, 0xFD, 0x00}; |
70 | 71 |
71 const char* getTestApplicationServerKey() { | 72 const char* getTestApplicationServerKey() { |
72 return reinterpret_cast<const char*>(kApplicationServerKey); | 73 return reinterpret_cast<const char*>(kApplicationServerKey); |
73 } | 74 } |
74 | 75 |
75 // Class to instantiate on the stack that is meant to be used with | |
76 // FakeGCMProfileService. The ::Run() method follows the signature of | |
77 // FakeGCMProfileService::UnregisterCallback. | |
78 class UnregistrationCallback { | |
79 public: | |
80 UnregistrationCallback() | |
81 : message_loop_runner_(new content::MessageLoopRunner) {} | |
82 | |
83 void Run(const std::string& app_id) { | |
84 app_id_ = app_id; | |
85 message_loop_runner_->Quit(); | |
86 } | |
87 | |
88 void WaitUntilSatisfied() { message_loop_runner_->Run(); } | |
89 | |
90 const std::string& app_id() { return app_id_; } | |
91 | |
92 private: | |
93 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; | |
94 std::string app_id_; | |
95 }; | |
96 | |
97 } // namespace | 76 } // namespace |
98 | 77 |
99 class PushMessagingBrowserTest : public InProcessBrowserTest { | 78 class PushMessagingBrowserTest : public InProcessBrowserTest { |
100 public: | 79 public: |
101 PushMessagingBrowserTest() : gcm_service_(nullptr) {} | 80 PushMessagingBrowserTest() : gcm_driver_(nullptr) {} |
102 ~PushMessagingBrowserTest() override {} | 81 ~PushMessagingBrowserTest() override {} |
103 | 82 |
104 // InProcessBrowserTest: | 83 // InProcessBrowserTest: |
105 void SetUp() override { | 84 void SetUp() override { |
106 https_server_.reset( | 85 https_server_.reset( |
107 new net::EmbeddedTestServer(net::EmbeddedTestServer::TYPE_HTTPS)); | 86 new net::EmbeddedTestServer(net::EmbeddedTestServer::TYPE_HTTPS)); |
108 https_server_->ServeFilesFromSourceDirectory("chrome/test/data"); | 87 https_server_->ServeFilesFromSourceDirectory("chrome/test/data"); |
109 ASSERT_TRUE(https_server_->Start()); | 88 ASSERT_TRUE(https_server_->Start()); |
110 | 89 |
111 #if defined(ENABLE_NOTIFICATIONS) | 90 #if defined(ENABLE_NOTIFICATIONS) |
112 notification_manager_.reset(new StubNotificationUIManager); | 91 notification_manager_.reset(new StubNotificationUIManager); |
113 notification_service()->SetNotificationUIManagerForTesting( | 92 notification_service()->SetNotificationUIManagerForTesting( |
114 notification_manager()); | 93 notification_manager()); |
115 #endif | 94 #endif |
116 | 95 |
117 InProcessBrowserTest::SetUp(); | 96 InProcessBrowserTest::SetUp(); |
118 } | 97 } |
119 | 98 |
120 void SetUpCommandLine(base::CommandLine* command_line) override { | 99 void SetUpCommandLine(base::CommandLine* command_line) override { |
121 // Enable experimental features for subscription restrictions. | 100 // Enable experimental features for subscription restrictions. |
122 command_line->AppendSwitch( | 101 command_line->AppendSwitch( |
123 switches::kEnableExperimentalWebPlatformFeatures); | 102 switches::kEnableExperimentalWebPlatformFeatures); |
124 InProcessBrowserTest::SetUpCommandLine(command_line); | 103 InProcessBrowserTest::SetUpCommandLine(command_line); |
125 } | 104 } |
126 | 105 |
127 // InProcessBrowserTest: | 106 // InProcessBrowserTest: |
128 void SetUpOnMainThread() override { | 107 void SetUpOnMainThread() override { |
129 gcm_service_ = static_cast<gcm::FakeGCMProfileService*>( | 108 gcm::GCMProfileService* gcm_service = static_cast<gcm::GCMProfileService*>( |
130 gcm::GCMProfileServiceFactory::GetInstance()->SetTestingFactoryAndUse( | 109 gcm::GCMProfileServiceFactory::GetInstance()->SetTestingFactoryAndUse( |
131 GetBrowser()->profile(), &gcm::FakeGCMProfileService::Build)); | 110 GetBrowser()->profile(), &gcm::FakeGCMProfileService::Build)); |
132 gcm_service_->set_collect(true); | 111 gcm_driver_ = gcm_service->driver(); |
133 push_service_ = | 112 push_service_ = |
134 PushMessagingServiceFactory::GetForProfile(GetBrowser()->profile()); | 113 PushMessagingServiceFactory::GetForProfile(GetBrowser()->profile()); |
135 | 114 |
136 LoadTestPage(); | 115 LoadTestPage(); |
137 | 116 |
138 InProcessBrowserTest::SetUpOnMainThread(); | 117 InProcessBrowserTest::SetUpOnMainThread(); |
139 } | 118 } |
140 | 119 |
141 void RestartPushService() { | 120 void RestartPushService() { |
142 Profile* profile = GetBrowser()->profile(); | 121 Profile* profile = GetBrowser()->profile(); |
(...skipping 26 matching lines...) Expand all Loading... | |
169 | 148 |
170 bool RunScript(const std::string& script, std::string* result, | 149 bool RunScript(const std::string& script, std::string* result, |
171 content::WebContents* web_contents) { | 150 content::WebContents* web_contents) { |
172 if (!web_contents) | 151 if (!web_contents) |
173 web_contents = GetBrowser()->tab_strip_model()->GetActiveWebContents(); | 152 web_contents = GetBrowser()->tab_strip_model()->GetActiveWebContents(); |
174 return content::ExecuteScriptAndExtractString(web_contents->GetMainFrame(), | 153 return content::ExecuteScriptAndExtractString(web_contents->GetMainFrame(), |
175 script, result); | 154 script, result); |
176 } | 155 } |
177 | 156 |
178 gcm::GCMAppHandler* GetAppHandler() { | 157 gcm::GCMAppHandler* GetAppHandler() { |
179 return gcm_service()->driver()->GetAppHandler( | 158 return gcm_driver_->GetAppHandler(kPushMessagingAppIdentifierPrefix); |
180 kPushMessagingAppIdentifierPrefix); | |
181 } | 159 } |
182 | 160 |
183 PermissionBubbleManager* GetPermissionBubbleManager() { | 161 PermissionBubbleManager* GetPermissionBubbleManager() { |
184 return PermissionBubbleManager::FromWebContents( | 162 return PermissionBubbleManager::FromWebContents( |
185 GetBrowser()->tab_strip_model()->GetActiveWebContents()); | 163 GetBrowser()->tab_strip_model()->GetActiveWebContents()); |
186 } | 164 } |
187 | 165 |
188 void RequestAndAcceptPermission(); | 166 void RequestAndAcceptPermission(); |
189 void RequestAndDenyPermission(); | 167 void RequestAndDenyPermission(); |
190 | 168 |
191 void TryToSubscribeSuccessfully( | 169 // Returns the subscription token (not including kPushMessagingEndpoint). |
192 const std::string& expected_push_subscription_info, | 170 std::string SubscribeSuccessfully(bool use_key = true); |
193 bool use_key = true); | |
194 | 171 |
195 std::string GetEndpointForSubscriptionId(const std::string& subscription_id) { | 172 std::string EndpointToToken(const std::string& endpoint); |
196 return std::string(kPushMessagingEndpoint) + "/" + subscription_id; | |
197 } | |
198 | 173 |
199 PushMessagingAppIdentifier GetAppIdentifierForServiceWorkerRegistration( | 174 PushMessagingAppIdentifier GetAppIdentifierForServiceWorkerRegistration( |
200 int64_t service_worker_registration_id); | 175 int64_t service_worker_registration_id); |
201 | 176 |
202 void SendMessageAndWaitUntilHandled( | 177 void SendMessageAndWaitUntilHandled( |
203 const PushMessagingAppIdentifier& app_identifier, | 178 const PushMessagingAppIdentifier& app_identifier, |
204 const gcm::IncomingMessage& message); | 179 const gcm::IncomingMessage& message); |
205 | 180 |
206 net::EmbeddedTestServer* https_server() const { return https_server_.get(); } | 181 net::EmbeddedTestServer* https_server() const { return https_server_.get(); } |
207 | 182 |
208 gcm::FakeGCMProfileService* gcm_service() const { return gcm_service_; } | |
209 | |
210 #if defined(ENABLE_NOTIFICATIONS) | 183 #if defined(ENABLE_NOTIFICATIONS) |
211 // To be called when delivery of a push message has finished. The |run_loop| | 184 // To be called when delivery of a push message has finished. The |run_loop| |
212 // will be told to quit after |messages_required| messages were received. | 185 // will be told to quit after |messages_required| messages were received. |
213 void OnDeliveryFinished(std::vector<size_t>* number_of_notifications_shown, | 186 void OnDeliveryFinished(std::vector<size_t>* number_of_notifications_shown, |
214 const base::Closure& done_closure) { | 187 const base::Closure& done_closure) { |
215 DCHECK(number_of_notifications_shown); | 188 DCHECK(number_of_notifications_shown); |
216 | 189 |
217 number_of_notifications_shown->push_back( | 190 number_of_notifications_shown->push_back( |
218 notification_manager_->GetNotificationCount()); | 191 notification_manager_->GetNotificationCount()); |
219 | 192 |
(...skipping 11 matching lines...) Expand all Loading... | |
231 | 204 |
232 PushMessagingServiceImpl* push_service() const { return push_service_; } | 205 PushMessagingServiceImpl* push_service() const { return push_service_; } |
233 | 206 |
234 protected: | 207 protected: |
235 virtual std::string GetTestURL() { return "/push_messaging/test.html"; } | 208 virtual std::string GetTestURL() { return "/push_messaging/test.html"; } |
236 | 209 |
237 virtual Browser* GetBrowser() const { return browser(); } | 210 virtual Browser* GetBrowser() const { return browser(); } |
238 | 211 |
239 private: | 212 private: |
240 scoped_ptr<net::EmbeddedTestServer> https_server_; | 213 scoped_ptr<net::EmbeddedTestServer> https_server_; |
241 gcm::FakeGCMProfileService* gcm_service_; | 214 gcm::GCMDriver* gcm_driver_; |
242 PushMessagingServiceImpl* push_service_; | 215 PushMessagingServiceImpl* push_service_; |
243 | 216 |
244 #if defined(ENABLE_NOTIFICATIONS) | 217 #if defined(ENABLE_NOTIFICATIONS) |
245 scoped_ptr<StubNotificationUIManager> notification_manager_; | 218 scoped_ptr<StubNotificationUIManager> notification_manager_; |
246 #endif | 219 #endif |
247 | 220 |
248 DISALLOW_COPY_AND_ASSIGN(PushMessagingBrowserTest); | 221 DISALLOW_COPY_AND_ASSIGN(PushMessagingBrowserTest); |
249 }; | 222 }; |
250 | 223 |
251 class PushMessagingBrowserTestEmptySubscriptionOptions | 224 class PushMessagingBrowserTestEmptySubscriptionOptions |
(...skipping 12 matching lines...) Expand all Loading... | |
264 } | 237 } |
265 | 238 |
266 void PushMessagingBrowserTest::RequestAndDenyPermission() { | 239 void PushMessagingBrowserTest::RequestAndDenyPermission() { |
267 std::string script_result; | 240 std::string script_result; |
268 GetPermissionBubbleManager()->set_auto_response_for_test( | 241 GetPermissionBubbleManager()->set_auto_response_for_test( |
269 PermissionBubbleManager::DENY_ALL); | 242 PermissionBubbleManager::DENY_ALL); |
270 EXPECT_TRUE(RunScript("requestNotificationPermission();", &script_result)); | 243 EXPECT_TRUE(RunScript("requestNotificationPermission();", &script_result)); |
271 EXPECT_EQ("permission status - denied", script_result); | 244 EXPECT_EQ("permission status - denied", script_result); |
272 } | 245 } |
273 | 246 |
274 void PushMessagingBrowserTest::TryToSubscribeSuccessfully( | 247 std::string PushMessagingBrowserTest::SubscribeSuccessfully(bool use_key) { |
275 const std::string& expected_push_subscription_info, | |
276 bool use_key) { | |
277 std::string script_result; | 248 std::string script_result; |
278 | 249 |
279 EXPECT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 250 EXPECT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
280 EXPECT_EQ("ok - service worker registered", script_result); | 251 EXPECT_EQ("ok - service worker registered", script_result); |
281 | 252 |
282 RequestAndAcceptPermission(); | 253 RequestAndAcceptPermission(); |
283 | 254 |
284 if (use_key) { | 255 if (use_key) { |
285 ASSERT_TRUE(RunScript("removeManifest()", &script_result)); | 256 EXPECT_TRUE(RunScript("removeManifest()", &script_result)); |
286 ASSERT_EQ("manifest removed", script_result); | 257 EXPECT_EQ("manifest removed", script_result); |
287 | 258 |
288 EXPECT_TRUE(RunScript("documentSubscribePush()", &script_result)); | 259 EXPECT_TRUE(RunScript("documentSubscribePush()", &script_result)); |
289 } else { | 260 } else { |
290 // Test backwards compatibility with old ID based subscriptions. | 261 // Test backwards compatibility with old ID based subscriptions. |
291 EXPECT_TRUE(RunScript("documentSubscribePushWithoutKey()", &script_result)); | 262 EXPECT_TRUE(RunScript("documentSubscribePushWithoutKey()", &script_result)); |
292 } | 263 } |
264 return EndpointToToken(script_result); | |
265 } | |
293 | 266 |
294 EXPECT_EQ(GetEndpointForSubscriptionId(expected_push_subscription_info), | 267 std::string PushMessagingBrowserTest::EndpointToToken( |
295 script_result); | 268 const std::string& endpoint) { |
269 std::string endpoint_prefix = std::string(kPushMessagingEndpoint) + "/"; | |
Peter Beverloo
2016/04/11 15:47:56
We cannot rely on kPushMessagingEndpoint anymore.
johnme
2016/04/21 10:58:37
Done.
| |
270 EXPECT_THAT(endpoint, ::testing::StartsWith(endpoint_prefix)); | |
271 EXPECT_GT(endpoint.length(), endpoint_prefix.length()); | |
272 return endpoint.substr(endpoint_prefix.length()); | |
296 } | 273 } |
297 | 274 |
298 PushMessagingAppIdentifier | 275 PushMessagingAppIdentifier |
299 PushMessagingBrowserTest::GetAppIdentifierForServiceWorkerRegistration( | 276 PushMessagingBrowserTest::GetAppIdentifierForServiceWorkerRegistration( |
300 int64_t service_worker_registration_id) { | 277 int64_t service_worker_registration_id) { |
301 GURL origin = https_server()->GetURL("/").GetOrigin(); | 278 GURL origin = https_server()->GetURL("/").GetOrigin(); |
302 PushMessagingAppIdentifier app_identifier = | 279 PushMessagingAppIdentifier app_identifier = |
303 PushMessagingAppIdentifier::FindByServiceWorker( | 280 PushMessagingAppIdentifier::FindByServiceWorker( |
304 GetBrowser()->profile(), origin, service_worker_registration_id); | 281 GetBrowser()->profile(), origin, service_worker_registration_id); |
305 EXPECT_FALSE(app_identifier.is_null()); | 282 EXPECT_FALSE(app_identifier.is_null()); |
306 return app_identifier; | 283 return app_identifier; |
307 } | 284 } |
308 | 285 |
309 void PushMessagingBrowserTest::SendMessageAndWaitUntilHandled( | 286 void PushMessagingBrowserTest::SendMessageAndWaitUntilHandled( |
310 const PushMessagingAppIdentifier& app_identifier, | 287 const PushMessagingAppIdentifier& app_identifier, |
311 const gcm::IncomingMessage& message) { | 288 const gcm::IncomingMessage& message) { |
312 base::RunLoop run_loop; | 289 base::RunLoop run_loop; |
313 push_service()->SetMessageCallbackForTesting(run_loop.QuitClosure()); | 290 push_service()->SetMessageCallbackForTesting(run_loop.QuitClosure()); |
314 push_service()->OnMessage(app_identifier.app_id(), message); | 291 push_service()->OnMessage(app_identifier.app_id(), message); |
315 run_loop.Run(); | 292 run_loop.Run(); |
316 } | 293 } |
317 | 294 |
318 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, | 295 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
319 SubscribeWithoutKeySuccessNotificationsGranted) { | 296 SubscribeWithoutKeySuccessNotificationsGranted) { |
320 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */, false); | 297 // Both of these methods EXPECT that they succeed. |
321 | 298 SubscribeSuccessfully(false /* use_key */); |
322 PushMessagingAppIdentifier app_identifier = | 299 GetAppIdentifierForServiceWorkerRegistration(0LL); |
323 GetAppIdentifierForServiceWorkerRegistration(0LL); | |
324 EXPECT_EQ(app_identifier.app_id(), gcm_service()->last_registered_app_id()); | |
325 EXPECT_EQ("1234567890", gcm_service()->last_registered_sender_ids()[0]); | |
326 } | 300 } |
327 | 301 |
328 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, | 302 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
329 SubscribeSuccessNotificationsGranted) { | 303 SubscribeSuccessNotificationsGranted) { |
330 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); | 304 // Both of these methods EXPECT that they succeed. |
331 | 305 SubscribeSuccessfully(); |
332 PushMessagingAppIdentifier app_identifier = | 306 GetAppIdentifierForServiceWorkerRegistration(0LL); |
333 GetAppIdentifierForServiceWorkerRegistration(0LL); | |
334 EXPECT_EQ(app_identifier.app_id(), gcm_service()->last_registered_app_id()); | |
335 EXPECT_EQ(getTestApplicationServerKey(), | |
336 gcm_service()->last_registered_sender_ids()[0]); | |
337 } | 307 } |
338 | 308 |
339 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, | 309 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
340 SubscribeSuccessNotificationsPrompt) { | 310 SubscribeSuccessNotificationsPrompt) { |
341 std::string script_result; | 311 std::string script_result; |
342 | 312 |
343 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 313 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
344 ASSERT_EQ("ok - service worker registered", script_result); | 314 ASSERT_EQ("ok - service worker registered", script_result); |
345 | 315 |
346 GetPermissionBubbleManager()->set_auto_response_for_test( | 316 GetPermissionBubbleManager()->set_auto_response_for_test( |
347 PermissionBubbleManager::ACCEPT_ALL); | 317 PermissionBubbleManager::ACCEPT_ALL); |
348 ASSERT_TRUE(RunScript("documentSubscribePush()", &script_result)); | 318 ASSERT_TRUE(RunScript("documentSubscribePush()", &script_result)); |
349 EXPECT_EQ(GetEndpointForSubscriptionId("1-0"), script_result); | 319 // Both of these methods EXPECT that they succeed. |
350 | 320 EndpointToToken(script_result); |
351 PushMessagingAppIdentifier app_identifier = | 321 GetAppIdentifierForServiceWorkerRegistration(0LL); |
352 GetAppIdentifierForServiceWorkerRegistration(0LL); | |
353 EXPECT_EQ(app_identifier.app_id(), gcm_service()->last_registered_app_id()); | |
354 EXPECT_EQ(getTestApplicationServerKey(), | |
355 gcm_service()->last_registered_sender_ids()[0]); | |
356 } | 322 } |
357 | 323 |
358 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, SubscribeFailureBadKey) { | 324 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, SubscribeFailureBadKey) { |
359 std::string script_result; | 325 std::string script_result; |
360 | 326 |
361 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 327 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
362 ASSERT_EQ("ok - service worker registered", script_result); | 328 ASSERT_EQ("ok - service worker registered", script_result); |
363 | 329 |
364 RequestAndAcceptPermission(); | 330 RequestAndAcceptPermission(); |
365 | 331 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
445 ASSERT_EQ("true - is controlled", script_result); | 411 ASSERT_EQ("true - is controlled", script_result); |
446 | 412 |
447 // Try to subscribe from a worker without a key. This should fail. | 413 // Try to subscribe from a worker without a key. This should fail. |
448 ASSERT_TRUE(RunScript("workerSubscribePushNoKey()", &script_result)); | 414 ASSERT_TRUE(RunScript("workerSubscribePushNoKey()", &script_result)); |
449 EXPECT_EQ( | 415 EXPECT_EQ( |
450 "AbortError - Registration failed - gcm_sender_id not found in manifest", | 416 "AbortError - Registration failed - gcm_sender_id not found in manifest", |
451 script_result); | 417 script_result); |
452 // Now run the subscribe from the service worker with a key. This | 418 // Now run the subscribe from the service worker with a key. This |
453 // should succeed, and write the key to the datastore. | 419 // should succeed, and write the key to the datastore. |
454 ASSERT_TRUE(RunScript("workerSubscribePush()", &script_result)); | 420 ASSERT_TRUE(RunScript("workerSubscribePush()", &script_result)); |
455 EXPECT_EQ(GetEndpointForSubscriptionId("1-0"), script_result); | 421 std::string token1 = EndpointToToken(script_result); |
456 | 422 |
457 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 423 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
458 EXPECT_EQ("unsubscribe result: true", script_result); | 424 EXPECT_EQ("unsubscribe result: true", script_result); |
459 EXPECT_NE(push_service(), GetAppHandler()); | 425 EXPECT_NE(push_service(), GetAppHandler()); |
460 | 426 |
461 // Now run the subscribe from the service worker without a key. | 427 // Now run the subscribe from the service worker without a key. |
462 // In this case, the key will be read from the datastore. | 428 // In this case, the key will be read from the datastore. |
463 ASSERT_TRUE(RunScript("workerSubscribePushNoKey()", &script_result)); | 429 ASSERT_TRUE(RunScript("workerSubscribePushNoKey()", &script_result)); |
464 EXPECT_EQ(GetEndpointForSubscriptionId("1-1"), script_result); | 430 std::string token2 = EndpointToToken(script_result); |
431 EXPECT_NE(token1, token2); | |
465 | 432 |
466 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 433 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
467 EXPECT_EQ("unsubscribe result: true", script_result); | 434 EXPECT_EQ("unsubscribe result: true", script_result); |
468 EXPECT_NE(push_service(), GetAppHandler()); | 435 EXPECT_NE(push_service(), GetAppHandler()); |
469 } | 436 } |
470 | 437 |
471 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, SubscribeWorkerUsingManifest) { | 438 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, SubscribeWorkerUsingManifest) { |
472 std::string script_result; | 439 std::string script_result; |
473 | 440 |
474 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 441 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
(...skipping 10 matching lines...) Expand all Loading... | |
485 ASSERT_TRUE(RunScript("workerSubscribePushNoKey()", &script_result)); | 452 ASSERT_TRUE(RunScript("workerSubscribePushNoKey()", &script_result)); |
486 EXPECT_EQ( | 453 EXPECT_EQ( |
487 "AbortError - Registration failed - gcm_sender_id not found in manifest", | 454 "AbortError - Registration failed - gcm_sender_id not found in manifest", |
488 script_result); | 455 script_result); |
489 EXPECT_NE(push_service(), GetAppHandler()); | 456 EXPECT_NE(push_service(), GetAppHandler()); |
490 | 457 |
491 // Run the subscription from the document without a key, this will trigger | 458 // Run the subscription from the document without a key, this will trigger |
492 // the code to read sender id from the manifest and will write it to the | 459 // the code to read sender id from the manifest and will write it to the |
493 // datastore. | 460 // datastore. |
494 ASSERT_TRUE(RunScript("documentSubscribePushWithoutKey()", &script_result)); | 461 ASSERT_TRUE(RunScript("documentSubscribePushWithoutKey()", &script_result)); |
495 EXPECT_EQ(GetEndpointForSubscriptionId("1-0"), script_result); | 462 std::string token1 = EndpointToToken(script_result); |
496 | 463 |
497 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 464 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
498 EXPECT_EQ("unsubscribe result: true", script_result); | 465 EXPECT_EQ("unsubscribe result: true", script_result); |
499 EXPECT_NE(push_service(), GetAppHandler()); | 466 EXPECT_NE(push_service(), GetAppHandler()); |
500 | 467 |
501 // Now run the subscribe from the service worker without a key. | 468 // Now run the subscribe from the service worker without a key. |
502 // In this case, the sender id will be read from the datastore. | 469 // In this case, the sender id will be read from the datastore. |
503 ASSERT_TRUE(RunScript("workerSubscribePushNoKey()", &script_result)); | 470 ASSERT_TRUE(RunScript("workerSubscribePushNoKey()", &script_result)); |
504 EXPECT_EQ(GetEndpointForSubscriptionId("1-1"), script_result); | 471 std::string token2 = EndpointToToken(script_result); |
472 EXPECT_NE(token1, token2); | |
505 | 473 |
506 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 474 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
507 EXPECT_EQ("unsubscribe result: true", script_result); | 475 EXPECT_EQ("unsubscribe result: true", script_result); |
508 EXPECT_NE(push_service(), GetAppHandler()); | 476 EXPECT_NE(push_service(), GetAppHandler()); |
509 } | 477 } |
510 | 478 |
511 // Disabled on Windows and Linux due to flakiness (http://crbug.com/554003). | 479 // Disabled on Windows and Linux due to flakiness (http://crbug.com/554003). |
512 #if defined(OS_WIN) || defined(OS_LINUX) | 480 #if defined(OS_WIN) || defined(OS_LINUX) |
513 #define MAYBE_SubscribePersisted DISABLED_SubscribePersisted | 481 #define MAYBE_SubscribePersisted DISABLED_SubscribePersisted |
514 #else | 482 #else |
515 #define MAYBE_SubscribePersisted SubscribePersisted | 483 #define MAYBE_SubscribePersisted SubscribePersisted |
516 #endif | 484 #endif |
517 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, MAYBE_SubscribePersisted) { | 485 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, MAYBE_SubscribePersisted) { |
518 std::string script_result; | 486 std::string script_result; |
519 | 487 |
520 // First, test that Service Worker registration IDs are assigned in order of | 488 // First, test that Service Worker registration IDs are assigned in order of |
521 // registering the Service Workers, and the (fake) push subscription ids are | 489 // registering the Service Workers, and the (fake) push subscription ids are |
522 // assigned in order of push subscription (even when these orders are | 490 // assigned in order of push subscription (even when these orders are |
523 // different). | 491 // different). |
524 | 492 |
525 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); | 493 std::string token1 = SubscribeSuccessfully(); |
526 PushMessagingAppIdentifier sw0_identifier = | 494 GetAppIdentifierForServiceWorkerRegistration(0LL); |
527 GetAppIdentifierForServiceWorkerRegistration(0LL); | |
528 EXPECT_EQ(sw0_identifier.app_id(), gcm_service()->last_registered_app_id()); | |
529 | 495 |
530 LoadTestPage("/push_messaging/subscope1/test.html"); | 496 LoadTestPage("/push_messaging/subscope1/test.html"); |
531 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 497 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
532 ASSERT_EQ("ok - service worker registered", script_result); | 498 ASSERT_EQ("ok - service worker registered", script_result); |
533 | 499 |
534 LoadTestPage("/push_messaging/subscope2/test.html"); | 500 LoadTestPage("/push_messaging/subscope2/test.html"); |
535 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 501 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
536 ASSERT_EQ("ok - service worker registered", script_result); | 502 ASSERT_EQ("ok - service worker registered", script_result); |
537 | 503 |
538 // Note that we need to reload the page after registering, otherwise | 504 // Note that we need to reload the page after registering, otherwise |
539 // navigator.serviceWorker.ready is going to be resolved with the parent | 505 // navigator.serviceWorker.ready is going to be resolved with the parent |
540 // Service Worker which still controls the page. | 506 // Service Worker which still controls the page. |
541 LoadTestPage("/push_messaging/subscope2/test.html"); | 507 LoadTestPage("/push_messaging/subscope2/test.html"); |
542 TryToSubscribeSuccessfully("1-1" /* expected_push_subscription_id */); | 508 std::string token2 = SubscribeSuccessfully(); |
543 PushMessagingAppIdentifier sw2_identifier = | 509 EXPECT_NE(token1, token2); |
544 GetAppIdentifierForServiceWorkerRegistration(2LL); | 510 GetAppIdentifierForServiceWorkerRegistration(2LL); |
545 EXPECT_EQ(sw2_identifier.app_id(), gcm_service()->last_registered_app_id()); | |
546 | 511 |
547 LoadTestPage("/push_messaging/subscope1/test.html"); | 512 LoadTestPage("/push_messaging/subscope1/test.html"); |
548 TryToSubscribeSuccessfully("1-2" /* expected_push_subscription_id */); | 513 std::string token3 = SubscribeSuccessfully(); |
549 PushMessagingAppIdentifier sw1_identifier = | 514 EXPECT_NE(token1, token3); |
550 GetAppIdentifierForServiceWorkerRegistration(1LL); | 515 EXPECT_NE(token2, token3); |
551 EXPECT_EQ(sw1_identifier.app_id(), gcm_service()->last_registered_app_id()); | 516 GetAppIdentifierForServiceWorkerRegistration(1LL); |
552 | 517 |
553 // Now test that the Service Worker registration IDs and push subscription IDs | 518 // Now test that the Service Worker registration IDs and push subscription IDs |
554 // generated above were persisted to SW storage, by checking that they are | 519 // generated above were persisted to SW storage, by checking that they are |
555 // unchanged despite requesting them in a different order. | 520 // unchanged despite requesting them in a different order. |
556 // TODO(johnme): Ideally we would restart the browser at this point to check | 521 // TODO(johnme): Ideally we would restart the browser at this point to check |
557 // they were persisted to disk, but that's not currently possible since the | 522 // they were persisted to disk, but that's not currently possible since the |
558 // test server uses random port numbers for each test (even PRE_Foo and Foo), | 523 // test server uses random port numbers for each test (even PRE_Foo and Foo), |
559 // so we wouldn't be able to load the test pages with the same origin. | 524 // so we wouldn't be able to load the test pages with the same origin. |
560 | 525 |
561 LoadTestPage("/push_messaging/subscope1/test.html"); | 526 LoadTestPage("/push_messaging/subscope1/test.html"); |
562 TryToSubscribeSuccessfully("1-2" /* expected_push_subscription_id */); | 527 std::string token4 = SubscribeSuccessfully(); |
563 EXPECT_EQ(sw1_identifier.app_id(), gcm_service()->last_registered_app_id()); | 528 EXPECT_EQ(token3, token4); |
564 | 529 |
565 LoadTestPage("/push_messaging/subscope2/test.html"); | 530 LoadTestPage("/push_messaging/subscope2/test.html"); |
566 TryToSubscribeSuccessfully("1-1" /* expected_push_subscription_id */); | 531 std::string token5 = SubscribeSuccessfully(); |
567 EXPECT_EQ(sw1_identifier.app_id(), gcm_service()->last_registered_app_id()); | 532 EXPECT_EQ(token2, token5); |
568 | 533 |
569 LoadTestPage(); | 534 LoadTestPage(); |
570 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); | 535 std::string token6 = SubscribeSuccessfully(); |
571 EXPECT_EQ(sw1_identifier.app_id(), gcm_service()->last_registered_app_id()); | 536 EXPECT_EQ(token1, token6); |
572 } | 537 } |
573 | 538 |
574 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, AppHandlerOnlyIfSubscribed) { | 539 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, AppHandlerOnlyIfSubscribed) { |
575 // This test restarts the push service to simulate restarting the browser. | 540 // This test restarts the push service to simulate restarting the browser. |
576 | 541 |
577 EXPECT_NE(push_service(), GetAppHandler()); | 542 EXPECT_NE(push_service(), GetAppHandler()); |
578 ASSERT_NO_FATAL_FAILURE(RestartPushService()); | 543 ASSERT_NO_FATAL_FAILURE(RestartPushService()); |
579 EXPECT_NE(push_service(), GetAppHandler()); | 544 EXPECT_NE(push_service(), GetAppHandler()); |
580 | 545 |
581 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); | 546 SubscribeSuccessfully(); |
Peter Beverloo
2016/04/11 15:47:56
It seems to me that this very much is something we
johnme
2016/04/21 10:58:37
Done (and generally cleaned this up elsewhere too)
| |
582 | 547 |
583 EXPECT_EQ(push_service(), GetAppHandler()); | 548 EXPECT_EQ(push_service(), GetAppHandler()); |
584 ASSERT_NO_FATAL_FAILURE(RestartPushService()); | 549 ASSERT_NO_FATAL_FAILURE(RestartPushService()); |
585 EXPECT_EQ(push_service(), GetAppHandler()); | 550 EXPECT_EQ(push_service(), GetAppHandler()); |
586 | 551 |
587 // Unsubscribe. | 552 // Unsubscribe. |
588 std::string script_result; | 553 std::string script_result; |
589 gcm_service()->AddExpectedUnregisterResponse(gcm::GCMClient::SUCCESS); | |
590 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 554 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
591 EXPECT_EQ("unsubscribe result: true", script_result); | 555 EXPECT_EQ("unsubscribe result: true", script_result); |
592 | 556 |
593 EXPECT_NE(push_service(), GetAppHandler()); | 557 EXPECT_NE(push_service(), GetAppHandler()); |
594 ASSERT_NO_FATAL_FAILURE(RestartPushService()); | 558 ASSERT_NO_FATAL_FAILURE(RestartPushService()); |
595 EXPECT_NE(push_service(), GetAppHandler()); | 559 EXPECT_NE(push_service(), GetAppHandler()); |
596 } | 560 } |
597 | 561 |
598 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PushEventSuccess) { | 562 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PushEventSuccess) { |
599 std::string script_result; | 563 std::string script_result; |
600 | 564 |
601 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); | 565 SubscribeSuccessfully(); |
602 | |
603 PushMessagingAppIdentifier app_identifier = | 566 PushMessagingAppIdentifier app_identifier = |
604 GetAppIdentifierForServiceWorkerRegistration(0LL); | 567 GetAppIdentifierForServiceWorkerRegistration(0LL); |
605 EXPECT_EQ(app_identifier.app_id(), gcm_service()->last_registered_app_id()); | |
606 EXPECT_EQ(getTestApplicationServerKey(), | |
607 gcm_service()->last_registered_sender_ids()[0]); | |
608 | 568 |
609 ASSERT_TRUE(RunScript("isControlled()", &script_result)); | 569 ASSERT_TRUE(RunScript("isControlled()", &script_result)); |
610 ASSERT_EQ("false - is not controlled", script_result); | 570 ASSERT_EQ("false - is not controlled", script_result); |
611 | 571 |
612 LoadTestPage(); // Reload to become controlled. | 572 LoadTestPage(); // Reload to become controlled. |
613 | 573 |
614 ASSERT_TRUE(RunScript("isControlled()", &script_result)); | 574 ASSERT_TRUE(RunScript("isControlled()", &script_result)); |
615 ASSERT_EQ("true - is controlled", script_result); | 575 ASSERT_EQ("true - is controlled", script_result); |
616 | 576 |
617 gcm::IncomingMessage message; | 577 gcm::IncomingMessage message; |
618 message.sender_id = std::string(getTestApplicationServerKey()); | 578 message.sender_id = std::string(getTestApplicationServerKey()); |
619 message.raw_data = "testdata"; | 579 message.raw_data = "testdata"; |
620 message.decrypted = true; | 580 message.decrypted = true; |
621 push_service()->OnMessage(app_identifier.app_id(), message); | 581 push_service()->OnMessage(app_identifier.app_id(), message); |
622 ASSERT_TRUE(RunScript("resultQueue.pop()", &script_result)); | 582 ASSERT_TRUE(RunScript("resultQueue.pop()", &script_result)); |
623 EXPECT_EQ("testdata", script_result); | 583 EXPECT_EQ("testdata", script_result); |
624 } | 584 } |
625 | 585 |
626 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PushEventWithoutPayload) { | 586 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PushEventWithoutPayload) { |
627 std::string script_result; | 587 std::string script_result; |
628 | 588 |
629 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); | 589 SubscribeSuccessfully(); |
630 | |
631 PushMessagingAppIdentifier app_identifier = | 590 PushMessagingAppIdentifier app_identifier = |
632 GetAppIdentifierForServiceWorkerRegistration(0LL); | 591 GetAppIdentifierForServiceWorkerRegistration(0LL); |
633 EXPECT_EQ(app_identifier.app_id(), gcm_service()->last_registered_app_id()); | |
634 EXPECT_EQ(getTestApplicationServerKey(), | |
635 gcm_service()->last_registered_sender_ids()[0]); | |
636 | 592 |
637 ASSERT_TRUE(RunScript("isControlled()", &script_result)); | 593 ASSERT_TRUE(RunScript("isControlled()", &script_result)); |
638 ASSERT_EQ("false - is not controlled", script_result); | 594 ASSERT_EQ("false - is not controlled", script_result); |
639 | 595 |
640 LoadTestPage(); // Reload to become controlled. | 596 LoadTestPage(); // Reload to become controlled. |
641 | 597 |
642 ASSERT_TRUE(RunScript("isControlled()", &script_result)); | 598 ASSERT_TRUE(RunScript("isControlled()", &script_result)); |
643 ASSERT_EQ("true - is controlled", script_result); | 599 ASSERT_EQ("true - is controlled", script_result); |
644 | 600 |
645 gcm::IncomingMessage message; | 601 gcm::IncomingMessage message; |
646 message.sender_id = std::string(getTestApplicationServerKey()); | 602 message.sender_id = std::string(getTestApplicationServerKey()); |
647 message.decrypted = false; | 603 message.decrypted = false; |
648 | 604 |
649 push_service()->OnMessage(app_identifier.app_id(), message); | 605 push_service()->OnMessage(app_identifier.app_id(), message); |
650 ASSERT_TRUE(RunScript("resultQueue.pop()", &script_result)); | 606 ASSERT_TRUE(RunScript("resultQueue.pop()", &script_result)); |
651 EXPECT_EQ("[NULL]", script_result); | 607 EXPECT_EQ("[NULL]", script_result); |
652 } | 608 } |
653 | 609 |
654 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PushEventNoServiceWorker) { | 610 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PushEventNoServiceWorker) { |
655 std::string script_result; | 611 std::string script_result; |
656 | 612 |
657 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); | 613 SubscribeSuccessfully(); |
658 | |
659 PushMessagingAppIdentifier app_identifier = | 614 PushMessagingAppIdentifier app_identifier = |
660 GetAppIdentifierForServiceWorkerRegistration(0LL); | 615 GetAppIdentifierForServiceWorkerRegistration(0LL); |
661 EXPECT_EQ(app_identifier.app_id(), gcm_service()->last_registered_app_id()); | |
662 EXPECT_EQ(getTestApplicationServerKey(), | |
663 gcm_service()->last_registered_sender_ids()[0]); | |
664 | 616 |
665 ASSERT_TRUE(RunScript("isControlled()", &script_result)); | 617 ASSERT_TRUE(RunScript("isControlled()", &script_result)); |
666 ASSERT_EQ("false - is not controlled", script_result); | 618 ASSERT_EQ("false - is not controlled", script_result); |
667 | 619 |
668 LoadTestPage(); // Reload to become controlled. | 620 LoadTestPage(); // Reload to become controlled. |
669 | 621 |
670 ASSERT_TRUE(RunScript("isControlled()", &script_result)); | 622 ASSERT_TRUE(RunScript("isControlled()", &script_result)); |
671 ASSERT_EQ("true - is controlled", script_result); | 623 ASSERT_EQ("true - is controlled", script_result); |
672 | 624 |
673 // Unregister service worker. Sending a message should now fail. | 625 // Unregister service worker. Sending a message should now fail. |
674 ASSERT_TRUE(RunScript("unregisterServiceWorker()", &script_result)); | 626 ASSERT_TRUE(RunScript("unregisterServiceWorker()", &script_result)); |
675 ASSERT_EQ("service worker unregistration status: true", script_result); | 627 ASSERT_EQ("service worker unregistration status: true", script_result); |
676 | 628 |
677 // When the push service will receive it next message, given that there is no | 629 // Unregistering the service worker doesn't yet unsubscribe from push (though |
678 // SW available, it should unregister |app_identifier.app_id()|. | 630 // it should), and FindByServiceWorker doesn't require a live SW. |
679 UnregistrationCallback callback; | 631 GURL origin = https_server()->GetURL("/").GetOrigin(); |
680 gcm_service()->SetUnregisterCallback( | 632 PushMessagingAppIdentifier app_identifier2 = |
681 base::Bind(&UnregistrationCallback::Run, base::Unretained(&callback))); | 633 PushMessagingAppIdentifier::FindByServiceWorker( |
634 GetBrowser()->profile(), | |
635 origin, 0LL /* service_worker_registration_id */); | |
636 EXPECT_FALSE(app_identifier2.is_null()); | |
637 EXPECT_EQ(app_identifier.app_id(), app_identifier2.app_id()); | |
682 | 638 |
683 gcm::IncomingMessage message; | 639 gcm::IncomingMessage message; |
684 message.sender_id = std::string(getTestApplicationServerKey()); | 640 message.sender_id = std::string(getTestApplicationServerKey()); |
685 message.raw_data = "testdata"; | 641 message.raw_data = "testdata"; |
686 message.decrypted = true; | 642 message.decrypted = true; |
687 push_service()->OnMessage(app_identifier.app_id(), message); | 643 SendMessageAndWaitUntilHandled(app_identifier, message); |
688 | 644 |
689 callback.WaitUntilSatisfied(); | 645 // Now the push service has received a message and failed to find its service |
690 EXPECT_EQ(app_identifier.app_id(), callback.app_id()); | 646 // worker, it should have automatically unsubscribed app_identifier.app_id(). |
647 PushMessagingAppIdentifier app_identifier3 = | |
648 PushMessagingAppIdentifier::FindByServiceWorker( | |
649 GetBrowser()->profile(), | |
650 origin, 0LL /* service_worker_registration_id */); | |
651 EXPECT_TRUE(app_identifier3.is_null()); | |
691 | 652 |
692 // No push data should have been received. | 653 // No push data should have been received. |
693 ASSERT_TRUE(RunScript("resultQueue.popImmediately()", &script_result)); | 654 ASSERT_TRUE(RunScript("resultQueue.popImmediately()", &script_result)); |
694 EXPECT_EQ("null", script_result); | 655 EXPECT_EQ("null", script_result); |
695 } | 656 } |
696 | 657 |
697 #if defined(ENABLE_NOTIFICATIONS) | 658 #if defined(ENABLE_NOTIFICATIONS) |
698 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, | 659 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
699 PushEventEnforcesUserVisibleNotification) { | 660 PushEventEnforcesUserVisibleNotification) { |
700 std::string script_result; | 661 std::string script_result; |
701 | 662 |
702 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); | 663 SubscribeSuccessfully(); |
703 | |
704 PushMessagingAppIdentifier app_identifier = | 664 PushMessagingAppIdentifier app_identifier = |
705 GetAppIdentifierForServiceWorkerRegistration(0LL); | 665 GetAppIdentifierForServiceWorkerRegistration(0LL); |
706 EXPECT_EQ(app_identifier.app_id(), gcm_service()->last_registered_app_id()); | |
707 EXPECT_EQ(getTestApplicationServerKey(), | |
708 gcm_service()->last_registered_sender_ids()[0]); | |
709 | 666 |
710 ASSERT_TRUE(RunScript("isControlled()", &script_result)); | 667 ASSERT_TRUE(RunScript("isControlled()", &script_result)); |
711 ASSERT_EQ("false - is not controlled", script_result); | 668 ASSERT_EQ("false - is not controlled", script_result); |
712 | 669 |
713 LoadTestPage(); // Reload to become controlled. | 670 LoadTestPage(); // Reload to become controlled. |
714 | 671 |
715 ASSERT_TRUE(RunScript("isControlled()", &script_result)); | 672 ASSERT_TRUE(RunScript("isControlled()", &script_result)); |
716 ASSERT_EQ("true - is controlled", script_result); | 673 ASSERT_EQ("true - is controlled", script_result); |
717 | 674 |
718 notification_manager()->CancelAll(); | 675 notification_manager()->CancelAll(); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
800 SendMessageAndWaitUntilHandled(app_identifier, message); | 757 SendMessageAndWaitUntilHandled(app_identifier, message); |
801 ASSERT_TRUE(RunScript("resultQueue.pop()", &script_result, web_contents)); | 758 ASSERT_TRUE(RunScript("resultQueue.pop()", &script_result, web_contents)); |
802 EXPECT_EQ("testdata", script_result); | 759 EXPECT_EQ("testdata", script_result); |
803 EXPECT_EQ(0u, notification_manager()->GetNotificationCount()); | 760 EXPECT_EQ(0u, notification_manager()->GetNotificationCount()); |
804 } | 761 } |
805 | 762 |
806 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, | 763 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
807 PushEventEnforcesUserVisibleNotificationAfterQueue) { | 764 PushEventEnforcesUserVisibleNotificationAfterQueue) { |
808 std::string script_result; | 765 std::string script_result; |
809 | 766 |
810 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); | 767 SubscribeSuccessfully(); |
811 | |
812 PushMessagingAppIdentifier app_identifier = | 768 PushMessagingAppIdentifier app_identifier = |
813 GetAppIdentifierForServiceWorkerRegistration(0LL); | 769 GetAppIdentifierForServiceWorkerRegistration(0LL); |
814 EXPECT_EQ(app_identifier.app_id(), gcm_service()->last_registered_app_id()); | |
815 EXPECT_EQ(getTestApplicationServerKey(), | |
816 gcm_service()->last_registered_sender_ids()[0]); | |
817 | 770 |
818 ASSERT_TRUE(RunScript("isControlled()", &script_result)); | 771 ASSERT_TRUE(RunScript("isControlled()", &script_result)); |
819 ASSERT_EQ("false - is not controlled", script_result); | 772 ASSERT_EQ("false - is not controlled", script_result); |
820 | 773 |
821 LoadTestPage(); // Reload to become controlled. | 774 LoadTestPage(); // Reload to become controlled. |
822 | 775 |
823 ASSERT_TRUE(RunScript("isControlled()", &script_result)); | 776 ASSERT_TRUE(RunScript("isControlled()", &script_result)); |
824 ASSERT_EQ("true - is controlled", script_result); | 777 ASSERT_EQ("true - is controlled", script_result); |
825 | 778 |
826 // Fire off two push messages in sequence, only the second one of which will | 779 // Fire off two push messages in sequence, only the second one of which will |
(...skipping 27 matching lines...) Expand all Loading... | |
854 EXPECT_EQ(0u, number_of_notifications_shown[0]); | 807 EXPECT_EQ(0u, number_of_notifications_shown[0]); |
855 EXPECT_EQ(1u, number_of_notifications_shown[1]); | 808 EXPECT_EQ(1u, number_of_notifications_shown[1]); |
856 } | 809 } |
857 | 810 |
858 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, | 811 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
859 PushEventNotificationWithoutEventWaitUntil) { | 812 PushEventNotificationWithoutEventWaitUntil) { |
860 std::string script_result; | 813 std::string script_result; |
861 content::WebContents* web_contents = | 814 content::WebContents* web_contents = |
862 GetBrowser()->tab_strip_model()->GetActiveWebContents(); | 815 GetBrowser()->tab_strip_model()->GetActiveWebContents(); |
863 | 816 |
864 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); | 817 SubscribeSuccessfully(); |
865 | |
866 PushMessagingAppIdentifier app_identifier = | 818 PushMessagingAppIdentifier app_identifier = |
867 GetAppIdentifierForServiceWorkerRegistration(0LL); | 819 GetAppIdentifierForServiceWorkerRegistration(0LL); |
868 EXPECT_EQ(app_identifier.app_id(), gcm_service()->last_registered_app_id()); | |
869 EXPECT_EQ(getTestApplicationServerKey(), | |
870 gcm_service()->last_registered_sender_ids()[0]); | |
871 | 820 |
872 ASSERT_TRUE(RunScript("isControlled()", &script_result)); | 821 ASSERT_TRUE(RunScript("isControlled()", &script_result)); |
873 ASSERT_EQ("false - is not controlled", script_result); | 822 ASSERT_EQ("false - is not controlled", script_result); |
874 | 823 |
875 LoadTestPage(); // Reload to become controlled. | 824 LoadTestPage(); // Reload to become controlled. |
876 | 825 |
877 ASSERT_TRUE(RunScript("isControlled()", &script_result)); | 826 ASSERT_TRUE(RunScript("isControlled()", &script_result)); |
878 ASSERT_EQ("true - is controlled", script_result); | 827 ASSERT_EQ("true - is controlled", script_result); |
879 | 828 |
880 scoped_refptr<content::MessageLoopRunner> message_loop_runner = | 829 scoped_refptr<content::MessageLoopRunner> message_loop_runner = |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
914 | 863 |
915 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PermissionStateSaysGranted) { | 864 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PermissionStateSaysGranted) { |
916 std::string script_result; | 865 std::string script_result; |
917 | 866 |
918 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 867 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
919 ASSERT_EQ("ok - service worker registered", script_result); | 868 ASSERT_EQ("ok - service worker registered", script_result); |
920 | 869 |
921 RequestAndAcceptPermission(); | 870 RequestAndAcceptPermission(); |
922 | 871 |
923 ASSERT_TRUE(RunScript("documentSubscribePush()", &script_result)); | 872 ASSERT_TRUE(RunScript("documentSubscribePush()", &script_result)); |
924 EXPECT_EQ(GetEndpointForSubscriptionId("1-0"), script_result); | 873 EndpointToToken(script_result); // EXPECTs that the conversion succeeds. |
925 | 874 |
926 ASSERT_TRUE(RunScript("permissionState()", &script_result)); | 875 ASSERT_TRUE(RunScript("permissionState()", &script_result)); |
927 EXPECT_EQ("permission status - granted", script_result); | 876 EXPECT_EQ("permission status - granted", script_result); |
928 } | 877 } |
929 | 878 |
930 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PermissionStateSaysDenied) { | 879 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PermissionStateSaysDenied) { |
931 std::string script_result; | 880 std::string script_result; |
932 | 881 |
933 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 882 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
934 ASSERT_EQ("ok - service worker registered", script_result); | 883 ASSERT_EQ("ok - service worker registered", script_result); |
935 | 884 |
936 RequestAndDenyPermission(); | 885 RequestAndDenyPermission(); |
937 | 886 |
938 ASSERT_TRUE(RunScript("documentSubscribePush()", &script_result)); | 887 ASSERT_TRUE(RunScript("documentSubscribePush()", &script_result)); |
939 EXPECT_EQ("PermissionDeniedError - Registration failed - permission denied", | 888 EXPECT_EQ("PermissionDeniedError - Registration failed - permission denied", |
940 script_result); | 889 script_result); |
941 | 890 |
942 ASSERT_TRUE(RunScript("permissionState()", &script_result)); | 891 ASSERT_TRUE(RunScript("permissionState()", &script_result)); |
943 EXPECT_EQ("permission status - denied", script_result); | 892 EXPECT_EQ("permission status - denied", script_result); |
944 } | 893 } |
945 | 894 |
946 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, UnsubscribeSuccess) { | 895 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, UnsubscribeSuccess) { |
947 std::string script_result; | 896 std::string script_result; |
948 | 897 |
949 EXPECT_TRUE(RunScript("registerServiceWorker()", &script_result)); | 898 EXPECT_TRUE(RunScript("registerServiceWorker()", &script_result)); |
950 EXPECT_EQ("ok - service worker registered", script_result); | 899 EXPECT_EQ("ok - service worker registered", script_result); |
951 | 900 |
952 // Resolves true if there was a subscription. | 901 // Resolves true if there was a subscription. |
953 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */, false); | 902 std::string token1 = SubscribeSuccessfully(false /* use_key */); |
954 gcm_service()->AddExpectedUnregisterResponse(gcm::GCMClient::SUCCESS); | |
955 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 903 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
956 EXPECT_EQ("unsubscribe result: true", script_result); | 904 EXPECT_EQ("unsubscribe result: true", script_result); |
957 | 905 |
958 // Resolves false if there was no longer a subscription. | 906 // Resolves false if there was no longer a subscription. |
959 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 907 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
960 EXPECT_EQ("unsubscribe result: false", script_result); | 908 EXPECT_EQ("unsubscribe result: false", script_result); |
961 | 909 |
962 // Doesn't reject if there was a network error (deactivates subscription | 910 // Doesn't reject if there was a network error (deactivates subscription |
963 // locally anyway). | 911 // locally anyway). |
964 TryToSubscribeSuccessfully("1-1" /* expected_push_subscription_id */, false); | 912 std::string token2 = SubscribeSuccessfully(false /* use_key */); |
965 gcm_service()->AddExpectedUnregisterResponse(gcm::GCMClient::NETWORK_ERROR); | 913 EXPECT_NE(token1, token2); |
914 // TODO(johnme): AddExpectedUnregisterResponse(gcm::GCMClient::NETWORK_ERROR); | |
966 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 915 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
967 EXPECT_EQ("unsubscribe result: true", script_result); | 916 EXPECT_EQ("unsubscribe result: true", script_result); |
968 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); | 917 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); |
969 EXPECT_EQ("false - not subscribed", script_result); | 918 EXPECT_EQ("false - not subscribed", script_result); |
970 | 919 |
971 // Doesn't reject if there were other push service errors (deactivates | 920 // Doesn't reject if there were other push service errors (deactivates |
972 // subscription locally anyway). | 921 // subscription locally anyway). |
973 TryToSubscribeSuccessfully("1-2" /* expected_push_subscription_id */, false); | 922 std::string token3 = SubscribeSuccessfully(false /* use_key */); |
974 gcm_service()->AddExpectedUnregisterResponse( | 923 EXPECT_NE(token1, token3); |
975 gcm::GCMClient::INVALID_PARAMETER); | 924 EXPECT_NE(token2, token3); |
925 // TODO(johnme): AddExpectedUnregisterResponse( | |
926 // gcm::GCMClient::INVALID_PARAMETER); | |
976 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 927 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
977 EXPECT_EQ("unsubscribe result: true", script_result); | 928 EXPECT_EQ("unsubscribe result: true", script_result); |
978 | 929 |
979 // Unsubscribing (with an existing reference to a PushSubscription), after | 930 // Unsubscribing (with an existing reference to a PushSubscription), after |
980 // unregistering the Service Worker, just means push subscription isn't found. | 931 // unregistering the Service Worker, just means push subscription isn't found. |
981 TryToSubscribeSuccessfully("1-3" /* expected_push_subscription_id */, false); | 932 std::string token4 = SubscribeSuccessfully(false /* use_key */); |
933 EXPECT_NE(token1, token4); | |
934 EXPECT_NE(token2, token4); | |
935 EXPECT_NE(token3, token4); | |
982 ASSERT_TRUE(RunScript("unregisterServiceWorker()", &script_result)); | 936 ASSERT_TRUE(RunScript("unregisterServiceWorker()", &script_result)); |
983 ASSERT_EQ("service worker unregistration status: true", script_result); | 937 ASSERT_EQ("service worker unregistration status: true", script_result); |
984 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 938 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
985 EXPECT_EQ("unsubscribe result: false", script_result); | 939 EXPECT_EQ("unsubscribe result: false", script_result); |
986 } | 940 } |
987 | 941 |
988 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, | 942 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
989 GlobalResetPushPermissionUnsubscribes) { | 943 GlobalResetPushPermissionUnsubscribes) { |
990 std::string script_result; | 944 std::string script_result; |
991 | 945 |
992 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); | 946 SubscribeSuccessfully(); |
993 | 947 |
994 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); | 948 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); |
995 EXPECT_EQ("true - subscribed", script_result); | 949 EXPECT_EQ("true - subscribed", script_result); |
996 | 950 |
997 ASSERT_TRUE(RunScript("permissionState()", &script_result)); | 951 ASSERT_TRUE(RunScript("permissionState()", &script_result)); |
998 EXPECT_EQ("permission status - granted", script_result); | 952 EXPECT_EQ("permission status - granted", script_result); |
999 | 953 |
1000 scoped_refptr<content::MessageLoopRunner> message_loop_runner = | 954 scoped_refptr<content::MessageLoopRunner> message_loop_runner = |
1001 new content::MessageLoopRunner; | 955 new content::MessageLoopRunner; |
1002 push_service()->SetContentSettingChangedCallbackForTesting( | 956 push_service()->SetContentSettingChangedCallbackForTesting( |
(...skipping 11 matching lines...) Expand all Loading... | |
1014 EXPECT_EQ("permission status - prompt", script_result); | 968 EXPECT_EQ("permission status - prompt", script_result); |
1015 | 969 |
1016 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); | 970 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); |
1017 EXPECT_EQ("false - not subscribed", script_result); | 971 EXPECT_EQ("false - not subscribed", script_result); |
1018 } | 972 } |
1019 | 973 |
1020 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, | 974 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
1021 LocalResetPushPermissionUnsubscribes) { | 975 LocalResetPushPermissionUnsubscribes) { |
1022 std::string script_result; | 976 std::string script_result; |
1023 | 977 |
1024 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); | 978 SubscribeSuccessfully(); |
1025 | 979 |
1026 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); | 980 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); |
1027 EXPECT_EQ("true - subscribed", script_result); | 981 EXPECT_EQ("true - subscribed", script_result); |
1028 | 982 |
1029 ASSERT_TRUE(RunScript("permissionState()", &script_result)); | 983 ASSERT_TRUE(RunScript("permissionState()", &script_result)); |
1030 EXPECT_EQ("permission status - granted", script_result); | 984 EXPECT_EQ("permission status - granted", script_result); |
1031 | 985 |
1032 scoped_refptr<content::MessageLoopRunner> message_loop_runner = | 986 scoped_refptr<content::MessageLoopRunner> message_loop_runner = |
1033 new content::MessageLoopRunner; | 987 new content::MessageLoopRunner; |
1034 push_service()->SetContentSettingChangedCallbackForTesting( | 988 push_service()->SetContentSettingChangedCallbackForTesting( |
(...skipping 15 matching lines...) Expand all Loading... | |
1050 EXPECT_EQ("permission status - prompt", script_result); | 1004 EXPECT_EQ("permission status - prompt", script_result); |
1051 | 1005 |
1052 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); | 1006 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); |
1053 EXPECT_EQ("false - not subscribed", script_result); | 1007 EXPECT_EQ("false - not subscribed", script_result); |
1054 } | 1008 } |
1055 | 1009 |
1056 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, | 1010 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
1057 DenyPushPermissionUnsubscribes) { | 1011 DenyPushPermissionUnsubscribes) { |
1058 std::string script_result; | 1012 std::string script_result; |
1059 | 1013 |
1060 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); | 1014 SubscribeSuccessfully(); |
1061 | 1015 |
1062 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); | 1016 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); |
1063 EXPECT_EQ("true - subscribed", script_result); | 1017 EXPECT_EQ("true - subscribed", script_result); |
1064 | 1018 |
1065 ASSERT_TRUE(RunScript("permissionState()", &script_result)); | 1019 ASSERT_TRUE(RunScript("permissionState()", &script_result)); |
1066 EXPECT_EQ("permission status - granted", script_result); | 1020 EXPECT_EQ("permission status - granted", script_result); |
1067 | 1021 |
1068 scoped_refptr<content::MessageLoopRunner> message_loop_runner = | 1022 scoped_refptr<content::MessageLoopRunner> message_loop_runner = |
1069 new content::MessageLoopRunner; | 1023 new content::MessageLoopRunner; |
1070 push_service()->SetContentSettingChangedCallbackForTesting( | 1024 push_service()->SetContentSettingChangedCallbackForTesting( |
(...skipping 11 matching lines...) Expand all Loading... | |
1082 EXPECT_EQ("permission status - denied", script_result); | 1036 EXPECT_EQ("permission status - denied", script_result); |
1083 | 1037 |
1084 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); | 1038 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); |
1085 EXPECT_EQ("false - not subscribed", script_result); | 1039 EXPECT_EQ("false - not subscribed", script_result); |
1086 } | 1040 } |
1087 | 1041 |
1088 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, | 1042 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
1089 GlobalResetNotificationsPermissionUnsubscribes) { | 1043 GlobalResetNotificationsPermissionUnsubscribes) { |
1090 std::string script_result; | 1044 std::string script_result; |
1091 | 1045 |
1092 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); | 1046 SubscribeSuccessfully(); |
1093 | 1047 |
1094 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); | 1048 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); |
1095 EXPECT_EQ("true - subscribed", script_result); | 1049 EXPECT_EQ("true - subscribed", script_result); |
1096 | 1050 |
1097 ASSERT_TRUE(RunScript("permissionState()", &script_result)); | 1051 ASSERT_TRUE(RunScript("permissionState()", &script_result)); |
1098 EXPECT_EQ("permission status - granted", script_result); | 1052 EXPECT_EQ("permission status - granted", script_result); |
1099 | 1053 |
1100 scoped_refptr<content::MessageLoopRunner> message_loop_runner = | 1054 scoped_refptr<content::MessageLoopRunner> message_loop_runner = |
1101 new content::MessageLoopRunner; | 1055 new content::MessageLoopRunner; |
1102 push_service()->SetContentSettingChangedCallbackForTesting( | 1056 push_service()->SetContentSettingChangedCallbackForTesting( |
1103 message_loop_runner->QuitClosure()); | 1057 message_loop_runner->QuitClosure()); |
1104 | 1058 |
1105 HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile()) | 1059 HostContentSettingsMapFactory::GetForProfile(GetBrowser()->profile()) |
1106 ->ClearSettingsForOneType(CONTENT_SETTINGS_TYPE_NOTIFICATIONS); | 1060 ->ClearSettingsForOneType(CONTENT_SETTINGS_TYPE_NOTIFICATIONS); |
1107 | 1061 |
1108 message_loop_runner->Run(); | 1062 message_loop_runner->Run(); |
1109 | 1063 |
1110 ASSERT_TRUE(RunScript("permissionState()", &script_result)); | 1064 ASSERT_TRUE(RunScript("permissionState()", &script_result)); |
1111 EXPECT_EQ("permission status - prompt", script_result); | 1065 EXPECT_EQ("permission status - prompt", script_result); |
1112 | 1066 |
1113 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); | 1067 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); |
1114 EXPECT_EQ("false - not subscribed", script_result); | 1068 EXPECT_EQ("false - not subscribed", script_result); |
1115 } | 1069 } |
1116 | 1070 |
1117 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, | 1071 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
1118 LocalResetNotificationsPermissionUnsubscribes) { | 1072 LocalResetNotificationsPermissionUnsubscribes) { |
1119 std::string script_result; | 1073 std::string script_result; |
1120 | 1074 |
1121 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); | 1075 SubscribeSuccessfully(); |
1122 | 1076 |
1123 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); | 1077 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); |
1124 EXPECT_EQ("true - subscribed", script_result); | 1078 EXPECT_EQ("true - subscribed", script_result); |
1125 | 1079 |
1126 ASSERT_TRUE(RunScript("permissionState()", &script_result)); | 1080 ASSERT_TRUE(RunScript("permissionState()", &script_result)); |
1127 EXPECT_EQ("permission status - granted", script_result); | 1081 EXPECT_EQ("permission status - granted", script_result); |
1128 | 1082 |
1129 scoped_refptr<content::MessageLoopRunner> message_loop_runner = | 1083 scoped_refptr<content::MessageLoopRunner> message_loop_runner = |
1130 new content::MessageLoopRunner; | 1084 new content::MessageLoopRunner; |
1131 push_service()->SetContentSettingChangedCallbackForTesting( | 1085 push_service()->SetContentSettingChangedCallbackForTesting( |
(...skipping 11 matching lines...) Expand all Loading... | |
1143 EXPECT_EQ("permission status - prompt", script_result); | 1097 EXPECT_EQ("permission status - prompt", script_result); |
1144 | 1098 |
1145 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); | 1099 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); |
1146 EXPECT_EQ("false - not subscribed", script_result); | 1100 EXPECT_EQ("false - not subscribed", script_result); |
1147 } | 1101 } |
1148 | 1102 |
1149 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, | 1103 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
1150 DenyNotificationsPermissionUnsubscribes) { | 1104 DenyNotificationsPermissionUnsubscribes) { |
1151 std::string script_result; | 1105 std::string script_result; |
1152 | 1106 |
1153 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); | 1107 SubscribeSuccessfully(); |
1154 | 1108 |
1155 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); | 1109 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); |
1156 EXPECT_EQ("true - subscribed", script_result); | 1110 EXPECT_EQ("true - subscribed", script_result); |
1157 | 1111 |
1158 ASSERT_TRUE(RunScript("permissionState()", &script_result)); | 1112 ASSERT_TRUE(RunScript("permissionState()", &script_result)); |
1159 EXPECT_EQ("permission status - granted", script_result); | 1113 EXPECT_EQ("permission status - granted", script_result); |
1160 | 1114 |
1161 scoped_refptr<content::MessageLoopRunner> message_loop_runner = | 1115 scoped_refptr<content::MessageLoopRunner> message_loop_runner = |
1162 new content::MessageLoopRunner; | 1116 new content::MessageLoopRunner; |
1163 push_service()->SetContentSettingChangedCallbackForTesting( | 1117 push_service()->SetContentSettingChangedCallbackForTesting( |
(...skipping 11 matching lines...) Expand all Loading... | |
1175 EXPECT_EQ("permission status - denied", script_result); | 1129 EXPECT_EQ("permission status - denied", script_result); |
1176 | 1130 |
1177 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); | 1131 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); |
1178 EXPECT_EQ("false - not subscribed", script_result); | 1132 EXPECT_EQ("false - not subscribed", script_result); |
1179 } | 1133 } |
1180 | 1134 |
1181 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, | 1135 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
1182 GrantAlreadyGrantedPermissionDoesNotUnsubscribe) { | 1136 GrantAlreadyGrantedPermissionDoesNotUnsubscribe) { |
1183 std::string script_result; | 1137 std::string script_result; |
1184 | 1138 |
1185 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); | 1139 SubscribeSuccessfully(); |
1186 | 1140 |
1187 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); | 1141 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); |
1188 EXPECT_EQ("true - subscribed", script_result); | 1142 EXPECT_EQ("true - subscribed", script_result); |
1189 | 1143 |
1190 ASSERT_TRUE(RunScript("permissionState()", &script_result)); | 1144 ASSERT_TRUE(RunScript("permissionState()", &script_result)); |
1191 EXPECT_EQ("permission status - granted", script_result); | 1145 EXPECT_EQ("permission status - granted", script_result); |
1192 | 1146 |
1193 scoped_refptr<content::MessageLoopRunner> message_loop_runner = | 1147 scoped_refptr<content::MessageLoopRunner> message_loop_runner = |
1194 new content::MessageLoopRunner; | 1148 new content::MessageLoopRunner; |
1195 push_service()->SetContentSettingChangedCallbackForTesting( | 1149 push_service()->SetContentSettingChangedCallbackForTesting( |
(...skipping 19 matching lines...) Expand all Loading... | |
1215 } | 1169 } |
1216 | 1170 |
1217 // This test is testing some non-trivial content settings rules and make sure | 1171 // This test is testing some non-trivial content settings rules and make sure |
1218 // that they are respected with regards to automatic unsubscription. In other | 1172 // that they are respected with regards to automatic unsubscription. In other |
1219 // words, it checks that the push service does not end up unsubscribing origins | 1173 // words, it checks that the push service does not end up unsubscribing origins |
1220 // that have push permission with some non-common rules. | 1174 // that have push permission with some non-common rules. |
1221 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, | 1175 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
1222 AutomaticUnsubscriptionFollowsContentSettingRules) { | 1176 AutomaticUnsubscriptionFollowsContentSettingRules) { |
1223 std::string script_result; | 1177 std::string script_result; |
1224 | 1178 |
1225 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); | 1179 SubscribeSuccessfully(); |
1226 | 1180 |
1227 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); | 1181 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); |
1228 EXPECT_EQ("true - subscribed", script_result); | 1182 EXPECT_EQ("true - subscribed", script_result); |
1229 | 1183 |
1230 ASSERT_TRUE(RunScript("permissionState()", &script_result)); | 1184 ASSERT_TRUE(RunScript("permissionState()", &script_result)); |
1231 EXPECT_EQ("permission status - granted", script_result); | 1185 EXPECT_EQ("permission status - granted", script_result); |
1232 | 1186 |
1233 scoped_refptr<content::MessageLoopRunner> message_loop_runner = | 1187 scoped_refptr<content::MessageLoopRunner> message_loop_runner = |
1234 new content::MessageLoopRunner; | 1188 new content::MessageLoopRunner; |
1235 push_service()->SetContentSettingChangedCallbackForTesting( | 1189 push_service()->SetContentSettingChangedCallbackForTesting( |
(...skipping 26 matching lines...) Expand all Loading... | |
1262 // The Push service should not unsubcribe |origin| because at no point it was | 1216 // The Push service should not unsubcribe |origin| because at no point it was |
1263 // left without permission to use Push. | 1217 // left without permission to use Push. |
1264 | 1218 |
1265 ASSERT_TRUE(RunScript("permissionState()", &script_result)); | 1219 ASSERT_TRUE(RunScript("permissionState()", &script_result)); |
1266 EXPECT_EQ("permission status - granted", script_result); | 1220 EXPECT_EQ("permission status - granted", script_result); |
1267 | 1221 |
1268 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); | 1222 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); |
1269 EXPECT_EQ("true - subscribed", script_result); | 1223 EXPECT_EQ("true - subscribed", script_result); |
1270 } | 1224 } |
1271 | 1225 |
1272 // Checks that automatically unsubscribing due to a revoked permission is | 1226 // Checks automatically unsubscribing due to a revoked permission after |
1273 // handled well if the sender ID needed to unsubscribe was already deleted. | 1227 // previously clearing site data. |
1274 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, | 1228 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
1275 ResetPushPermissionAfterClearingSiteData) { | 1229 ResetPushPermissionAfterClearingSiteData) { |
1276 std::string script_result; | 1230 std::string script_result; |
1277 | 1231 |
1278 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); | 1232 SubscribeSuccessfully(); |
1279 | 1233 |
1280 PushMessagingAppIdentifier app_identifier = | 1234 PushMessagingAppIdentifier app_identifier = |
1281 GetAppIdentifierForServiceWorkerRegistration(0LL); | 1235 GetAppIdentifierForServiceWorkerRegistration(0LL); |
1282 EXPECT_EQ(app_identifier.app_id(), gcm_service()->last_registered_app_id()); | |
1283 PushMessagingAppIdentifier stored_app_identifier = | 1236 PushMessagingAppIdentifier stored_app_identifier = |
1284 PushMessagingAppIdentifier::FindByAppId(GetBrowser()->profile(), | 1237 PushMessagingAppIdentifier::FindByAppId(GetBrowser()->profile(), |
1285 app_identifier.app_id()); | 1238 app_identifier.app_id()); |
1286 EXPECT_FALSE(stored_app_identifier.is_null()); | 1239 EXPECT_FALSE(stored_app_identifier.is_null()); |
1287 | 1240 |
1288 // Simulate a user clearing site data (including Service Workers, crucially). | 1241 // Simulate a user clearing site data (including Service Workers, crucially). |
1289 BrowsingDataRemover* remover = | 1242 BrowsingDataRemover* remover = |
1290 BrowsingDataRemoverFactory::GetForBrowserContext(GetBrowser()->profile()); | 1243 BrowsingDataRemoverFactory::GetForBrowserContext(GetBrowser()->profile()); |
1291 BrowsingDataRemoverCompletionObserver observer(remover); | 1244 BrowsingDataRemoverCompletionObserver observer(remover); |
1292 remover->Remove(BrowsingDataRemover::Unbounded(), | 1245 remover->Remove(BrowsingDataRemover::Unbounded(), |
(...skipping 16 matching lines...) Expand all Loading... | |
1309 run_loop.Run(); | 1262 run_loop.Run(); |
1310 | 1263 |
1311 // |app_identifier| should no longer be stored in prefs. | 1264 // |app_identifier| should no longer be stored in prefs. |
1312 PushMessagingAppIdentifier stored_app_identifier2 = | 1265 PushMessagingAppIdentifier stored_app_identifier2 = |
1313 PushMessagingAppIdentifier::FindByAppId(GetBrowser()->profile(), | 1266 PushMessagingAppIdentifier::FindByAppId(GetBrowser()->profile(), |
1314 app_identifier.app_id()); | 1267 app_identifier.app_id()); |
1315 EXPECT_TRUE(stored_app_identifier2.is_null()); | 1268 EXPECT_TRUE(stored_app_identifier2.is_null()); |
1316 } | 1269 } |
1317 | 1270 |
1318 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, EncryptionKeyUniqueness) { | 1271 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, EncryptionKeyUniqueness) { |
1319 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */, false); | 1272 std::string token1 = SubscribeSuccessfully(false /* use_key */); |
1320 | 1273 |
1321 std::string first_public_key; | 1274 std::string first_public_key; |
1322 ASSERT_TRUE(RunScript("GetP256dh()", &first_public_key)); | 1275 ASSERT_TRUE(RunScript("GetP256dh()", &first_public_key)); |
1323 EXPECT_GE(first_public_key.size(), 32u); | 1276 EXPECT_GE(first_public_key.size(), 32u); |
1324 | 1277 |
1325 std::string script_result; | 1278 std::string script_result; |
1326 gcm_service()->AddExpectedUnregisterResponse(gcm::GCMClient::SUCCESS); | |
1327 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 1279 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
1328 EXPECT_EQ("unsubscribe result: true", script_result); | 1280 EXPECT_EQ("unsubscribe result: true", script_result); |
1329 | 1281 |
1330 TryToSubscribeSuccessfully("1-1" /* expected_push_subscription_id */); | 1282 std::string token2 = SubscribeSuccessfully(); |
1283 EXPECT_NE(token1, token2); | |
1331 | 1284 |
1332 std::string second_public_key; | 1285 std::string second_public_key; |
1333 ASSERT_TRUE(RunScript("GetP256dh()", &second_public_key)); | 1286 ASSERT_TRUE(RunScript("GetP256dh()", &second_public_key)); |
1334 EXPECT_GE(second_public_key.size(), 32u); | 1287 EXPECT_GE(second_public_key.size(), 32u); |
1335 | 1288 |
1336 EXPECT_NE(first_public_key, second_public_key); | 1289 EXPECT_NE(first_public_key, second_public_key); |
1337 } | 1290 } |
1338 | 1291 |
1339 class PushMessagingIncognitoBrowserTest : public PushMessagingBrowserTest { | 1292 class PushMessagingIncognitoBrowserTest : public PushMessagingBrowserTest { |
1340 public: | 1293 public: |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1372 #if BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) | 1325 #if BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) |
1373 // Push background mode is disabled by default. | 1326 // Push background mode is disabled by default. |
1374 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, | 1327 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, |
1375 BackgroundModeDisabledByDefault) { | 1328 BackgroundModeDisabledByDefault) { |
1376 // Initially background mode is inactive. | 1329 // Initially background mode is inactive. |
1377 BackgroundModeManager* background_mode_manager = | 1330 BackgroundModeManager* background_mode_manager = |
1378 g_browser_process->background_mode_manager(); | 1331 g_browser_process->background_mode_manager(); |
1379 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 1332 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
1380 | 1333 |
1381 // Once there is a push subscription background mode is still inactive. | 1334 // Once there is a push subscription background mode is still inactive. |
1382 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); | 1335 SubscribeSuccessfully(); |
1383 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 1336 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
1384 | 1337 |
1385 // After dropping the last subscription it is still inactive. | 1338 // After dropping the last subscription it is still inactive. |
1386 std::string script_result; | 1339 std::string script_result; |
1387 gcm_service()->AddExpectedUnregisterResponse(gcm::GCMClient::SUCCESS); | |
1388 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 1340 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
1389 EXPECT_EQ("unsubscribe result: true", script_result); | 1341 EXPECT_EQ("unsubscribe result: true", script_result); |
1390 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 1342 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
1391 } | 1343 } |
1392 | 1344 |
1393 class PushMessagingBackgroundModeEnabledBrowserTest | 1345 class PushMessagingBackgroundModeEnabledBrowserTest |
1394 : public PushMessagingBrowserTest { | 1346 : public PushMessagingBrowserTest { |
1395 public: | 1347 public: |
1396 ~PushMessagingBackgroundModeEnabledBrowserTest() override {} | 1348 ~PushMessagingBackgroundModeEnabledBrowserTest() override {} |
1397 | 1349 |
1398 // PushMessagingBrowserTest: | 1350 // PushMessagingBrowserTest: |
1399 void SetUpCommandLine(base::CommandLine* command_line) override { | 1351 void SetUpCommandLine(base::CommandLine* command_line) override { |
1400 command_line->AppendSwitch(switches::kEnablePushApiBackgroundMode); | 1352 command_line->AppendSwitch(switches::kEnablePushApiBackgroundMode); |
1401 PushMessagingBrowserTest::SetUpCommandLine(command_line); | 1353 PushMessagingBrowserTest::SetUpCommandLine(command_line); |
1402 } | 1354 } |
1403 }; | 1355 }; |
1404 | 1356 |
1405 // In this test the command line enables push background mode. | 1357 // In this test the command line enables push background mode. |
1406 IN_PROC_BROWSER_TEST_F(PushMessagingBackgroundModeEnabledBrowserTest, | 1358 IN_PROC_BROWSER_TEST_F(PushMessagingBackgroundModeEnabledBrowserTest, |
1407 BackgroundModeEnabledWithCommandLine) { | 1359 BackgroundModeEnabledWithCommandLine) { |
1408 // Initially background mode is inactive. | 1360 // Initially background mode is inactive. |
1409 BackgroundModeManager* background_mode_manager = | 1361 BackgroundModeManager* background_mode_manager = |
1410 g_browser_process->background_mode_manager(); | 1362 g_browser_process->background_mode_manager(); |
1411 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 1363 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
1412 | 1364 |
1413 // Once there is a push subscription background mode is active. | 1365 // Once there is a push subscription background mode is active. |
1414 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); | 1366 SubscribeSuccessfully(); |
1415 ASSERT_TRUE(background_mode_manager->IsBackgroundModeActive()); | 1367 ASSERT_TRUE(background_mode_manager->IsBackgroundModeActive()); |
1416 | 1368 |
1417 // Dropping the last subscription deactivates background mode. | 1369 // Dropping the last subscription deactivates background mode. |
1418 std::string script_result; | 1370 std::string script_result; |
1419 gcm_service()->AddExpectedUnregisterResponse(gcm::GCMClient::SUCCESS); | |
1420 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 1371 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
1421 EXPECT_EQ("unsubscribe result: true", script_result); | 1372 EXPECT_EQ("unsubscribe result: true", script_result); |
1422 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 1373 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
1423 } | 1374 } |
1424 | 1375 |
1425 class PushMessagingBackgroundModeDisabledBrowserTest | 1376 class PushMessagingBackgroundModeDisabledBrowserTest |
1426 : public PushMessagingBrowserTest { | 1377 : public PushMessagingBrowserTest { |
1427 public: | 1378 public: |
1428 ~PushMessagingBackgroundModeDisabledBrowserTest() override {} | 1379 ~PushMessagingBackgroundModeDisabledBrowserTest() override {} |
1429 | 1380 |
1430 // PushMessagingBrowserTest: | 1381 // PushMessagingBrowserTest: |
1431 void SetUpCommandLine(base::CommandLine* command_line) override { | 1382 void SetUpCommandLine(base::CommandLine* command_line) override { |
1432 command_line->AppendSwitch(switches::kDisablePushApiBackgroundMode); | 1383 command_line->AppendSwitch(switches::kDisablePushApiBackgroundMode); |
1433 PushMessagingBrowserTest::SetUpCommandLine(command_line); | 1384 PushMessagingBrowserTest::SetUpCommandLine(command_line); |
1434 } | 1385 } |
1435 }; | 1386 }; |
1436 | 1387 |
1437 // In this test the command line disables push background mode. | 1388 // In this test the command line disables push background mode. |
1438 IN_PROC_BROWSER_TEST_F(PushMessagingBackgroundModeDisabledBrowserTest, | 1389 IN_PROC_BROWSER_TEST_F(PushMessagingBackgroundModeDisabledBrowserTest, |
1439 BackgroundModeDisabledWithCommandLine) { | 1390 BackgroundModeDisabledWithCommandLine) { |
1440 // Initially background mode is inactive. | 1391 // Initially background mode is inactive. |
1441 BackgroundModeManager* background_mode_manager = | 1392 BackgroundModeManager* background_mode_manager = |
1442 g_browser_process->background_mode_manager(); | 1393 g_browser_process->background_mode_manager(); |
1443 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 1394 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
1444 | 1395 |
1445 // Once there is a push subscription background mode is still inactive. | 1396 // Once there is a push subscription background mode is still inactive. |
1446 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); | 1397 SubscribeSuccessfully(); |
1447 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 1398 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
1448 | 1399 |
1449 // After dropping the last subscription background mode is still inactive. | 1400 // After dropping the last subscription background mode is still inactive. |
1450 std::string script_result; | 1401 std::string script_result; |
1451 gcm_service()->AddExpectedUnregisterResponse(gcm::GCMClient::SUCCESS); | |
1452 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); | 1402 ASSERT_TRUE(RunScript("unsubscribePush()", &script_result)); |
1453 EXPECT_EQ("unsubscribe result: true", script_result); | 1403 EXPECT_EQ("unsubscribe result: true", script_result); |
1454 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); | 1404 ASSERT_FALSE(background_mode_manager->IsBackgroundModeActive()); |
1455 } | 1405 } |
1456 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) | 1406 #endif // BUILDFLAG(ENABLE_BACKGROUND) && !defined(OS_CHROMEOS) |
OLD | NEW |