OLD | NEW |
---|---|
(Empty) | |
1 <!doctype html> | |
2 <html> | |
3 <head> | |
4 <title>Notifications: the fetch handler handles the request for the icon.</t itle> | |
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 request for the notification icon is handled by the fetc h event handler. | |
Peter Beverloo
2016/04/21 17:27:00
nit: + "for a persistent notifications shown by th
Michael van Ouwerkerk
2016/04/22 13:24:09
Done.
| |
13 | |
14 async_test(test => { | |
Peter Beverloo
2016/04/21 17:27:00
Consider using promise_test()?
Michael van Ouwerkerk
2016/04/22 13:24:09
Done.
| |
15 var scope = './'; | |
16 var script = 'instrumentation-service-worker.js'; | |
17 var port; | |
18 var registration; | |
19 var iconPath = '/resources/square20.png'; | |
20 | |
21 testRunner.setPermission('notifications', 'granted', location.origin, location.origin); | |
22 | |
23 getActiveServiceWorkerWithMessagePort(test, script, scope).then(info = > { | |
24 port = info.port; | |
25 registration = info.registration; | |
Peter Beverloo
2016/04/21 17:27:00
nit: unnecessary
Michael van Ouwerkerk
2016/04/22 13:24:09
Done.
| |
26 assert_true(!!navigator.serviceWorker.controller, 'The page must b e controlled.'); | |
27 // (1) Display a persistent notification from a document context. | |
28 return registration.showNotification('Title', { icon: iconPath }); | |
29 }).then(() => { | |
30 return sendCommand(port, { command: 'get-fetch-history' }); | |
31 }).then(data => { | |
32 // (2) Confirm that the icon request passed through the fetch even t handler. | |
33 assert_equals(data.fetchHistory[0], location.origin + iconPath); | |
Peter Beverloo
2016/04/21 17:27:00
assert_equals(data.fetchHistory.length, 1); ?
Michael van Ouwerkerk
2016/04/22 13:24:09
Done.
| |
34 test.done(); | |
35 }).catch(unreached_rejection(test)); | |
36 | |
37 }, 'The request for the notification icon is handled by the fetch event ha ndler.'); | |
38 </script> | |
39 </body> | |
40 </html> | |
OLD | NEW |