OLD | NEW |
1 <!doctype html> | 1 <!doctype html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>Notifications: ServiceWorkerRegistration.getNotifications() when crea
ted by the Service Worker.</title> | 4 <title>Notifications: ServiceWorkerRegistration.getNotifications() when crea
ted by the Service Worker.</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 // Tests that the getNotifications() function when used in a document retu
rns | 12 // Tests that the getNotifications() function when used in a document retu
rns |
13 // an array of the notifications which were previously displayed by the | 13 // an array of the notifications which were previously displayed by the |
14 // Service Worker. | 14 // Service Worker. |
15 async_test(function(test) { | 15 async_test(function(test) { |
16 var scope = 'resources/scope/' + location.pathname, | 16 var scope = 'resources/scope/' + location.pathname, |
17 script = 'resources/instrumentation-service-worker.js'; | 17 script = 'resources/instrumentation-service-worker.js'; |
18 | 18 |
19 testRunner.setPermission('notifications', 'granted', location.origin,
location.origin); | 19 testRunner.setPermission('notifications', 'granted', location.origin,
location.origin); |
20 testRunner.grantWebNotificationPermission(location.origin, true); | |
21 | 20 |
22 var info = null; | 21 var info = null; |
23 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi
on(workerInfo) { | 22 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi
on(workerInfo) { |
24 info = workerInfo; | 23 info = workerInfo; |
25 | 24 |
26 // (1) Tell the Service Worker to display a new Notification and w
ait for it | 25 // (1) Tell the Service Worker to display a new Notification and w
ait for it |
27 // to have been displayed to the user. | 26 // to have been displayed to the user. |
28 info.port.postMessage({ | 27 info.port.postMessage({ |
29 command: 'show', | 28 command: 'show', |
30 | 29 |
(...skipping 23 matching lines...) Expand all Loading... |
54 assert_equals(notifications[0].body, 'Hello, world!'); | 53 assert_equals(notifications[0].body, 'Hello, world!'); |
55 | 54 |
56 test.done(); | 55 test.done(); |
57 | 56 |
58 }).catch(unreached_rejection(test)); | 57 }).catch(unreached_rejection(test)); |
59 | 58 |
60 }, 'ServiceWorkerRegistration.getNotifications() when created by a Service
Worker.'); | 59 }, 'ServiceWorkerRegistration.getNotifications() when created by a Service
Worker.'); |
61 </script> | 60 </script> |
62 </body> | 61 </body> |
63 </html> | 62 </html> |
OLD | NEW |