blob: b541ab35b1333603bbb8a7739eb3194612816d57 [file] [log] [blame]
<!DOCTYPE html>
<script src="/resources/js-test-pre.js"></script>
<script src="/resources/notifications-test-pre.js"></script>
<p id="description"></p>
<div id="console"></div>
<script>
if (window.testRunner)
testRunner.waitUntilDone();
description("This test looks for the dispatch of the onshow event handler.");
var n = null;
function part1() {
shouldBeEqualToString("Notification.permission", "default");
n = new Notification("title 1");
n.onshow = function() {
testFailed("onshow event handler should not be called");
setTimeout(part2, 0);
};
n.onerror = function() {
testPassed("onerror event handler was called");
setTimeout(part2, 0);
};
}
function part2() {
debug("Granting permission to " + testURL);
testRunner.grantWebNotificationPermission(testURL);
shouldBeEqualToString("Notification.permission", "granted");
n = new Notification("title 2");
n.onshow = function() {
testPassed("onshow event handler was called");
setTimeout(part3, 0);
};
n.onerror = function() {
testFailed("onerror event handler should not be called");
setTimeout(part3, 0);
};
}
function part3() {
debug("Denying permission to " + testURL);
testRunner.denyWebNotificationPermission(testURL);
shouldBeEqualToString("Notification.permission", "denied");
n = new Notification("title 3");
n.onshow = function() {
testFailed("onshow event handler should not be called");
setTimeout(part4, 0);
};
n.onerror = function() {
testPassed("onerror event handler was called");
setTimeout(part4, 0);
};
}
function part4() {
debug("Resetting all permissions");
testRunner.removeAllWebNotificationPermissions();
shouldBeEqualToString("Notification.permission", "default");
testCompleted();
}
part1();
</script>