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

Side by Side Diff: LayoutTests/http/tests/serviceworker/unregister.html

Issue 362123003: ServiceWorker: unregister's scope argument should be optional (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Reformated test Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script> 2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script> 3 <script src="../resources/testharnessreport.js"></script>
4 <script src="resources/test-helpers.js"></script>
4 <script> 5 <script>
5 (function() { 6 async_test(function(t) {
6 var t = async_test('Unregistering out of origin'); 7 navigator.serviceWorker.unregister('http://example.com/*')
7 navigator.serviceWorker.unregister('http://example.com/*').then( 8 .then(function() {
8 t.step_func(function() { 9 assert_unreached('unregistering out of origin should fail');
9 assert_unreached('unregistering out of origin should fail'); 10 }, function(reason) {
10 }), 11 assert_equals(reason.name, 'SecurityError',
11 t.step_func(function(reason) { 12 'unregistering out of origin scope should fail');
12 assert_equals(reason.name, 'SecurityError', 13 t.done();
13 'unregistering out of origins should fail'); 14 })
14 t.done(); 15 .catch(unreached_rejection(t));
15 })); 16 }, 'Unregistering out of origin');
16 }());
17 17
18 (function() { 18 async_test(function(t) {
19 var t = async_test('Unregistering with no existing registration'); 19 navigator.serviceWorker.unregister('/nothing-here/*')
20 navigator.serviceWorker.unregister('/nothing-here/*').then( 20 .then(function(value) {
21 t.step_func(function(value) { 21 assert_equals(value, undefined,
22 assert_equals(value, undefined, 22 'unregistering with no existing registration should ' +
23 'unregistering with no existing registration ' + 23 'succeed with no value');
24 'should succeed with no value'); 24 t.done();
25 t.done(); 25 })
26 }), 26 .catch(unreached_rejection(t));
27 t.step_func(function(reason) { 27 }, 'Unregistering with no existing registration');
28 assert_unreached('unregistering with no existing registration ' +
29 'should not fail: ' + reason.name);
30 }));
31 }());
32 28
33 (function() { 29 async_test(function(t) {
34 var scope = '/register-then-unregister/*'; 30 var scope = '/register-then-unregister/*';
31 navigator.serviceWorker.register(
32 'resources/empty-worker.js', {scope: scope})
33 .then(function(worker) {
34 return navigator.serviceWorker.unregister(scope);
35 })
36 .then(function(value) {
37 assert_equals(value, undefined,
38 'successful unregistration should succeed with no value');
39 t.done();
40 })
41 .catch(unreached_rejection(t));
42 }, 'Register then unregister');
35 43
36 var t = async_test('Register then unregister'); 44 async_test(function(t) {
37 navigator.serviceWorker.register( 45 var state_promise;
38 'resources/empty-worker.js', 46 service_worker_unregister_and_register(t, 'resources/empty-worker.js')
39 { scope: scope } 47 .then(function(sw) {
40 ).then( 48 state_promise = wait_for_state(t, sw, 'redundant');
41 function(worker) { 49 return navigator.serviceWorker.unregister();
42 return navigator.serviceWorker.unregister(scope); 50 })
43 }, 51 .then(function(value) {
44 t.step_func(function(reason) { 52 assert_equals(value, undefined,
45 assert_unreached('registration should succeed.'); 53 'unregister with default scope should succeed');
46 }) 54 return state_promise;
47 ).then( 55 })
48 function(value) { 56 .then(function(state) {
49 assert_equals(value, undefined, 57 assert_equals(state, 'redundant',
50 'successful unregistration should succeed ' + 58 'service worker registered with default scope should be ' +
51 'with no value'); 59 'unregstered');
52 t.done(); 60 t.done();
53 }, 61 })
54 t.step_func(function(reason) { 62 .catch(unreached_rejection(t));
55 assert_unreached('unregistration should succeed.'); 63 }, 'Unregistering with default scope');
56 }) 64
57 );
58 }());
59 </script> 65 </script>
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/serviceworker/resources/test-helpers.js ('k') | Source/modules/serviceworkers/ServiceWorkerContainer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698