mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
6ee42939de
--HG-- rename : dom/tests/mochitest/notification/create_notification.html => dom/tests/mochitest/notification/desktop-notification/create_notification.html rename : dom/tests/mochitest/notification/notification_common.js => dom/tests/mochitest/notification/desktop-notification/notification_common.js rename : dom/tests/mochitest/notification/test_basic_notification.html => dom/tests/mochitest/notification/desktop-notification/test_basic_notification.html rename : dom/tests/mochitest/notification/test_basic_notification_click.html => dom/tests/mochitest/notification/desktop-notification/test_basic_notification_click.html rename : dom/tests/mochitest/notification/test_leak_windowClose.html => dom/tests/mochitest/notification/desktop-notification/test_leak_windowClose.html rename : dom/tests/mochitest/notification/test_notification_tag.html => dom/tests/mochitest/notification/desktop-notification/test_notification_tag.html rename : dom/tests/mochitest/notification/test_system_principal.xul => dom/tests/mochitest/notification/desktop-notification/test_system_principal.xul
116 lines
3.5 KiB
HTML
116 lines
3.5 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<title>Notification Basics</title>
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<script type="text/javascript" src="MockServices.js"></script>
|
|
<script type="text/javascript" src="NotificationTest.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
</head>
|
|
<body>
|
|
<p id="display"></p>
|
|
<div id="content" style="display: none"></div>
|
|
<pre id="test"></pre>
|
|
<script type="text/javascript">
|
|
|
|
var info = NotificationTest.info;
|
|
|
|
var steps = [
|
|
function () {
|
|
info("Test notification spec");
|
|
ok(Notification, "Notification constructor exists");
|
|
ok(Notification.permission, "Notification.permission exists");
|
|
ok(Notification.requestPermission, "Notification.requestPermission exists");
|
|
ok(Notification.get, "Notification.get exists");
|
|
},
|
|
|
|
function () {
|
|
info("Test blank requestPermission");
|
|
Notification.requestPermission();
|
|
},
|
|
|
|
function (done) {
|
|
info("Test requestPermission deny");
|
|
NotificationTest.denyNotifications();
|
|
Notification.requestPermission(function(perm) {
|
|
is(perm, "denied", "Permission should be denied.");
|
|
is(Notification.permission, "denied", "Permission should be denied.");
|
|
done();
|
|
});
|
|
},
|
|
|
|
function (done) {
|
|
info("Test requestPermission grant");
|
|
NotificationTest.allowNotifications();
|
|
Notification.requestPermission(function (perm) {
|
|
is(perm, "granted", "Permission should be granted.");
|
|
is(Notification.permission, "granted", "Permission should be granted");
|
|
done();
|
|
});
|
|
},
|
|
|
|
function () {
|
|
info("Test invalid requestPermission");
|
|
try {
|
|
Notification.requestPermission({});
|
|
ok(false, "Non callable arg to requestPermission should throw");
|
|
} catch (e) {
|
|
ok(true, "Non callable arg to requestPermission should throw");
|
|
}
|
|
},
|
|
|
|
function (done) {
|
|
info("Test create notification");
|
|
|
|
var options = {
|
|
dir: "auto",
|
|
lang: "",
|
|
body: "This is a notification body",
|
|
tag: "sometag",
|
|
icon: "icon.png"
|
|
};
|
|
var notification = new Notification("This is a title", options);
|
|
|
|
ok(notification, "Notification exists");
|
|
is(notification.onclick, null, "onclick() should be null");
|
|
is(notification.onshow, null, "onshow() should be null");
|
|
is(notification.onerror, null, "onerror() should be null");
|
|
is(notification.onclose, null, "onclose() should be null");
|
|
is(typeof notification.close, "function", "close() should exist");
|
|
|
|
is(notification.dir, options.dir, "auto should get set");
|
|
is(notification.lang, options.lang, "lang should get set");
|
|
is(notification.body, options.body, "body should get set");
|
|
is(notification.tag, options.tag, "tag should get set");
|
|
is(notification.icon, options.icon, "icon should get set");
|
|
|
|
// store notification in test context
|
|
this.notification = notification;
|
|
|
|
notification.onshow = function () {
|
|
ok(true, "onshow handler should be called");
|
|
done();
|
|
};
|
|
},
|
|
|
|
function (done) {
|
|
info("Test closing a notification");
|
|
var notification = this.notification;
|
|
|
|
notification.onclose = function () {
|
|
ok(true, "onclose handler should be called");
|
|
done();
|
|
};
|
|
|
|
notification.close();
|
|
},
|
|
];
|
|
|
|
MockServices.register();
|
|
NotificationTest.run(steps, function () {
|
|
MockServices.unregister();
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|