blob: 391859000711395eade151a748ba2bdbb82708be [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="/js-test-resources/testharness.js"></script>
<script src="/js-test-resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
<div id="container"></div>
<script>
test(function() {
assert_throws(new TypeError(), function() { new Notification(); });
}, "The Notification constructor requires at least one argument.");
test(function() {
let notification = new Notification("test title");
assert_class_string(notification, "Notification");
assert_equals(notification.title, "test title");
assert_equals(notification.dir, "auto");
assert_equals(notification.lang, "");
assert_equals(notification.body, "");
assert_equals(notification.tag, "");
assert_equals(notification.icon, "");
}, "The Notification object initializes its properties to their default values from the NotificationOptions dictionary if it is not provided.");
test(function() {
let notification = new Notification("test title", {
dir: "ltr",
lang: "en",
body: "test body",
tag: "test tag",
icon: "foo.png"
});
assert_equals(notification.title, "test title");
assert_equals(notification.dir, "ltr");
assert_equals(notification.lang, "en");
assert_equals(notification.body, "test body");
assert_equals(notification.tag, "test tag");
assert_equals(notification.icon, "http://127.0.0.1:8000/notifications/foo.png");
}, "The Notification object initializes its properties to the values from NotificationOptions dictionary if it is provided.");
test(function() {
let notification1 = new Notification("test title", { dir: "auto" });
assert_equals(notification1.dir, "auto");
let notification2 = new Notification("test title", { dir: "ltr" });
assert_equals(notification2.dir, "ltr");
let notification3 = new Notification("test title", { dir: "rtl" });
assert_equals(notification3.dir, "rtl");
assert_throws(new TypeError(), function() { new Notification("test title", { dir: "foo" }) });
}, "The NotificationOptions dictionary only accepts valid NotificationDirection values.");
</script>
</body>
</html>