Index: LayoutTests/http/tests/notifications/serviceworkerregistration-document-actions-throw.html |
diff --git a/LayoutTests/http/tests/notifications/serviceworkerregistration-document-actions-throw.html b/LayoutTests/http/tests/notifications/serviceworkerregistration-document-actions-throw.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a2c050aa31df988e774a9e77a12d40de73106d42 |
--- /dev/null |
+++ b/LayoutTests/http/tests/notifications/serviceworkerregistration-document-actions-throw.html |
@@ -0,0 +1,53 @@ |
+<!doctype html> |
+<html> |
+ <head> |
+ <title>Notifications: Check that showNotifications rejects if actions is set incorrectly.</title> |
+ <script src="../resources/testharness.js"></script> |
+ <script src="../resources/testharnessreport.js"></script> |
+ <script src="../serviceworker/resources/test-helpers.js"></script> |
+ <script src="resources/test-helpers.js"></script> |
+ </head> |
+ <body> |
+ <script> |
+ // Tests that serviceWorkerRegistration.showNotification throws a |
+ // TypeError if NotificationOptions.actions is set incorrectly. |
+ var script = 'resources/instrumentation-service-worker.js'; |
+ |
+ testRunner.setPermission('notifications', 'granted', location.origin, location.origin); |
+ |
+ async_test(function(test) { |
+ var scope = 'resources/scope/' + location.pathname + "/notitle"; |
+ |
+ getActiveServiceWorkerWithMessagePort(test, script, scope).then(function(workerInfo) { |
+ assert_inherits(workerInfo.registration, 'showNotification', 'showNotification() must be exposed.'); |
+ |
+ workerInfo.registration.showNotification('Title', { |
+ actions: [{}] |
+ }).then(unreached_fulfillment(test)).catch(function(error) { |
+ assert_equals(error.name, 'TypeError'); |
+ assert_equals(error.message, "Failed to execute 'showNotification' on 'ServiceWorkerRegistration': required member title is undefined."); |
+ test.done(); |
+ }); |
+ }).catch(unreached_rejection(test)); |
+ |
+ }, 'showNotification() must reject if an action has no title.'); |
+ |
+ async_test(function(test) { |
+ var scope = 'resources/scope/' + location.pathname + "/emptytitle"; |
+ |
+ getActiveServiceWorkerWithMessagePort(test, script, scope).then(function(workerInfo) { |
+ assert_inherits(workerInfo.registration, 'showNotification', 'showNotification() must be exposed.'); |
+ |
+ workerInfo.registration.showNotification('Title', { |
+ actions: [{title: ""}] |
+ }).then(unreached_fulfillment(test)).catch(function(error) { |
+ assert_equals(error.name, 'TypeError'); |
+ assert_equals(error.message, 'Notification action titles must not be empty.'); |
+ test.done(); |
+ }); |
+ }).catch(unreached_rejection(test)); |
+ |
+ }, 'showNotification() must reject if an action has an empty title.'); |
+ </script> |
+ </body> |
+</html> |