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

Side by Side Diff: LayoutTests/http/tests/background_sync/namespaces.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 unified diff | Download patch
OLDNEW
(Empty)
1 <!doctype html>
2 <html>
3 <head>
4 <title>Background Sync API: Verifies that the one-shot and periodic sync API s don't share a tag namespace.</title>
5 <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
6 <script src="../resources/testharnessreport.js"></script>
7 <script src="../serviceworker/resources/test-helpers.js"></script>
8 </head>
9 <body>
10 <script>
11 // Tests that one-shot and periodic syncs exist in isolated tag namespaces
12
13 function clearRegisteredSyncs(sync_manager) {
14 return sync_manager.getRegistrations().then(function(registrations) {
15 // Clear them all out
16 var promises = [];
17 for (registration of registrations) {
18 promises.push(registration.unregister());
19 }
20 return Promise.all(promises);
21 });
22 }
23
24 function clearAllSyncs(serviceworker_registration) {
25 return Promise.all([
26 clearRegisteredSyncs(serviceworker_registration.sync),
27 clearRegisteredSyncs(serviceworker_registration.periodicSync)
28 ]);
29 }
30
31 async_test(function(t) {
32 var sw_registration;
33 var oneshot_sync_manager;
34 var periodic_sync_manager;
35
36 service_worker_unregister_and_register(t, 'resources/empty_worker.js', 'resources/scope/background_sync/oneshot.html').then(function(swreg) {
37 sw_registration = swreg;
38 oneshot_sync_manager = swreg.sync;
39 periodic_sync_manager = swreg.periodicSync;
40 return wait_for_state(t, swreg.installing, 'activated');
41 }).then(function() {
42 return clearAllSyncs(sw_registration);
43 }).then(function() {
44 // Register a new one
45 return oneshot_sync_manager.register({tag: "abcde"});
46 }).then(function() {
47 return oneshot_sync_manager.getRegistrations();
48 }).then(function(registrations) {
49 assert_equals(1, registrations.length);
50 }).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.
51 return periodic_sync_manager.getRegistrations();
52 }).then(function(registrations) {
53 assert_equals(0, registrations.length);
54 }).then(function() {
55 t.done();
56 }).catch(unreached_rejection(t));
57 }, 'Registering a one-shot sync should not cause a periodic sync to appear .');
58
59 async_test(function(t) {
60 var sw_registration;
61 var oneshot_sync_manager;
62 var periodic_sync_manager;
63
64 service_worker_unregister_and_register(t, 'resources/empty_worker.js', 'resources/scope/background_sync/oneshot_periodic').then(function(swreg) {
65 sw_registration = swreg;
66 oneshot_sync_manager = swreg.sync;
67 periodic_sync_manager = swreg.periodicSync;
68 return wait_for_state(t, swreg.installing, 'activated');
69 }).then(function() {
70 return clearAllSyncs(sw_registration);
71 }).then(function() {
72 // Register a new one
73 return periodic_sync_manager.register({tag: "abcde"});
74 }).then(function() {
75 return periodic_sync_manager.getRegistrations();
76 }).then(function(registrations) {
77 assert_equals(1, registrations.length);
78 }).then(function() {
79 return oneshot_sync_manager.getRegistrations();
80 }).then(function(registrations) {
81 assert_equals(0, registrations.length);
82 }).then(function() {
83 t.done();
84 }).catch(unreached_rejection(t));
85 }, 'Registering a periodic sync should not cause a one-shot sync to appear .');
86 /*
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
87 async_test(function(t) {
88 var sw_registration;
89 var oneshot_sync_manager;
90 var periodic_sync_manager;
91
92 service_worker_unregister_and_register(t, 'resources/empty_worker.js', 'resources/scope/background_sync/oneshot.html').then(function(swreg) {
93 sw_registration = swreg;
94 oneshot_sync_manager = swreg.sync;
95 periodic_sync_manager = swreg.periodicSync;
96 return wait_for_state(t, swreg.installing, 'activated');
97 }).then(function() {
98 return clearAllSyncs(sw_registration);
99 }).then(function() {
100 // Register two new syncs
101 return Promise.all([
102 oneshot_sync_manager.register({tag: "abcde"}),
103 periodic_sync_manager.register({tag: "abcde"})
104 ]);
105 }).then(function() {
106 return oneshot_sync_manager.getRegistrations();
107 }).then(function(registrations) {
108 assert_equals(1, registrations.length);
109 }).then(function() {
110 return periodic_sync_manager.getRegistrations();
111 }).then(function(registrations) {
112 assert_equals(1, registrations.length);
113 }).then(function() {
114 return oneshot_sync_manager.getRegistration("abcde");
115 }).then(function(registration) {
116 return registration.unregister();
117 }).then(function() {
118 return periodic_sync_manager.getRegistrations();
119 }).then(function(registrations) {
120 assert_equals(1, registrations.length);
121 }).then(function() {
122 t.done();
123 }).catch(unreached_rejection(t));
124 }, 'Unegistering a one-shot sync should not cause a periodic sync to disap pear.');
125 */
126 </script>
127 </body>
128 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/http/tests/background_sync/oneshot.html » ('j') | Source/modules/background_sync/PeriodicSyncEvent.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698