Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Unified Diff: LayoutTests/http/tests/background_sync/oneshot.html

Issue 1096503002: [Background Sync] Converting Blink code to the MVP API (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Make sure ids are 64 bit; fix formatting anomaly Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/http/tests/background_sync/oneshot.html
diff --git a/LayoutTests/http/tests/background_sync/oneshot.html b/LayoutTests/http/tests/background_sync/oneshot.html
new file mode 100644
index 0000000000000000000000000000000000000000..62058eca17e64b3aaf0dc85e1cdc2ed9411246f0
--- /dev/null
+++ b/LayoutTests/http/tests/background_sync/oneshot.html
@@ -0,0 +1,59 @@
+<!doctype html>
+<html>
+ <head>
+ <title>Background Sync API: Verifies that the one-shot sync API works correctly.</title>
+ <script src="../resources/testharness.js"></script>
+ <script src="../resources/testharnessreport.js"></script>
+ <script src="../serviceworker/resources/test-helpers.js"></script>
+ </head>
+ <body>
+ <script>
+ // Tests that the Background Sync One-Shot API works as expected from the
+ // Document scope
+ async_test(function(t) {
+ var sync_manager;
+ var sync_registration;
+
+ service_worker_unregister_and_register(t, 'resources/empty_worker.js', 'resources/scope/background_sync/oneshot.html').then(function(swreg) {
+ sync_manager = swreg.sync;
+ return wait_for_state(t, swreg.installing, 'activated');
+ }).then(function() {
+ // Get any existing registrations
+ 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);
+ }).then(function() {
+ // Ensure that there are none left
+ return sync_manager.getRegistrations();
+ }).then(function(registrations) {
+ assert_equals(registrations.length, 0);
+ }).then(function() {
+ // Register a new one
+ return sync_manager.register({tag: "abcde"});
+ }).then(function(registration) {
+ sync_registration = registration;
+ assert_class_string(sync_registration, 'SyncRegistration');
+ assert_equals("abcde", registration.tag);
+ return sync_manager.getRegistrations();
+ }).then(function(registrations) {
+ assert_equals(1, registrations.length);
+ }).then(function() {
+ // Unregister it
+ return sync_registration.unregister();
+ }).then(function() {
+ // Ensure that they are all gone
+ return sync_manager.getRegistrations();
+ }).then(function(registrations) {
+ assert_equals(0, registrations.length);
+ }).then(function() {
+ t.done();
+ }).catch(unreached_rejection(t));
+ }, 'SyncManager should be allow one-shot syncs to be registered and unregistered.');
+ </script>
+ </body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698