OLD | NEW |
1 <!doctype html> | 1 <!doctype html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>Notifications: Check that showNotifications rejects if actions is set
incorrectly.</title> | 4 <title>Notifications: Check that showNotifications rejects if actions is set
incorrectly.</title> |
5 <script src="../resources/testharness.js"></script> | 5 <script src="../resources/testharness.js"></script> |
6 <script src="../resources/testharnessreport.js"></script> | 6 <script src="../resources/testharnessreport.js"></script> |
7 <script src="../serviceworker/resources/test-helpers.js"></script> | 7 <script src="../serviceworker/resources/test-helpers.js"></script> |
8 <script src="resources/test-helpers.js"></script> | 8 <script src="resources/test-helpers.js"></script> |
9 </head> | 9 </head> |
10 <body> | 10 <body> |
11 <script> | 11 <script> |
12 var scope = 'resources/scope/' + location.pathname, | 12 var scope = 'resources/scope/' + location.pathname, |
13 script = 'resources/instrumentation-service-worker.js'; | 13 script = 'resources/instrumentation-service-worker.js'; |
14 | 14 |
15 testRunner.setPermission('notifications', 'granted', location.origin, loca
tion.origin); | 15 testRunner.setPermission('notifications', 'granted', location.origin, loca
tion.origin); |
16 | 16 |
17 async_test(function(test) { | 17 async_test(function(test) { |
18 | 18 |
19 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi
on(workerInfo) { | 19 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi
on(workerInfo) { |
20 assert_inherits(workerInfo.registration, 'showNotification', 'show
Notification() must be exposed.'); | 20 assert_inherits(workerInfo.registration, 'showNotification', 'show
Notification() must be exposed.'); |
21 | 21 |
22 workerInfo.registration.showNotification('Title', { | 22 workerInfo.registration.showNotification('Title', { |
23 actions: [{}] | 23 actions: [{title: "Foo"}] |
| 24 }).then(unreached_fulfillment(test)).catch(function(error) { |
| 25 assert_equals(error.name, 'TypeError'); |
| 26 assert_equals(error.message, "Failed to execute 'showNotificat
ion' on 'ServiceWorkerRegistration': required member action is undefined."); |
| 27 test.done(); |
| 28 }); |
| 29 }).catch(unreached_rejection(test)); |
| 30 |
| 31 }, 'showNotification() must reject if a NotificationAction has no action.'
); |
| 32 |
| 33 async_test(function(test) { |
| 34 |
| 35 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi
on(workerInfo) { |
| 36 assert_inherits(workerInfo.registration, 'showNotification', 'show
Notification() must be exposed.'); |
| 37 |
| 38 workerInfo.registration.showNotification('Title', { |
| 39 actions: [{action: "foo"}] |
24 }).then(unreached_fulfillment(test)).catch(function(error) { | 40 }).then(unreached_fulfillment(test)).catch(function(error) { |
25 assert_equals(error.name, 'TypeError'); | 41 assert_equals(error.name, 'TypeError'); |
26 assert_equals(error.message, "Failed to execute 'showNotificat
ion' on 'ServiceWorkerRegistration': required member title is undefined."); | 42 assert_equals(error.message, "Failed to execute 'showNotificat
ion' on 'ServiceWorkerRegistration': required member title is undefined."); |
27 test.done(); | 43 test.done(); |
28 }); | 44 }); |
29 }).catch(unreached_rejection(test)); | 45 }).catch(unreached_rejection(test)); |
30 | 46 |
31 }, 'showNotification() must reject if an action has no title.'); | 47 }, 'showNotification() must reject if a NotificationAction has no title.')
; |
32 | 48 |
33 async_test(function(test) { | 49 async_test(function(test) { |
34 | 50 |
| 51 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi
on(workerInfo) { |
| 52 assert_inherits(workerInfo.registration, 'showNotification', 'show
Notification() must be exposed.'); |
| 53 |
| 54 workerInfo.registration.showNotification('Title', { |
| 55 actions: [{action: "", title: "Foo"}] |
| 56 }).then(unreached_fulfillment(test)).catch(function(error) { |
| 57 assert_equals(error.name, 'TypeError'); |
| 58 assert_equals(error.message, 'NotificationAction action must n
ot be empty.'); |
| 59 test.done(); |
| 60 }); |
| 61 }).catch(unreached_rejection(test)); |
| 62 |
| 63 }, 'showNotification() must reject if a NotificationAction has an empty ac
tion.'); |
| 64 |
| 65 async_test(function(test) { |
| 66 |
35 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi
on(workerInfo) { | 67 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi
on(workerInfo) { |
36 assert_inherits(workerInfo.registration, 'showNotification', 'show
Notification() must be exposed.'); | 68 assert_inherits(workerInfo.registration, 'showNotification', 'show
Notification() must be exposed.'); |
37 | 69 |
38 workerInfo.registration.showNotification('Title', { | 70 workerInfo.registration.showNotification('Title', { |
39 actions: [{title: ""}] | 71 actions: [{action: "foo", title: ""}] |
40 }).then(unreached_fulfillment(test)).catch(function(error) { | 72 }).then(unreached_fulfillment(test)).catch(function(error) { |
41 assert_equals(error.name, 'TypeError'); | 73 assert_equals(error.name, 'TypeError'); |
42 assert_equals(error.message, 'Notification action titles must
not be empty.'); | 74 assert_equals(error.message, 'NotificationAction title must no
t be empty.'); |
43 test.done(); | 75 test.done(); |
44 }); | 76 }); |
45 }).catch(unreached_rejection(test)); | 77 }).catch(unreached_rejection(test)); |
46 | 78 |
47 }, 'showNotification() must reject if an action has an empty title.'); | 79 }, 'showNotification() must reject if a NotificationAction has an empty ti
tle.'); |
48 </script> | 80 </script> |
49 </body> | 81 </body> |
50 </html> | 82 </html> |
OLD | NEW |