| Open this page through a web server in two views. If necessary request permission to post web notifications: <button onclick="requestPermission()">Request permission</button><br/> |
| Then post this permission once in each page. <button onclick="postNotification()">Post notification</button><br/> |
| Click on the notification. Only the second notification should be closed on the second page. |
| function requestPermission() { |
| if (Notification.permission == "granted") { |
| log("Notification already granted"); |
| log("Requesting permission..."); |
| Notification.requestPermission(function(permission) { |
| if (Notification.permission == "granted") { |
| log("Notification granted"); |
| log("Notification denied"); |
| function postNotification() { |
| var n = new Notification("Notification title"); |
| n.onshow = onShowHandler; |
| n.onclick = onClickHandler; |
| n.onclose = onCloseHandler; |
| document.getElementById("console").innerHTML += message + "<br/>"; |
| function onShowHandler() { |
| log("onshow handler called"); |
| function onClickHandler() { |
| log("onclick handler called"); |
| function onCloseHandler() { |
| log("onclose handler called"); |