Index: third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/getregistrations.https.html |
diff --git a/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/getregistrations.https.html b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/getregistrations.https.html |
index 036764d1133247f8657d15b22cd4042d723339b6..1ed871a8b227ce27bc1fe6179a626c51eb8ca3f8 100644 |
--- a/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/getregistrations.https.html |
+++ b/third_party/WebKit/LayoutTests/external/wpt/service-workers/service-worker/getregistrations.https.html |
@@ -4,12 +4,22 @@ |
<script src="/resources/testharnessreport.js"></script> |
<script src="resources/test-helpers.sub.js"></script> |
<script src="/common/get-host-info.sub.js"></script> |
-<script src="../fetch/resources/fetch-test-helpers.sub.js"></script> |
<script> |
// Purge the existing registrations for the origin. |
// getRegistrations() is used in order to avoid adding additional complexity |
// e.g. adding an internal function. |
-promise_test(function(t) { |
+setup({ explicit_done: true }); |
+ |
+promise_test(function() { |
+ function waitForUnregistered() { |
+ return navigator.serviceWorker.getRegistrations() |
+ .then(function(value) { |
+ if (value.length > 0) { |
+ return waitForUnregistered(); |
+ } |
+ }); |
+ } |
+ |
return navigator.serviceWorker.getRegistrations() |
.then(function(registrations) { |
return registrations.reduce(function(sequence, registration) { |
@@ -17,19 +27,18 @@ promise_test(function(t) { |
return registration.unregister(); |
}); |
}, Promise.resolve()); |
- }); |
- }, 'Purge the existing registrations.'); |
- |
-promise_test(function(t) { |
- return navigator.serviceWorker.getRegistrations() |
- .then(function(value) { |
- assert_array_equals( |
- value, |
- [], |
- 'getRegistrations should resolve with an empty array.'); |
- }); |
- }, 'getRegistrations'); |
+ }) |
+ .then(waitForUnregistered) |
Marijn Kruisselbrink
2017/05/03 16:31:41
I don't think this waitForUnregistered change (rat
mike3
2017/05/03 17:26:19
Ah, right. I'll remove `waitForUnregistered`.
|
+ // This test's sub-tests should only be defined (and subsequently |
+ // executed) after all registrations are known to be cleared. |
Marijn Kruisselbrink
2017/05/03 16:31:41
promise_tests are ran sequentially anyway (i.e. th
mike3
2017/05/03 17:26:19
I made both changes according to the mistaken beli
|
+ .then(defineTests) |
+ // Invoking the global `done` function instructs the test harness to |
+ // interpret the completion of all currently-defined sub-tests as a |
+ // signal of test completion. |
+ .then(done); |
+ }, 'test set up: purge all registrations'); |
+function defineTests() { |
promise_test(function(t) { |
var scope = 'resources/scope/getregistrations/normal'; |
var script = 'resources/empty-worker.js'; |
@@ -186,6 +195,5 @@ promise_test(function(t) { |
return service_worker_unregister(t, scope); |
}); |
}, 'getRegistrations promise resolves only with same origin registrations.'); |
- |
-done(); |
+} |
</script> |