blob: 95455320e3a4e51af538d23776e140425271490b [file] [log] [blame]
<!doctype html>
<html>
<head>
<title>Notifications: ServiceWorkerRegistration.showNotification() shows notification with correct notification direction.</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 resolves a promise, and that the
// notificationclick event gets fired with the correct notification direction.
// This test requires the test runner.
async_test(function(test) {
var scope = 'resources/spec/' + location.pathname;
var script = 'instrumentation-service-worker.js';
var port;
testRunner.setPermission('notifications', 'granted', location.origin, location.origin);
getActiveServiceWorkerWithMessagePort(test, script, scope).then(function(info) {
port = info.port;
// (1) Display a Web Notification from the document.
return info.registration.showNotification(scope, {
dir: 'rtl'
});
}).then(function() {
// (2) Simulate a click on the notification that has been displayed.
return simulateNotificationClick(scope, -1 /* action_index */, port);
}).then(function(data) {
// (3) Verify that the click event was received by the Service Worker,
// and that the correct direction was passed along.
assert_equals(data.notification.dir, 'rtl');
test.done();
}).catch(unreached_rejection(test));
}, 'Clicking on a notification displayed through showNotification() fires a Service Worker event with the correct notification direction');
</script>
</body>
</html>