Index: LayoutTests/http/tests/push_messaging/register_success.html |
diff --git a/LayoutTests/http/tests/push_messaging/register_success.html b/LayoutTests/http/tests/push_messaging/register_success.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..0085bc148d739b43623ee17b3840dcf3443027a4 |
--- /dev/null |
+++ b/LayoutTests/http/tests/push_messaging/register_success.html |
@@ -0,0 +1,44 @@ |
+<!DOCTYPE html> |
+<html> |
+<head> |
+<title>register() succeeds when permission is granted and fulfills with a valid registration</title> |
Peter Beverloo
2014/12/10 00:18:18
nit: s/fulfills/resolves/ (In the test's descripti
Michael van Ouwerkerk
2014/12/10 15:13:06
Done.
|
+<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; |
+ return wait_for_activated(test, swRegistration); |
+ }) |
+ .then(function() { |
+ testRunner.setPushMessagingPermission(location.origin, true); |
+ return swRegistration.pushManager.register(); |
+ }) |
+ .then(function(pushRegistration) { |
+ assert_own_property(pushRegistration, 'pushRegistrationId'); |
+ assert_equals(typeof pushRegistration.pushRegistrationId, 'string'); |
+ |
+ assert_own_property(pushRegistration, 'pushEndpoint'); |
+ assert_equals(typeof pushRegistration.pushEndpoint, 'string'); |
+ try { |
+ var endpointUrl = new URL(pushRegistration.pushEndpoint); |
+ } catch(e) { |
+ assert_unreached('Constructing a URL from the endpoint should not throw.'); |
+ } |
+ |
+ return service_worker_unregister_and_done(test, workerScope); |
+ }) |
+ .catch(unreached_rejection(test)); |
+}, 'register() succeeds when permission is granted and fulfills with a valid registration'); |
+</script> |
+</body> |
+</html> |