Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/ready.https.html |
| diff --git a/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/ready.https.html b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/ready.https.html |
| index ee6a97ca8fc96c449734814b5c3a767c34c43a9d..d5b699037767ee19fbaf8a30bcd0f42cc094ea5e 100644 |
| --- a/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/ready.https.html |
| +++ b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/ready.https.html |
| @@ -12,31 +12,39 @@ test(function() { |
| 'registrations should return the same Promise object'); |
| }, 'ready returns the same Promise object'); |
| -async_test(function(t) { |
| - with_iframe('resources/blank.html?uncontrolled') |
| +promise_test(function(t) { |
| + return with_iframe('resources/blank.html?uncontrolled') |
| .then(t.step_func(function(frame) { |
| var promise = frame.contentWindow.navigator.serviceWorker.ready; |
| + t.add_cleanup(function() { |
| + frame.remove(); |
| + }); |
| + |
| assert_equals(Object.getPrototypeOf(promise), |
| frame.contentWindow.Promise.prototype, |
| 'the Promise should be in the context of the ' + |
| 'related document'); |
| - frame.remove(); |
| - t.done(); |
| })); |
| }, 'ready returns a Promise object in the context of the related document'); |
| -async_test(function(t) { |
| +promise_test(function(t) { |
| var url = 'resources/empty-worker.js'; |
| var scope = 'resources/blank.html?ready-controlled'; |
| var expected_url = normalizeURL(url); |
| var frame; |
| - service_worker_unregister_and_register(t, url, scope) |
| + return service_worker_unregister_and_register(t, url, scope) |
| .then(function(registration) { |
| + add_completion_callback(function() { |
| + registration.unregister(); |
| + }); |
| return wait_for_state(t, registration.installing, 'activated'); |
| }) |
| .then(function() { return with_iframe(scope); }) |
| .then(function(f) { |
| + t.add_cleanup(function() { |
| + f.remove(); |
| + }); |
| frame = f; |
| return frame.contentWindow.navigator.serviceWorker.ready; |
| }) |
| @@ -51,25 +59,31 @@ async_test(function(t) { |
| frame.contentWindow.navigator.serviceWorker.controller.scriptURL, |
| expected_url, |
| 'controlled document should have a controller'); |
|
falken
2017/05/15 05:48:59
I think now the spec intends to require JS equalit
mike3
2017/05/15 19:48:26
I'm not so sure about this. The spec language rega
-jakearchibald-
2017/05/15 20:44:56
I agree that the spec wording isn't great, but equ
mike3
2017/05/15 21:48:27
Thanks, Jake! I've updated the patch to replace th
|
| - |
| - frame.remove(); |
| - service_worker_unregister_and_done(t, scope); |
| - }) |
| - .catch(unreached_rejection(t)); |
| + assert_in_array(registration.active.state, |
| + ['activating', 'activated'], |
| + '.ready should be resolved when the registration ' + |
| + 'has an active worker'); |
| + }); |
| }, 'ready on a controlled document'); |
| -async_test(function(t) { |
| +promise_test(function(t) { |
| var url = 'resources/empty-worker.js'; |
| var scope = 'resources/blank.html?ready-potential-controlled'; |
| var expected_url = normalizeURL(url); |
| var frame; |
| - with_iframe(scope) |
| + return with_iframe(scope) |
| .then(function(f) { |
| + t.add_cleanup(function() { |
| + f.remove(); |
| + }); |
| frame = f; |
| return navigator.serviceWorker.register(url, {scope:scope}); |
| }) |
| - .then(function() { |
| + .then(function(r) { |
| + add_completion_callback(function() { |
| + r.unregister(); |
| + }); |
| return frame.contentWindow.navigator.serviceWorker.ready; |
| }) |
| .then(function(registration) { |
| @@ -79,32 +93,99 @@ async_test(function(t) { |
| 'waiting should be null.') |
| assert_equals(registration.active.scriptURL, expected_url, |
| 'active after ready should not be null'); |
| + assert_in_array(registration.active.state, |
| + ['activating', 'activated'], |
| + '.ready should be resolved when the registration ' + |
| + 'has an active worker'); |
| assert_equals(frame.contentWindow.navigator.serviceWorker.controller, |
| null, |
| 'uncontrolled document should not have a controller'); |
| + }); |
| + }, 'ready on a potential controlled document'); |
| + |
| +promise_test(function(t) { |
| + var url = 'resources/empty-worker.js'; |
| + var scope = 'resources/blank.html?ready-installing'; |
| - frame.remove(); |
| - service_worker_unregister_and_done(t, scope); |
| + return service_worker_unregister(t, scope) |
| + .then(function() { |
| + return with_iframe(scope); |
| }) |
| - .catch(unreached_rejection(t)); |
| - }, 'ready on a potential controlled document'); |
| + .then(function(f) { |
| + var promise = f.contentWindow.navigator.serviceWorker.ready; |
| + t.add_cleanup(function() { |
| + f.remove(); |
| + }); |
| + navigator.serviceWorker.register(url, {scope: scope}); |
| + return promise; |
| + }) |
| + .then(function(registration) { |
| + add_completion_callback(function() { |
| + registration.unregister(); |
| + }); |
| + |
| + assert_equals(registration.installing, null, |
| + 'installing should be null'); |
| + assert_equals(registration.waiting, null, 'waiting should be null'); |
| + assert_not_equals(registration.active, null, |
| + 'active after ready should not be null'); |
| + assert_in_array(registration.active.state, |
| + ['activating', 'activated'], |
| + '.ready should be resolved when the registration ' + |
| + 'has an active worker'); |
| + }); |
| + }, 'ready on an iframe whose parent registers a new service worker'); |
| + |
| +promise_test(function(t) { |
| + var url = 'resources/empty-worker.js'; |
| + var scope = 'resources/register-iframe.html'; |
| + var expected_url = normalizeURL(url); |
| -async_test(function(t) { |
| + return with_iframe(scope) |
| + .then(function(f) { |
| + t.add_cleanup(function() { |
| + f.remove(); |
| + }); |
| + return f.contentWindow.navigator.serviceWorker.ready; |
| + }) |
| + .then(function(registration) { |
| + add_completion_callback(function() { |
| + registration.unregister(); |
| + }); |
| + |
| + assert_equals(registration.installing, null, |
| + 'installing should be null'); |
| + assert_equals(registration.waiting, null, 'waiting should be null'); |
| + assert_not_equals(registration.active, null, |
| + 'active after ready should not be null'); |
| + assert_in_array(registration.active.state, |
| + ['activating', 'activated'], |
| + '.ready should be resolved with "active worker"'); |
| + }); |
| + }, 'ready on an iframe with installing a new service worker by itself'); |
|
falken
2017/05/15 05:48:59
"with installing" -> "that installs" and remove "b
mike3
2017/05/15 19:48:26
Done.
|
| + |
| +promise_test(function(t) { |
| var url = 'resources/empty-worker.js'; |
| var matched_scope = 'resources/blank.html?ready-after-match'; |
| var longer_matched_scope = 'resources/blank.html?ready-after-match-longer'; |
| var frame, registration; |
| - Promise.all([service_worker_unregister(t, matched_scope), |
| - service_worker_unregister(t, longer_matched_scope)]) |
| + return Promise.all([service_worker_unregister(t, matched_scope), |
| + service_worker_unregister(t, longer_matched_scope)]) |
| .then(function() { |
| return with_iframe(longer_matched_scope); |
| }) |
| .then(function(f) { |
| + t.add_cleanup(function() { |
| + f.remove(); |
| + }); |
| frame = f; |
| return navigator.serviceWorker.register(url, {scope: matched_scope}); |
| }) |
| .then(function(r) { |
| + add_completion_callback(function() { |
| + r.unregister(); |
| + }); |
| registration = r; |
| return wait_for_state(t, r.installing, 'activated'); |
| }) |
| @@ -112,7 +193,10 @@ async_test(function(t) { |
| return navigator.serviceWorker.register( |
| url, {scope: longer_matched_scope}); |
| }) |
| - .then(function() { |
| + .then(function(r) { |
| + add_completion_callback(function() { |
| + r.unregister(); |
| + }); |
| return frame.contentWindow.navigator.serviceWorker.ready; |
| }) |
| .then(function(r) { |
| @@ -120,24 +204,21 @@ async_test(function(t) { |
| 'longer matched registration should be returned'); |
| assert_equals(frame.contentWindow.navigator.serviceWorker.controller, |
| null, 'controller should be null'); |
| - return registration.unregister(); |
| - }) |
| - .then(function() { |
| - frame.remove(); |
| - return service_worker_unregister_and_done(t, longer_matched_scope); |
| - }) |
| - .catch(unreached_rejection(t)); |
| + }); |
| }, 'ready after a longer matched registration registered'); |
| -async_test(function(t) { |
| +promise_test(function(t) { |
| var url = 'resources/empty-worker.js'; |
| var matched_scope = 'resources/blank.html?ready-after-resolve'; |
| var longer_matched_scope = |
| 'resources/blank.html?ready-after-resolve-longer'; |
| var frame, registration; |
| - service_worker_unregister_and_register(t, url, matched_scope) |
| + return service_worker_unregister_and_register(t, url, matched_scope) |
| .then(function(r) { |
| + add_completion_callback(function() { |
| + r.unregister(); |
| + }); |
| registration = r; |
| return wait_for_state(t, r.installing, 'activated'); |
| }) |
| @@ -145,6 +226,9 @@ async_test(function(t) { |
| return with_iframe(longer_matched_scope); |
| }) |
| .then(function(f) { |
| + t.add_cleanup(function() { |
| + f.remove(); |
| + }); |
| frame = f; |
| return f.contentWindow.navigator.serviceWorker.ready; |
| }) |
| @@ -154,19 +238,15 @@ async_test(function(t) { |
| return navigator.serviceWorker.register( |
| url, {scope: longer_matched_scope}); |
| }) |
| - .then(function() { |
| + .then(function(r) { |
| + add_completion_callback(function() { |
| + r.unregister(); |
| + }); |
| return frame.contentWindow.navigator.serviceWorker.ready; |
| }) |
| .then(function(r) { |
| assert_equals(r.scope, normalizeURL(matched_scope), |
| 'ready should only be resolved once'); |
| - return registration.unregister(); |
| - }) |
| - .then(function() { |
| - frame.remove(); |
| - return service_worker_unregister_and_done(t, longer_matched_scope); |
| - }) |
| - .catch(unreached_rejection(t)); |
| + }); |
| }, 'access ready after it has been resolved'); |
| - |
| </script> |