OLD | NEW |
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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, RegisterSucceeds) { | 247 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, RegisterSucceeds) { |
248 StartTestFromBackgroundPage("register.js", kExpectSuccess); | 248 StartTestFromBackgroundPage("register.js", kExpectSuccess); |
249 } | 249 } |
250 | 250 |
251 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, UpdateRefreshesServiceWorker) { | 251 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, UpdateRefreshesServiceWorker) { |
252 base::ScopedTempDir scoped_temp_dir; | 252 base::ScopedTempDir scoped_temp_dir; |
253 ASSERT_TRUE(scoped_temp_dir.CreateUniqueTempDir()); | 253 ASSERT_TRUE(scoped_temp_dir.CreateUniqueTempDir()); |
254 base::FilePath pem_path = test_data_dir_.AppendASCII("service_worker") | 254 base::FilePath pem_path = test_data_dir_.AppendASCII("service_worker") |
255 .AppendASCII("update") | 255 .AppendASCII("update") |
256 .AppendASCII("service_worker.pem"); | 256 .AppendASCII("service_worker.pem"); |
257 base::FilePath path_v1 = PackExtensionWithOptions( | 257 base::FilePath path_v1 = |
258 test_data_dir_.AppendASCII("service_worker") | 258 PackExtensionWithOptions(test_data_dir_.AppendASCII("service_worker") |
259 .AppendASCII("update") | 259 .AppendASCII("update") |
260 .AppendASCII("v1"), | 260 .AppendASCII("v1"), |
261 scoped_temp_dir.path().AppendASCII("v1.crx"), pem_path, base::FilePath()); | 261 scoped_temp_dir.GetPath().AppendASCII("v1.crx"), |
262 base::FilePath path_v2 = PackExtensionWithOptions( | 262 pem_path, base::FilePath()); |
263 test_data_dir_.AppendASCII("service_worker") | 263 base::FilePath path_v2 = |
264 .AppendASCII("update") | 264 PackExtensionWithOptions(test_data_dir_.AppendASCII("service_worker") |
265 .AppendASCII("v2"), | 265 .AppendASCII("update") |
266 scoped_temp_dir.path().AppendASCII("v2.crx"), pem_path, base::FilePath()); | 266 .AppendASCII("v2"), |
| 267 scoped_temp_dir.GetPath().AppendASCII("v2.crx"), |
| 268 pem_path, base::FilePath()); |
267 const char* kId = "hfaanndiiilofhfokeanhddpkfffchdi"; | 269 const char* kId = "hfaanndiiilofhfokeanhddpkfffchdi"; |
268 | 270 |
269 ExtensionTestMessageListener listener_v1("Pong from version 1", false); | 271 ExtensionTestMessageListener listener_v1("Pong from version 1", false); |
270 listener_v1.set_failure_message("FAILURE_V1"); | 272 listener_v1.set_failure_message("FAILURE_V1"); |
271 // Install version 1.0 of the extension. | 273 // Install version 1.0 of the extension. |
272 ASSERT_TRUE(InstallExtension(path_v1, 1)); | 274 ASSERT_TRUE(InstallExtension(path_v1, 1)); |
273 EXPECT_TRUE(extensions::ExtensionRegistry::Get(profile()) | 275 EXPECT_TRUE(extensions::ExtensionRegistry::Get(profile()) |
274 ->enabled_extensions() | 276 ->enabled_extensions() |
275 .GetByID(kId)); | 277 .GetByID(kId)); |
276 EXPECT_TRUE(listener_v1.WaitUntilSatisfied()); | 278 EXPECT_TRUE(listener_v1.WaitUntilSatisfied()); |
277 | 279 |
278 ExtensionTestMessageListener listener_v2("Pong from version 2", false); | 280 ExtensionTestMessageListener listener_v2("Pong from version 2", false); |
279 listener_v2.set_failure_message("FAILURE_V2"); | 281 listener_v2.set_failure_message("FAILURE_V2"); |
280 | 282 |
281 // Update to version 2.0. | 283 // Update to version 2.0. |
282 EXPECT_TRUE(UpdateExtension(kId, path_v2, 0)); | 284 EXPECT_TRUE(UpdateExtension(kId, path_v2, 0)); |
283 EXPECT_TRUE(extensions::ExtensionRegistry::Get(profile()) | 285 EXPECT_TRUE(extensions::ExtensionRegistry::Get(profile()) |
284 ->enabled_extensions() | 286 ->enabled_extensions() |
285 .GetByID(kId)); | 287 .GetByID(kId)); |
286 EXPECT_TRUE(listener_v2.WaitUntilSatisfied()); | 288 EXPECT_TRUE(listener_v2.WaitUntilSatisfied()); |
287 } | 289 } |
288 | 290 |
289 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, UpdateWithoutSkipWaiting) { | 291 IN_PROC_BROWSER_TEST_F(ServiceWorkerTest, UpdateWithoutSkipWaiting) { |
290 base::ScopedTempDir scoped_temp_dir; | 292 base::ScopedTempDir scoped_temp_dir; |
291 ASSERT_TRUE(scoped_temp_dir.CreateUniqueTempDir()); | 293 ASSERT_TRUE(scoped_temp_dir.CreateUniqueTempDir()); |
292 base::FilePath pem_path = test_data_dir_.AppendASCII("service_worker") | 294 base::FilePath pem_path = test_data_dir_.AppendASCII("service_worker") |
293 .AppendASCII("update_without_skip_waiting") | 295 .AppendASCII("update_without_skip_waiting") |
294 .AppendASCII("update_without_skip_waiting.pem"); | 296 .AppendASCII("update_without_skip_waiting.pem"); |
295 base::FilePath path_v1 = PackExtensionWithOptions( | 297 base::FilePath path_v1 = |
296 test_data_dir_.AppendASCII("service_worker") | 298 PackExtensionWithOptions(test_data_dir_.AppendASCII("service_worker") |
297 .AppendASCII("update_without_skip_waiting") | 299 .AppendASCII("update_without_skip_waiting") |
298 .AppendASCII("v1"), | 300 .AppendASCII("v1"), |
299 scoped_temp_dir.path().AppendASCII("v1.crx"), pem_path, base::FilePath()); | 301 scoped_temp_dir.GetPath().AppendASCII("v1.crx"), |
300 base::FilePath path_v2 = PackExtensionWithOptions( | 302 pem_path, base::FilePath()); |
301 test_data_dir_.AppendASCII("service_worker") | 303 base::FilePath path_v2 = |
302 .AppendASCII("update_without_skip_waiting") | 304 PackExtensionWithOptions(test_data_dir_.AppendASCII("service_worker") |
303 .AppendASCII("v2"), | 305 .AppendASCII("update_without_skip_waiting") |
304 scoped_temp_dir.path().AppendASCII("v2.crx"), pem_path, base::FilePath()); | 306 .AppendASCII("v2"), |
| 307 scoped_temp_dir.GetPath().AppendASCII("v2.crx"), |
| 308 pem_path, base::FilePath()); |
305 const char* kId = "mhnnnflgagdakldgjpfcofkiocpdmogl"; | 309 const char* kId = "mhnnnflgagdakldgjpfcofkiocpdmogl"; |
306 | 310 |
307 // Install version 1.0 of the extension. | 311 // Install version 1.0 of the extension. |
308 ASSERT_TRUE(InstallExtension(path_v1, 1)); | 312 ASSERT_TRUE(InstallExtension(path_v1, 1)); |
309 EXPECT_TRUE(extensions::ExtensionRegistry::Get(profile()) | 313 EXPECT_TRUE(extensions::ExtensionRegistry::Get(profile()) |
310 ->enabled_extensions() | 314 ->enabled_extensions() |
311 .GetByID(kId)); | 315 .GetByID(kId)); |
312 const Extension* extension = extensions::ExtensionRegistry::Get(profile()) | 316 const Extension* extension = extensions::ExtensionRegistry::Get(profile()) |
313 ->enabled_extensions() | 317 ->enabled_extensions() |
314 .GetByID(kId); | 318 .GetByID(kId); |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 message.sender_id = "1234567890"; | 777 message.sender_id = "1234567890"; |
774 message.raw_data = "testdata"; | 778 message.raw_data = "testdata"; |
775 message.decrypted = true; | 779 message.decrypted = true; |
776 push_service()->SetMessageCallbackForTesting(run_loop.QuitClosure()); | 780 push_service()->SetMessageCallbackForTesting(run_loop.QuitClosure()); |
777 push_service()->OnMessage(app_identifier.app_id(), message); | 781 push_service()->OnMessage(app_identifier.app_id(), message); |
778 EXPECT_TRUE(push_message_listener.WaitUntilSatisfied()); | 782 EXPECT_TRUE(push_message_listener.WaitUntilSatisfied()); |
779 run_loop.Run(); // Wait until the message is handled by push service. | 783 run_loop.Run(); // Wait until the message is handled by push service. |
780 } | 784 } |
781 | 785 |
782 } // namespace extensions | 786 } // namespace extensions |
OLD | NEW |