summaryrefslogtreecommitdiffstats
path: root/dom/tests/mochitest/notification/test_notification_basics.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/tests/mochitest/notification/test_notification_basics.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/tests/mochitest/notification/test_notification_basics.html')
-rw-r--r--dom/tests/mochitest/notification/test_notification_basics.html129
1 files changed, 129 insertions, 0 deletions
diff --git a/dom/tests/mochitest/notification/test_notification_basics.html b/dom/tests/mochitest/notification/test_notification_basics.html
new file mode 100644
index 000000000..3d0465c3f
--- /dev/null
+++ b/dom/tests/mochitest/notification/test_notification_basics.html
@@ -0,0 +1,129 @@
+<!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 options;
+
+ SimpleTest.requestFlakyTimeout("untriaged");
+
+ 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 requestPermission without callback");
+ Notification.requestPermission();
+ },
+
+ function (done) {
+ info("Test requestPermission deny");
+ function assertPermissionDenied(perm) {
+ is(perm, "denied", "Permission should be denied.");
+ is(Notification.permission, "denied", "Permission should be denied.");
+ }
+ NotificationTest.denyNotifications();
+ Notification.requestPermission()
+ .then(assertPermissionDenied)
+ .then(_ => Notification.requestPermission(assertPermissionDenied))
+ .catch(err => {
+ ok(!err, "requestPermission should not reject promise");
+ })
+ .then(done);
+ },
+
+ function (done) {
+ info("Test requestPermission grant");
+ function assertPermissionGranted(perm) {
+ is(perm, "granted", "Permission should be granted.");
+ is(Notification.permission, "granted", "Permission should be granted");
+ }
+ NotificationTest.allowNotifications();
+ Notification.requestPermission()
+ .then(assertPermissionGranted)
+ .then(_ => Notification.requestPermission(assertPermissionGranted))
+ .catch(err => {
+ ok(!err, "requestPermission should not reject promise");
+ })
+ .then(done);
+ },
+
+ function (done) {
+ info("Test invalid requestPermission");
+ Notification.requestPermission({})
+ .then(_ => {
+ ok(false, "Non callable arg to requestPermission should reject promise");
+ }, err => {
+ ok(true, "Non callable arg to requestPermission should reject promise");
+ })
+ .then(done);
+ },
+
+ function (done) {
+ info("Test create notification");
+
+ options = NotificationTest.payload;
+
+ 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(typeof notification.data, "object", "data should be a JS object");
+
+ 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");
+ ok(NotificationTest.customDataMatches(notification.data),
+ "data 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>