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/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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/http/tests/serviceworker/unregister.html
diff --git a/LayoutTests/http/tests/serviceworker/unregister.html b/LayoutTests/http/tests/serviceworker/unregister.html
index 29e312ed50cfd38efdf6bc20399de44b8aac1f77..760a8b739378798f4b9909dd4ddcb51cd6f55be4 100644
--- a/LayoutTests/http/tests/serviceworker/unregister.html
+++ b/LayoutTests/http/tests/serviceworker/unregister.html
@@ -1,59 +1,65 @@
<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
+<script src="resources/test-helpers.js"></script>
<script>
-(function() {
- var t = async_test('Unregistering out of origin');
- navigator.serviceWorker.unregister('http://example.com/*').then(
- t.step_func(function() {
- assert_unreached('unregistering out of origin should fail');
- }),
- t.step_func(function(reason) {
- assert_equals(reason.name, 'SecurityError',
- 'unregistering out of origins should fail');
- t.done();
- }));
-}());
+async_test(function(t) {
+ navigator.serviceWorker.unregister('http://example.com/*')
+ .then(function() {
+ assert_unreached('unregistering out of origin should fail');
+ }, function(reason) {
+ assert_equals(reason.name, 'SecurityError',
+ 'unregistering out of origin scope should fail');
+ t.done();
+ })
+ .catch(unreached_rejection(t));
+}, 'Unregistering out of origin');
-(function() {
- var t = async_test('Unregistering with no existing registration');
- navigator.serviceWorker.unregister('/nothing-here/*').then(
- t.step_func(function(value) {
- assert_equals(value, undefined,
- 'unregistering with no existing registration ' +
- 'should succeed with no value');
- t.done();
- }),
- t.step_func(function(reason) {
- assert_unreached('unregistering with no existing registration ' +
- 'should not fail: ' + reason.name);
- }));
-}());
+async_test(function(t) {
+ navigator.serviceWorker.unregister('/nothing-here/*')
+ .then(function(value) {
+ assert_equals(value, undefined,
+ 'unregistering with no existing registration should ' +
+ 'succeed with no value');
+ t.done();
+ })
+ .catch(unreached_rejection(t));
+}, 'Unregistering with no existing registration');
-(function() {
- var scope = '/register-then-unregister/*';
+async_test(function(t) {
+ var scope = '/register-then-unregister/*';
+ navigator.serviceWorker.register(
+ 'resources/empty-worker.js', {scope: scope})
+ .then(function(worker) {
+ return navigator.serviceWorker.unregister(scope);
+ })
+ .then(function(value) {
+ assert_equals(value, undefined,
+ 'successful unregistration should succeed with no value');
+ t.done();
+ })
+ .catch(unreached_rejection(t));
+}, 'Register then unregister');
+
+async_test(function(t) {
+ var state_promise;
+ service_worker_unregister_and_register(t, 'resources/empty-worker.js')
+ .then(function(sw) {
+ state_promise = wait_for_state(t, sw, 'redundant');
+ return navigator.serviceWorker.unregister();
+ })
+ .then(function(value) {
+ assert_equals(value, undefined,
+ 'unregister with default scope should succeed');
+ return state_promise;
+ })
+ .then(function(state) {
+ assert_equals(state, 'redundant',
+ 'service worker registered with default scope should be ' +
+ 'unregstered');
+ t.done();
+ })
+ .catch(unreached_rejection(t));
+}, 'Unregistering with default scope');
- var t = async_test('Register then unregister');
- navigator.serviceWorker.register(
- 'resources/empty-worker.js',
- { scope: scope }
- ).then(
- function(worker) {
- return navigator.serviceWorker.unregister(scope);
- },
- t.step_func(function(reason) {
- assert_unreached('registration should succeed.');
- })
- ).then(
- function(value) {
- assert_equals(value, undefined,
- 'successful unregistration should succeed ' +
- 'with no value');
- t.done();
- },
- t.step_func(function(reason) {
- assert_unreached('unregistration should succeed.');
- })
- );
-}());
</script>
« 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