blob: 94008cb1f5739570ca50f2cc51bb54b3c3fec3c9 [file] [log] [blame]
<!doctype html>
<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>
// 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_equals(data.message, 'No notification permission has been granted for this origin.');
}, 'showNotification() must reject if no Web Notification permission has been granted.');