Chromium Code Reviews| Index: LayoutTests/http/tests/background_sync/namespaces.html |
| diff --git a/LayoutTests/http/tests/background_sync/namespaces.html b/LayoutTests/http/tests/background_sync/namespaces.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9df918b1908b8957a14ea390263360e7fef08979 |
| --- /dev/null |
| +++ b/LayoutTests/http/tests/background_sync/namespaces.html |
| @@ -0,0 +1,128 @@ |
| +<!doctype html> |
| +<html> |
| + <head> |
| + <title>Background Sync API: Verifies that the one-shot and periodic sync APIs don't share a tag namespace.</title> |
| + <script src="../resources/testharness.js"></script> |
|
jkarlin
2015/04/17 19:04:49
I see a pretty large style difference between this
jsbell
2015/04/17 19:22:04
While we don't have a unified standard for blink l
iclelland
2015/04/22 14:05:10
Done. -- I've removed all of the boilerplate, move
|
| + <script src="../resources/testharnessreport.js"></script> |
| + <script src="../serviceworker/resources/test-helpers.js"></script> |
| + </head> |
| + <body> |
| + <script> |
| + // Tests that one-shot and periodic syncs exist in isolated tag namespaces |
| + |
| + function clearRegisteredSyncs(sync_manager) { |
| + return sync_manager.getRegistrations().then(function(registrations) { |
| + // Clear them all out |
| + var promises = []; |
| + for (registration of registrations) { |
| + promises.push(registration.unregister()); |
| + } |
| + return Promise.all(promises); |
| + }); |
| + } |
| + |
| + function clearAllSyncs(serviceworker_registration) { |
| + return Promise.all([ |
| + clearRegisteredSyncs(serviceworker_registration.sync), |
| + clearRegisteredSyncs(serviceworker_registration.periodicSync) |
| + ]); |
| + } |
| + |
| + async_test(function(t) { |
| + var sw_registration; |
| + var oneshot_sync_manager; |
| + var periodic_sync_manager; |
| + |
| + service_worker_unregister_and_register(t, 'resources/empty_worker.js', 'resources/scope/background_sync/oneshot.html').then(function(swreg) { |
| + sw_registration = swreg; |
| + oneshot_sync_manager = swreg.sync; |
| + periodic_sync_manager = swreg.periodicSync; |
| + return wait_for_state(t, swreg.installing, 'activated'); |
| + }).then(function() { |
| + return clearAllSyncs(sw_registration); |
| + }).then(function() { |
| + // Register a new one |
| + return oneshot_sync_manager.register({tag: "abcde"}); |
| + }).then(function() { |
| + return oneshot_sync_manager.getRegistrations(); |
| + }).then(function(registrations) { |
| + assert_equals(1, registrations.length); |
| + }).then(function() { |
|
jsbell
2015/04/17 19:22:04
Personally, I'd eliminate this line i.e. merge two
iclelland
2015/04/22 14:05:10
Done.
|
| + return periodic_sync_manager.getRegistrations(); |
| + }).then(function(registrations) { |
| + assert_equals(0, registrations.length); |
| + }).then(function() { |
| + t.done(); |
| + }).catch(unreached_rejection(t)); |
| + }, 'Registering a one-shot sync should not cause a periodic sync to appear.'); |
| + |
| + async_test(function(t) { |
| + var sw_registration; |
| + var oneshot_sync_manager; |
| + var periodic_sync_manager; |
| + |
| + service_worker_unregister_and_register(t, 'resources/empty_worker.js', 'resources/scope/background_sync/oneshot_periodic').then(function(swreg) { |
| + sw_registration = swreg; |
| + oneshot_sync_manager = swreg.sync; |
| + periodic_sync_manager = swreg.periodicSync; |
| + return wait_for_state(t, swreg.installing, 'activated'); |
| + }).then(function() { |
| + return clearAllSyncs(sw_registration); |
| + }).then(function() { |
| + // Register a new one |
| + return periodic_sync_manager.register({tag: "abcde"}); |
| + }).then(function() { |
| + return periodic_sync_manager.getRegistrations(); |
| + }).then(function(registrations) { |
| + assert_equals(1, registrations.length); |
| + }).then(function() { |
| + return oneshot_sync_manager.getRegistrations(); |
| + }).then(function(registrations) { |
| + assert_equals(0, registrations.length); |
| + }).then(function() { |
| + t.done(); |
| + }).catch(unreached_rejection(t)); |
| + }, 'Registering a periodic sync should not cause a one-shot sync to appear.'); |
| +/* |
|
jkarlin
2015/04/17 19:04:49
Remove commented section
iclelland
2015/04/22 14:05:10
I've removed the comment markers and reinstated th
iclelland
2015/04/22 14:05:10
I've removed the comments -- the test itself is ac
|
| + async_test(function(t) { |
| + var sw_registration; |
| + var oneshot_sync_manager; |
| + var periodic_sync_manager; |
| + |
| + service_worker_unregister_and_register(t, 'resources/empty_worker.js', 'resources/scope/background_sync/oneshot.html').then(function(swreg) { |
| + sw_registration = swreg; |
| + oneshot_sync_manager = swreg.sync; |
| + periodic_sync_manager = swreg.periodicSync; |
| + return wait_for_state(t, swreg.installing, 'activated'); |
| + }).then(function() { |
| + return clearAllSyncs(sw_registration); |
| + }).then(function() { |
| + // Register two new syncs |
| + return Promise.all([ |
| + oneshot_sync_manager.register({tag: "abcde"}), |
| + periodic_sync_manager.register({tag: "abcde"}) |
| + ]); |
| + }).then(function() { |
| + return oneshot_sync_manager.getRegistrations(); |
| + }).then(function(registrations) { |
| + assert_equals(1, registrations.length); |
| + }).then(function() { |
| + return periodic_sync_manager.getRegistrations(); |
| + }).then(function(registrations) { |
| + assert_equals(1, registrations.length); |
| + }).then(function() { |
| + return oneshot_sync_manager.getRegistration("abcde"); |
| + }).then(function(registration) { |
| + return registration.unregister(); |
| + }).then(function() { |
| + return periodic_sync_manager.getRegistrations(); |
| + }).then(function(registrations) { |
| + assert_equals(1, registrations.length); |
| + }).then(function() { |
| + t.done(); |
| + }).catch(unreached_rejection(t)); |
| + }, 'Unegistering a one-shot sync should not cause a periodic sync to disappear.'); |
| +*/ |
| + </script> |
| + </body> |
| +</html> |