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
133 lines
4.0 KiB
HTML
133 lines
4.0 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">
|
|
|
|
function deleteAllNotifications() {
|
|
var promise = Notification.get();
|
|
promise.then(function (notifications) {
|
|
notifications.forEach(function(notification) {
|
|
notification.close();
|
|
});
|
|
});
|
|
}
|
|
|
|
var info = NotificationTest.info;
|
|
|
|
var steps = [
|
|
function (done) {
|
|
info("Test that Notifcation.get fulfills the promise");
|
|
var promise = Notification.get();
|
|
ok(promise.then, "should return a promise");
|
|
|
|
// Create a new notification to make sure
|
|
// Notification.get() works while creating
|
|
var notification = new Notification("this is a test");
|
|
|
|
promise.then(function () {
|
|
ok(true, "promise should be fulfilled");
|
|
done();
|
|
});
|
|
},
|
|
|
|
deleteAllNotifications,
|
|
|
|
function (done) {
|
|
info("Test adding a notification, and making sure get returns it");
|
|
NotificationTest.allowNotifications();
|
|
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);
|
|
var promise = Notification.get();
|
|
promise.then(function (notifications) {
|
|
ok(notifications.length, "should return notifications");
|
|
for (var i = 0; i < notifications.length; i++) {
|
|
var notification = notifications[i];
|
|
if (notification.tag === options.tag) {
|
|
ok(true, "should contain newly created notification");
|
|
for (var key in options) {
|
|
is(notification[key], options[key], key + " property should match");
|
|
}
|
|
notification.close();
|
|
return;
|
|
}
|
|
}
|
|
ok(false, "should contain newly created notification");
|
|
notification.close();
|
|
});
|
|
notification.onclose = done;
|
|
},
|
|
|
|
function (done) {
|
|
info("Testing fetching notification by tag filter");
|
|
var n1 = new Notification("title1", {tag: "tag1"});
|
|
var n2 = new Notification("title2", {tag: "tag2"});
|
|
var n3 = new Notification("title3", {tag: "tag3"});
|
|
var promise = Notification.get({tag: "tag3"});
|
|
promise.then(function (notifications) {
|
|
var notification = notifications[0];
|
|
is(notifications.length, 1, "should return 1 notification");
|
|
is(notifications[0].title, "title3", "titles should match");
|
|
is(notifications[0].tag, "tag3", "tags should match");
|
|
var closeCount = 0;
|
|
var waitForAll = function () {
|
|
if (++closeCount >= 3) {
|
|
done();
|
|
}
|
|
};
|
|
n1.onclose = waitForAll;
|
|
n2.onclose = waitForAll;
|
|
n3.onclose = waitForAll;
|
|
n1.close();
|
|
n2.close();
|
|
n3.close();
|
|
});
|
|
},
|
|
|
|
deleteAllNotifications,
|
|
|
|
function (done) {
|
|
info("Testing fetching no notifications");
|
|
var promise = Notification.get();
|
|
promise.then(function (notifications) {
|
|
is(notifications.length, 0, "should return 0 notifications");
|
|
done();
|
|
});
|
|
},
|
|
|
|
function (done) {
|
|
info("Testing fetching multiple notifications");
|
|
var n1 = new Notification("title1");
|
|
var n2 = new Notification("title2");
|
|
var n3 = new Notification("title3");
|
|
var promise = Notification.get();
|
|
promise.then(function (notifications) {
|
|
is(notifications.length, 3, "should return 2 notifications");
|
|
done();
|
|
});
|
|
}
|
|
];
|
|
|
|
MockServices.register();
|
|
NotificationTest.run(steps, function () {
|
|
MockServices.unregister();
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|