Index: LayoutTests/fast/notifications/notifications-constructor-request-permission.html |
diff --git a/LayoutTests/fast/notifications/notifications-constructor-request-permission.html b/LayoutTests/fast/notifications/notifications-constructor-request-permission.html |
index 65a6bf24937c12f72bdef685e0d2a86a4100ec92..0ead09f41b3d1cf684d196571fedd7f735d31b69 100644 |
--- a/LayoutTests/fast/notifications/notifications-constructor-request-permission.html |
+++ b/LayoutTests/fast/notifications/notifications-constructor-request-permission.html |
@@ -1,36 +1,47 @@ |
<!DOCTYPE html> |
<html> |
-<head> |
- <script type="text/javascript"> |
- function log(message) |
- { |
- document.getElementById("result").innerHTML += message + "<br>"; |
- } |
- |
- function runTests() |
- { |
+ <head> |
+ <script src="../../resources/js-test.js"></script> |
+ </head> |
+ <body> |
+ <p> |
+ Tests that it is possible to request permission to display Web |
+ Notifications from a document context, for which the passed callback |
+ will be invoked with the requests' result. It also makes sure that |
+ not passing a callback won't result in a crash. |
+ </p> |
+ <div id="console"></div> |
+ <script> |
if (window.testRunner) { |
testRunner.dumpAsText(); |
+ testRunner.waitUntilDone(); |
+ testRunner.clearWebNotificationPermissions(); |
} |
- if (!window.Notification) { |
- log("FAIL: No Notification interface!"); |
- } |
- |
- var N = window.Notification.requestPermission( |
- function() { log("PASS: Permission callback invoked."); } |
- ); |
- } |
- </script> |
-</head> |
-<body> |
- <p>Requesting notification permission...</p> |
- |
-<div id="result"></div> |
-<script type="text/javascript"> |
-runTests(); |
-</script> |
+ var result; |
+ |
+ // This should not crash given that the callback is optional. |
+ Notification.requestPermission(); |
+ |
+ // This should log the default permission, since no other permission |
+ // has been set yet. |
+ Notification.requestPermission(function (localResult) { |
+ result = localResult; |
+ shouldBeEqualToString("result", "default"); |
+ |
+ if (!window.testRunner) { |
+ testPassed("The remainder of this test requires the TestRunner."); |
+ return; |
+ } |
+ testRunner.grantWebNotificationPermission("file://", true); |
+ Notification.requestPermission(function (localResult) { |
+ result = localResult; |
+ shouldBeEqualToString("result", "granted"); |
-</body> |
+ testRunner.notifyDone(); |
+ }); |
+ }); |
+ </script> |
+ </body> |
</html> |