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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/background_sync/oneshot.html

Issue 1437883002: [Background Sync] Align exposed API with spec (Closed) Base URL: https://chromium.googlesource.com/chromium/src@remove-periodic
Patch Set: Rebase Created 5 years, 1 month 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
1 <!doctype html> 1 <!doctype html>
2 <meta charset="utf-8"> 2 <meta charset="utf-8">
3 <title>Background Sync API: Verifies that the one-shot sync API works 3 <title>Background Sync API: Verifies that the one-shot sync API works
4 correctly.</title> 4 correctly.</title>
5 <script src="../resources/testharness.js"></script> 5 <script src="../resources/testharness.js"></script>
6 <script src="../resources/testharness-helpers.js"></script> 6 <script src="../resources/testharness-helpers.js"></script>
7 <script src="../resources/testharnessreport.js"></script> 7 <script src="../resources/testharnessreport.js"></script>
8 <script src="../serviceworker/resources/test-helpers.js"></script> 8 <script src="../serviceworker/resources/test-helpers.js"></script>
9 <script src="resources/test-helpers.js"></script>
10 <script> 9 <script>
11 10
12 promise_test(function(t) { 11 promise_test(function(t) {
13 var url = 'resources/empty_worker.js'; 12 var url = 'resources/empty_worker.js';
14 var scope = 'resources/scope/background_sync/oneshot.html'; 13 var scope = 'resources/scope/background_sync/oneshot.html';
15 var sync_manager; 14 var sync_manager;
16 var sync_registration; 15 var sync_registration;
17 16
18 // One-shot syncs can only be registered from a controlled document. This 17 // This test verifies that one-shot syncs can be registered from service-
19 // test creates a frame, after the service worker is active, in order to use 18 // worker-controlled documents. It creates a frame, after the service worker
20 // its service worker registration. 19 // is active, in order to use its service worker registration.
21 return service_worker_unregister_and_register(t, url, scope) 20 return service_worker_unregister_and_register(t, url, scope)
22 .then(function(sw_registration_page) { 21 .then(function(sw_registration_page) {
23 return wait_for_state(t, sw_registration_page.installing, 'activated'); 22 return wait_for_state(t, sw_registration_page.installing, 'activated');
24 }) 23 })
25 .then(function() { 24 .then(function() {
26 return with_iframe(scope) 25 return with_iframe(scope)
27 }) 26 })
28 .then(function(frame) { 27 .then(function(frame) {
29 var w = frame.contentWindow; 28 var w = frame.contentWindow;
30 return w.navigator.serviceWorker.getRegistration(scope); 29 return w.navigator.serviceWorker.getRegistration(scope);
31 }) 30 })
32 .then(function(sw_registration_frame) { 31 .then(function(sw_registration_frame) {
33 sync_manager = sw_registration_frame.sync; 32 sync_manager = sw_registration_frame.sync;
34 return clear_registered_syncs(sync_manager); 33 return sync_manager.getTags();
35 }) 34 })
36 .then(function() { return sync_manager.getRegistrations(); }) 35 .then(function(tags) {
37 .then(function(registrations) { 36 assert_equals(tags.length, 0, 'One-shot syncs should be ' +
38 assert_equals(registrations.length, 0, 'One-shot syncs should be ' +
39 'cleared at the start of the test.'); 37 'cleared at the start of the test.');
40 return sync_manager.register({tag: 'abcde'}); 38 return sync_manager.register('abcde');
41 }) 39 })
42 .then(function(registration) { 40 .then(function() {
43 sync_registration = registration;
44 assert_class_string(sync_registration, 'SyncRegistration', 'One-' +
45 'shot sync registrations should have the correct ' +
46 'class name.');
47 assert_equals('abcde', registration.tag, 'Sync registration tag ' +
48 'returned should match the tag registered.');
49 return service_worker_unregister(t, scope); 41 return service_worker_unregister(t, scope);
50 }); 42 });
51 }, 'Background Sync API should allow one-shot syncs to be registered from ' + 43 }, 'Background Sync API should allow one-shot syncs to be registered from ' +
52 'the Document scope'); 44 'the Document scope');
53 45
54 promise_test(function(t) { 46 promise_test(function(t) {
55 var url = 'resources/empty_worker.js'; 47 var url = 'resources/empty_worker.js';
56 var scope = 'resources/scope/background_sync/oneshot-uncontrolled.html'; 48 var scope = 'resources/scope/background_sync/oneshot-uncontrolled.html';
57 var sync_manager; 49 var sync_manager;
58 var sync_registration; 50 var sync_registration;
59 51
60 // One-shot syncs can also be registered from uncontrolled documents. This 52 // This test verifies that one-shot syncs can be registered from uncontrolled
61 // test creates a frame, after the service worker is active, in order to use 53 // documents.
62 // its service worker registration.
63 return service_worker_unregister_and_register(t, url, scope) 54 return service_worker_unregister_and_register(t, url, scope)
64 .then(function(sw_registration) { 55 .then(function(sw_registration) {
65 sync_manager = sw_registration.sync; 56 sync_manager = sw_registration.sync;
66 return wait_for_state(t, sw_registration.installing, 'activated'); 57 return wait_for_state(t, sw_registration.installing, 'activated');
67 }) 58 })
68 .then(function() { return clear_registered_syncs(sync_manager); }) 59 .then(function() { return sync_manager.getTags(); })
69 .then(function() { return sync_manager.getRegistrations(); }) 60 .then(function(tags) {
70 .then(function(registrations) { 61 assert_equals(tags.length, 0, 'One-shot syncs should be ' +
71 assert_equals(registrations.length, 0, 'One-shot syncs should be ' +
72 'cleared at the start of the test.'); 62 'cleared at the start of the test.');
73 return sync_manager.register({tag: 'abcde'}); 63 return sync_manager.register('abcde');
74 }) 64 })
75 .then(function(registration) { 65 .then(function() {
76 sync_registration = registration;
77 assert_class_string(sync_registration, 'SyncRegistration', 'One-' +
78 'shot sync registrations should have the correct ' +
79 'class name.');
80 assert_equals('abcde', registration.tag, 'Sync registration tag ' +
81 'returned should match the tag registered.');
82 return service_worker_unregister(t, scope); 66 return service_worker_unregister(t, scope);
83 }) 67 })
84 .then(function() { return service_worker_unregister(t, scope); })
85 }, 'Background Sync API should allow one-shot syncs to be registered ' + 68 }, 'Background Sync API should allow one-shot syncs to be registered ' +
86 'with window clients not currently controlled by service worker'); 69 'with window clients not currently controlled by service worker');
87 </script> 70 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698