Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/http/tests/notifications/serviceworkerregistration-document-fetch-resources.html |
| diff --git a/third_party/WebKit/LayoutTests/http/tests/notifications/serviceworkerregistration-document-fetch-resources.html b/third_party/WebKit/LayoutTests/http/tests/notifications/serviceworkerregistration-document-fetch-resources.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f51881d6814c38b2bab881a75e46253a001629d2 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/http/tests/notifications/serviceworkerregistration-document-fetch-resources.html |
| @@ -0,0 +1,40 @@ |
| +<!doctype html> |
| +<html> |
| + <head> |
| + <title>Notifications: the fetch handler handles the request for the icon.</title> |
| + <script src="../resources/testharness.js"></script> |
| + <script src="../resources/testharnessreport.js"></script> |
| + <script src="../serviceworker/resources/test-helpers.js"></script> |
| + <script src="resources/test-helpers.js"></script> |
| + </head> |
| + <body> |
| + <script> |
| + // Tests that the request for the notification icon is handled by the fetch 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.
|
| + |
| + 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.
|
| + var scope = './'; |
| + var script = 'instrumentation-service-worker.js'; |
| + var port; |
| + var registration; |
| + var iconPath = '/resources/square20.png'; |
| + |
| + testRunner.setPermission('notifications', 'granted', location.origin, location.origin); |
| + |
| + getActiveServiceWorkerWithMessagePort(test, script, scope).then(info => { |
| + port = info.port; |
| + registration = info.registration; |
|
Peter Beverloo
2016/04/21 17:27:00
nit: unnecessary
Michael van Ouwerkerk
2016/04/22 13:24:09
Done.
|
| + assert_true(!!navigator.serviceWorker.controller, 'The page must be controlled.'); |
| + // (1) Display a persistent notification from a document context. |
| + return registration.showNotification('Title', { icon: iconPath }); |
| + }).then(() => { |
| + return sendCommand(port, { command: 'get-fetch-history' }); |
| + }).then(data => { |
| + // (2) Confirm that the icon request passed through the fetch event handler. |
| + 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.
|
| + test.done(); |
| + }).catch(unreached_rejection(test)); |
| + |
| + }, 'The request for the notification icon is handled by the fetch event handler.'); |
| + </script> |
| + </body> |
| +</html> |