| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script type="text/javascript"> | 4 <script src="../../resources/js-test.js"></script> |
| 5 function log(message) | 5 </head> |
| 6 { | 6 <body> |
| 7 document.getElementById("result").innerHTML += message + "<br>"; | 7 <p> |
| 8 } | 8 Tests that it is possible to request permission to display Web |
| 9 | 9 Notifications from a document context, for which the passed callback |
| 10 function runTests() | 10 will be invoked with the requests' result. It also makes sure that |
| 11 { | 11 not passing a callback won't result in a crash. |
| 12 </p> |
| 13 <div id="console"></div> |
| 14 <script> |
| 12 if (window.testRunner) { | 15 if (window.testRunner) { |
| 13 testRunner.dumpAsText(); | 16 testRunner.dumpAsText(); |
| 17 testRunner.waitUntilDone(); |
| 18 testRunner.clearWebNotificationPermissions(); |
| 14 } | 19 } |
| 15 | 20 |
| 16 if (!window.Notification) { | 21 var result; |
| 17 log("FAIL: No Notification interface!"); | |
| 18 } | |
| 19 | |
| 20 var N = window.Notification.requestPermission( | |
| 21 function() { log("PASS: Permission callback invoked."); } | |
| 22 ); | |
| 23 } | |
| 24 </script> | |
| 25 </head> | |
| 26 <body> | |
| 27 <p>Requesting notification permission...</p> | |
| 28 | |
| 29 <div id="result"></div> | |
| 30 <script type="text/javascript"> | |
| 31 runTests(); | |
| 32 </script> | |
| 33 | 22 |
| 23 // This should not crash given that the callback is optional. |
| 24 Notification.requestPermission(); |
| 34 | 25 |
| 35 </body> | 26 // This should log the default permission, since no other permission |
| 27 // has been set yet. |
| 28 Notification.requestPermission(function (localResult) { |
| 29 result = localResult; |
| 30 shouldBeEqualToString("result", "default"); |
| 31 |
| 32 if (!window.testRunner) { |
| 33 testPassed("The remainder of this test requires the TestRunn
er."); |
| 34 return; |
| 35 } |
| 36 |
| 37 testRunner.grantWebNotificationPermission("file://", true); |
| 38 Notification.requestPermission(function (localResult) { |
| 39 result = localResult; |
| 40 shouldBeEqualToString("result", "granted"); |
| 41 |
| 42 testRunner.notifyDone(); |
| 43 }); |
| 44 }); |
| 45 </script> |
| 46 </body> |
| 36 </html> | 47 </html> |
| OLD | NEW |