Chromium Code Reviews| Index: LayoutTests/http/tests/push_messaging/has-permission-document.html |
| diff --git a/LayoutTests/http/tests/push_messaging/has-permission-document.html b/LayoutTests/http/tests/push_messaging/has-permission-document.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4b2b206bd1ca4e773c8afed21e1fbee4d8ab55e9 |
| --- /dev/null |
| +++ b/LayoutTests/http/tests/push_messaging/has-permission-document.html |
| @@ -0,0 +1,46 @@ |
| +<!DOCTYPE html> |
| +<html> |
| +<head> |
| +<title>Push API: hasPermission 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) { |
| + assert_true(!!window.testRunner, 'This test requires the TestRunner.'); |
| + var url = 'resources/empty-worker.js'; |
| + var scope = 'resources/scope/hasPermission'; |
| + var origin = 'http://127.0.0.1:8000'; |
| + var swRegistration; |
| + service_worker_unregister_and_register(test, url, scope) |
| + .then(function(serviceWorkerRegistration) { |
| + swRegistration = serviceWorkerRegistration; |
| + return swRegistration.pushManager.hasPermission(); |
| + }) |
| + .then(function(permissionStatus) { |
| + assert_equals(permissionStatus, 'default', 'By default hasPermission resolves with default.'); |
| + testRunner.setPushMessagingPermission(origin, true); |
| + return swRegistration.pushManager.hasPermission(); |
| + }) |
| + .then(function(permissionStatus) { |
| + assert_equals(permissionStatus, 'granted', 'Once granted hasPermission resolves with granted.'); |
| + testRunner.setPushMessagingPermission(origin, false); |
| + return swRegistration.pushManager.hasPermission(); |
| + }) |
| + .then(function(permissionStatus) { |
| + assert_equals(permissionStatus, 'denied', 'Once denied hasPermission resolves with denied.'); |
| + testRunner.clearPushMessagingPermissions(); |
| + return swRegistration.pushManager.hasPermission(); |
| + }) |
| + .then(function(permissionStatus) { |
|
Peter Beverloo
2014/12/08 21:40:50
This clause shouldn't be included, as it tests the
Michael van Ouwerkerk
2014/12/09 18:47:45
Done. Actually, I split these into three separate
|
| + assert_equals(permissionStatus, 'default', 'After a reset hasPermission resolves with default again.'); |
| + test.done(); |
| + }) |
| + .catch(unreached_rejection(test)); |
| +}, 'Push API: hasPermission in document context'); |
| +</script> |
| +</body> |
| +</html> |