Index: LayoutTests/http/tests/serviceworker/getregistrations.html |
diff --git a/LayoutTests/http/tests/serviceworker/getregistrations.html b/LayoutTests/http/tests/serviceworker/getregistrations.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ab88b39b187d37b7a19b8467e25b6fac3e962675 |
--- /dev/null |
+++ b/LayoutTests/http/tests/serviceworker/getregistrations.html |
@@ -0,0 +1,82 @@ |
+<!DOCTYPE html> |
+<script src="../resources/testharness.js"></script> |
+<script src="../resources/testharnessreport.js"></script> |
+<script src="resources/test-helpers.js"></script> |
+<script> |
falken
2015/05/25 00:43:02
This will be racy since async tests including prom
jungkees
2015/05/27 08:06:46
I gave it a try with sequential_promise_test, but
|
+promise_test(function(t) { |
+ navigator.serviceWorker.getRegistrations() |
+ .then(function(value) { |
+ assert_array_equals( |
+ value, |
+ [], |
+ 'getRegistrations should resolve with an empty array.'); |
+ t.done(); |
+ }) |
+ .catch(unreached_rejection(t)); |
falken
2015/05/25 00:43:02
for a promise_test, you only need to return a prom
|
+ }, 'getRegistrations'); |
+ |
+promise_test(function(t) { |
+ var scope = 'resources/scope/getregistrations/normal'; |
+ var script = 'resources/empty-worker.js'; |
+ var registrations = []; |
+ service_worker_unregister_and_register(t, script, scope) |
+ .then(function(r) { |
+ registrations.push(r); |
+ return navigator.serviceWorker.getRegistrations(); |
+ }) |
+ .then(function(value) { |
+ assert_array_equals( |
+ value, |
+ registrations, |
+ 'getRegistrations should resolve with array of registrations.'); |
+ service_worker_unregister_and_done(t, scope); |
+ }) |
+ .catch(unreached_rejection(t)); |
+ }, 'Register then getRegistrations'); |
+ |
+promise_test(function(t) { |
+ var scope1 = 'resources/scope/getregistrations/scope1'; |
+ var scope2 = 'resources/scope/getregistrations/scope2'; |
+ var script = 'resources/empty-worker.js'; |
+ var registrations = []; |
+ service_worker_unregister_and_register(t, script, scope1) |
+ .then(function(r) { |
+ registrations.push(r); |
+ return service_worker_unregister_and_register(t, script, scope2); |
+ }) |
+ .then(function(r) { |
+ registrations.push(r); |
+ return navigator.serviceWorker.getRegistrations(); |
+ }) |
+ .then(function(value) { |
+ assert_array_equals( |
+ value, |
+ registrations, |
+ 'getRegistrations should resolve with array of registrations.'); |
+ service_worker_unregister(t, scope1); |
+ service_worker_unregister_and_done(t, scope2); |
+ }) |
+ .catch(unreached_rejection(t)); |
+ }, 'Register multiple times then getRegistrations'); |
+ |
+promise_test(function(t) { |
+ var scope = 'resources/scope/getregistrations/register-unregister'; |
+ var script = 'resources/empty-worker.js'; |
+ service_worker_unregister_and_register(t, script, scope) |
+ .then(function(registration) { |
+ return registration.unregister(); |
+ }) |
+ .then(function() { |
+ return navigator.serviceWorker.getRegistrations(); |
+ }) |
+ .then(function(value) { |
+ assert_array_equals( |
+ value, |
+ [], |
+ 'getRegistrations should resolve with an empty array.'); |
+ t.done(); |
+ }) |
+ .catch(unreached_rejection(t)); |
+ }, 'Register then Unregister then getRegistrations'); |
+ |
+</script> |