blob: 0a30970974c59b5dc94241123d9366d78031e675 [file] [log] [blame]
<!doctype html>
<html>
<head>
<title>Notifications: Creating notifications should succeed when permission has been granted.</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
</head>
<body>
<script>
// Tests that Notification.requestPermission() returns "granted" when
// permission has been granted, causing creation of notifications to
// succeed. When running this test manually, accept permission
// for displaying notifications prior to running the test.
async_test(function (test) {
testRunner.setPermission('notifications', 'granted', location.origin, location.origin);
Notification.requestPermission(function (status) {
assert_equals(status, 'granted');
var notification = new Notification('My Notification');
notification.addEventListener('show', function() {
test.done();
});
notification.addEventListener('error', function() {
assert_unreached('The notification is expected to be shown.');
});
});
}, 'Notification creation succeeds when permission has been granted.');
</script>
</body>
</html>