blob: 94008cb1f5739570ca50f2cc51bb54b3c3fec3c9 [file] [log] [blame]
<!doctype html>
<html>
<head>
<title>Notifications: ServiceWorkerRegistration.showNotification().</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 the showNotification() function when used in a Service Worker
// rejects when no permission has been granted. This test requires the test runner.
async_test(function(test) {
var scope = 'resources/scope/serviceworkerregistration-service-worker-click',
script = 'instrumentation-service-worker.js';
getActiveServiceWorkerWithMessagePort(test, script, scope).then(function(info) {
// (1) Tell the Service Worker to display a Web Notification.
return sendCommand(info.port, {
command: 'show',
title: 'My Notification',
options: { body: 'Hello, world!' }
});
}).then(function(data) {
// (2) Confirm that the service worker could not display the notification due to a
// permission error.
assert_false(data.success);
assert_equals(data.message, 'No notification permission has been granted for this origin.');
test.done();
}).catch(unreached_rejection(test));
}, 'showNotification() must reject if no Web Notification permission has been granted.');
</script>
</body>
</html>