<!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 event handlers.");

if (window.testRunner) {
	debug("Granting permission to " + testURL);
	testRunner.grantWebNotificationPermission(testURL);
}

shouldBeEqualToString("Notification.permission", "granted");

var n = new Notification("title");
n.onshow = function() {
	testPassed("onshow event handler was called");
	testRunner.simulateWebNotificationClick(this);
};
n.onclick = function() {
	testPassed("onclick event handler was called");
	this.close();
};
n.onclose = function() {
	testPassed("onclose event handler was called");
	testCompleted();
};
n.onerror = function() {
	testFailed("onerror event handler should not be called");
	testCompleted();
};
</script>
