Chromium Code Reviews| Index: LayoutTests/http/tests/push_messaging/register-document.html |
| diff --git a/LayoutTests/http/tests/push_messaging/register-document.html b/LayoutTests/http/tests/push_messaging/register-document.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e6cd1c4e90c9ab9879cc9a88b5356cf09f6e8fe8 |
| --- /dev/null |
| +++ b/LayoutTests/http/tests/push_messaging/register-document.html |
| @@ -0,0 +1,42 @@ |
| +<!DOCTYPE html> |
| +<html> |
| +<head> |
| +<title>Push API: register in document context</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) { |
|
Peter Beverloo
2014/12/08 21:40:50
This is a bit of a weird test. Also, "register in
Michael van Ouwerkerk
2014/12/09 18:47:45
It was mixed up because multiple async tests on th
|
| + assert_true(!!window.testRunner, 'This test requires the TestRunner.'); |
| + var url = 'resources/empty-worker.js'; |
| + var scope = 'resources/scope/register'; |
| + var origin = 'http://127.0.0.1:8000'; |
| + var swRegistration; |
| + service_worker_unregister_and_register(test, url, scope) |
| + .then(function(serviceWorkerRegistration) { |
| + swRegistration = serviceWorkerRegistration; |
| + testRunner.setPushMessagingPermission(origin, true); |
| + return swRegistration.pushManager.register(); |
| + }) |
| + .then(function(pushRegistration) { |
| + assert_equals(pushRegistration.pushEndpoint, 'https://example.com/LayoutTestEndpoint'); |
| + assert_equals(pushRegistration.pushRegistrationId, 'layoutTestRegistrationId_0'); |
| + testRunner.resetPushMessagingRegistrations(); |
| + testRunner.setPushMessagingPermission(origin, false); |
| + return swRegistration.pushManager.register(); |
| + }) |
| + .then(function(pushRegistration) { |
| + assert_unreached('Registration must not succeed after permission is denied.'); |
| + }, function(e) { |
| + assert_equals(e.name, 'AbortError'); |
| + assert_equals(e.message, 'Registration failed - permission denied'); |
| + test.done(); |
| + }) |
| + .catch(unreached_rejection(test)); |
| +}, 'Push API: register in document context'); |
| +</script> |
| +</body> |
| +</html> |