Chromium Code Reviews| Index: LayoutTests/http/tests/push_messaging/register_worker_not_activated.html |
| diff --git a/LayoutTests/http/tests/push_messaging/register_worker_not_activated.html b/LayoutTests/http/tests/push_messaging/register_worker_not_activated.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..1ea5119320f640ab17cb2ef1e12b7b55885c138e |
| --- /dev/null |
| +++ b/LayoutTests/http/tests/push_messaging/register_worker_not_activated.html |
| @@ -0,0 +1,36 @@ |
| +<!DOCTYPE html> |
| +<html> |
| +<head> |
| +<title>register() is rejected when the service worker is not active yet</title> |
| +<link rel="manifest" href="resources/push_manifest.json"> |
| +<script src="../resources/testharness.js"></script> |
| +<script src="../resources/testharnessreport.js"></script> |
| +<script src="../serviceworker/resources/test-helpers.js"></script> |
| +</head> |
| +<body> |
| +<script> |
| +async_test(function(test) { |
| + assert_true(!!window.testRunner, 'This test requires the TestRunner.'); |
| + var workerUrl = 'resources/empty_worker.js'; |
| + var workerScope = 'resources/scope/' + location.pathname; |
| + var swRegistration; |
| + service_worker_unregister_and_register(test, workerUrl, workerScope) |
| + .then(function(serviceWorkerRegistration) { |
| + swRegistration = serviceWorkerRegistration; |
| + assert_true(!!swRegistration.installing, 'The worker should be installing'); |
|
Peter Beverloo
2014/12/10 00:18:18
assert_not_equals(swRegistration.installing, null)
Michael van Ouwerkerk
2014/12/10 15:13:06
Done.
|
| + assert_equals(swRegistration.active, null, 'The worker should not be active yet'); |
| + testRunner.setPushMessagingPermission(location.origin, true); |
| + return swRegistration.pushManager.register(); |
| + }) |
| + .then(function(pushRegistration) { |
| + assert_unreached('register() must not succeed without an active service worker'); |
| + }, function(e) { |
| + assert_equals(e.name, 'AbortError'); |
| + assert_equals(e.message, 'Registration failed - no Service Worker'); |
| + return service_worker_unregister_and_done(test, workerScope); |
| + }) |
| + .catch(unreached_rejection(test)); |
| +}, 'register() is rejected when the service worker is not active yet'); |
| +</script> |
| +</body> |
| +</html> |