OLD | NEW |
1 importScripts('../../serviceworker/resources/worker-testharness.js'); | 1 importScripts('../../serviceworker/resources/worker-testharness.js'); |
2 | 2 |
3 let messagePort = null; | 3 let messagePort = null; |
4 addEventListener('message', workerEvent => { | 4 addEventListener('message', workerEvent => { |
5 messagePort = workerEvent.data; | 5 messagePort = workerEvent.data; |
6 messagePort.postMessage('ready'); | 6 messagePort.postMessage('ready'); |
7 }); | 7 }); |
8 | 8 |
9 addEventListener('notificationclick', e => runTest(e.notification)); | 9 addEventListener('notificationclick', e => runTest(e.notification)); |
10 | 10 |
11 // Test body for the serviceworker-notification-event.html layout test. | 11 // Test body for the serviceworker-notification-event.html layout test. |
12 function runTest(notification) { | 12 function runTest(notification) { |
13 assert_true('NotificationEvent' in self); | 13 assert_true('NotificationEvent' in self); |
14 | 14 |
15 assert_throws(null, () => new NotificationEvent('NotificationEvent')); | 15 assert_throws(null, () => new NotificationEvent('NotificationEvent')); |
16 assert_throws(null, () => new NotificationEvent('NotificationEvent', {})); | 16 assert_throws(null, () => new NotificationEvent('NotificationEvent', {})); |
| 17 assert_throws(null, () => new NotificationEvent('NotificationEvent', { notif
ication: null })); |
17 | 18 |
18 const event = new NotificationEvent('NotificationEvent', { notification }); | 19 const event = new NotificationEvent('NotificationEvent', { notification }); |
19 | 20 |
20 assert_equals(event.type, 'NotificationEvent'); | 21 assert_equals(event.type, 'NotificationEvent'); |
21 assert_idl_attribute(event, 'notification'); | 22 assert_idl_attribute(event, 'notification'); |
22 assert_idl_attribute(event, 'action'); | 23 assert_idl_attribute(event, 'action'); |
23 assert_equals(event.cancelable, false); | 24 assert_equals(event.cancelable, false); |
24 assert_equals(event.bubbles, false); | 25 assert_equals(event.bubbles, false); |
25 assert_equals(event.notification, notification); | 26 assert_equals(event.notification, notification); |
26 assert_equals(event.action, ''); | 27 assert_equals(event.action, ''); |
27 assert_inherits(event, 'waitUntil'); | 28 assert_inherits(event, 'waitUntil'); |
28 | 29 |
29 const customEvent = new NotificationEvent('NotificationEvent', { | 30 const customEvent = new NotificationEvent('NotificationEvent', { |
30 notification: notification, | 31 notification: notification, |
31 bubbles: true, | 32 bubbles: true, |
32 cancelable: true }); | 33 cancelable: true }); |
33 | 34 |
34 assert_equals(customEvent.type, 'NotificationEvent'); | 35 assert_equals(customEvent.type, 'NotificationEvent'); |
35 assert_equals(customEvent.cancelable, true); | 36 assert_equals(customEvent.cancelable, true); |
36 assert_equals(customEvent.bubbles, true); | 37 assert_equals(customEvent.bubbles, true); |
37 assert_equals(customEvent.notification, notification); | 38 assert_equals(customEvent.notification, notification); |
38 | 39 |
39 // Signal to the document that the test has finished running. | 40 // Signal to the document that the test has finished running. |
40 messagePort.postMessage(true /* success */); | 41 messagePort.postMessage(true /* success */); |
41 } | 42 } |
OLD | NEW |