OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <html> |
| 3 <head> |
| 4 <title>Notifications: ServiceWorkerRegistration.showNotification() should va
lidate the syntax of the language tag of a notification.</title> |
| 5 <script src="../resources/testharness.js"></script> |
| 6 <script src="../resources/testharnessreport.js"></script> |
| 7 <script src="../serviceworker/resources/test-helpers.js"></script> |
| 8 <script src="resources/test-helpers.js"></script> |
| 9 </head> |
| 10 <body> |
| 11 <script> |
| 12 // Tests that the showNotification() function validates the language tag o
f the |
| 13 // notification, by making sure that the tag is empty when an invalid BCP
47 |
| 14 // language has been supplied on getting the notifications. |
| 15 |
| 16 async_test(function(test) { |
| 17 var scope = 'resources/spec/' + location.pathname, |
| 18 script = 'resources/instrumentation-service-worker.js'; |
| 19 |
| 20 testRunner.setPermission('notifications', 'granted', location.origin,
location.origin); |
| 21 |
| 22 var registration = null; |
| 23 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi
on(info) { |
| 24 registration = info.registration; |
| 25 |
| 26 // (1) Display a Web Notification from the document. |
| 27 return registration.showNotification(scope, { |
| 28 lang: 'invalid language' |
| 29 }); |
| 30 }).then(function() { |
| 31 return registration.getNotifications(); |
| 32 }).then(function(notifications) { |
| 33 assert_equals(notifications.length, 1); |
| 34 assert_equals(notifications[0].lang, ''); |
| 35 |
| 36 test.done(); |
| 37 }).catch(unreached_rejection(test)); |
| 38 |
| 39 }, 'ServiceWorkerRegistration.showNotification() should validate the synta
x of the language tag of a notification.'); |
| 40 </script> |
| 41 </body> |
| 42 </html> |
OLD | NEW |