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 for |
| 13 // a persistent notification shown by the document. |
| 14 promise_test(test => { |
| 15 var scope = './'; |
| 16 var script = 'instrumentation-service-worker.js'; |
| 17 var port; |
| 18 var iconPath = '/resources/square20.png'; |
| 19 |
| 20 testRunner.setPermission('notifications', 'granted', location.origin,
location.origin); |
| 21 |
| 22 return getActiveServiceWorkerWithMessagePort(test, script, scope).then
(info => { |
| 23 port = info.port; |
| 24 assert_true(!!navigator.serviceWorker.controller, 'The page must b
e controlled.'); |
| 25 // (1) Display a persistent notification from a document context. |
| 26 return info.registration.showNotification('Title', { icon: iconPat
h }); |
| 27 }).then(() => { |
| 28 return sendCommand(port, { command: 'get-fetch-history' }); |
| 29 }).then(data => { |
| 30 // (2) Confirm that the icon request passed through the fetch even
t handler. |
| 31 assert_equals(data.fetchHistory.length, 1); |
| 32 assert_equals(data.fetchHistory[0], location.origin + iconPath); |
| 33 }); |
| 34 }, 'The request for the notification icon is handled by the fetch event ha
ndler.'); |
| 35 </script> |
| 36 </body> |
| 37 </html> |
OLD | NEW |