blob: 72c6c46c25d33a48592ddeb1ae2f2c451fca8438 [file] [log] [blame]
<!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 = 'instrumentation-service-worker.js';
testRunner.setPermission('notifications', 'granted', location.origin, location.origin);
async_test(function(test) {
var scope = 'resources/scope/' + location.pathname + "/noaction";
getActiveServiceWorkerWithMessagePort(test, script, scope).then(function(workerInfo) {
assert_inherits(workerInfo.registration, 'showNotification', 'showNotification() must be exposed.');
workerInfo.registration.showNotification('Title', {
actions: [{ title: "Foo" }]
}).then(unreached_fulfillment(test)).catch(function(error) {
assert_equals(error.name, 'TypeError');
assert_equals(error.message, "Failed to execute 'showNotification' on 'ServiceWorkerRegistration': required member action is undefined.");
test.done();
});
}).catch(unreached_rejection(test));
}, 'showNotification() must reject if a NotificationAction has no action.');
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: [{ action: "foo" }]
}).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 a NotificationAction has no title.');
</script>
</body>
</html>