Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(409)

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/notifications/serviceworkerregistration-service-worker-fetch-resources.html

Issue 2478153003: Fix notification test to return a promise. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!doctype html> 1 <!doctype html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>Notifications: the fetch handler handles the request for the icon.</t itle> 4 <title>Notifications: the fetch handler handles the request for the icon.</t itle>
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 request for the notification icon is handled by the fetc h event handler for 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 service worker. 13 // a persistent notification shown by the service worker.
14 promise_test(test => { 14 promise_test(test => {
15 var scope = './'; 15 var scope = './';
16 var script = 'instrumentation-service-worker.js'; 16 var script = 'instrumentation-service-worker.js';
17 var port; 17 var port;
18 var iconPath = '/resources/square20.png'; 18 var iconPath = '/resources/square20.png';
19 19
20 testRunner.setPermission('notifications', 'granted', location.origin, location.origin); 20 testRunner.setPermission('notifications', 'granted', location.origin, location.origin);
21 21
22 getActiveServiceWorkerWithMessagePort(test, script, scope).then(info = > { 22 return getActiveServiceWorkerWithMessagePort(test, script, scope).then (info => {
23 port = info.port; 23 port = info.port;
24 assert_true(!!navigator.serviceWorker.controller, 'The page must b e controlled.'); 24 assert_true(!!navigator.serviceWorker.controller, 'The page must b e controlled.');
25 // (1) Display a persistent notification from a service worker con text. 25 // (1) Display a persistent notification from a service worker con text.
26 return sendCommand(port, { 26 return sendCommand(port, {
27 command: 'show', 27 command: 'show',
28 title: 'Title', 28 title: 'Title',
29 options: { icon: iconPath } 29 options: { icon: iconPath }
30 }); 30 });
31 }).then(data => { 31 }).then(data => {
32 assert_true(data.success); 32 assert_true(data.success);
33 return sendCommand(port, { command: 'get-fetch-history' }); 33 return sendCommand(port, { command: 'get-fetch-history' });
34 }).then(data => { 34 }).then(data => {
35 // (2) Verify that the icon request passed through the fetch event handler. 35 // (2) Verify that the icon request passed through the fetch event handler.
36 // TODO(mvanouwerkerk): The fetch should go through the worker - c rbug.com/605917. 36 // TODO(mvanouwerkerk): The fetch should go through the worker - c rbug.com/605917.
37 assert_equals(data.fetchHistory.length, 0); 37 assert_equals(data.fetchHistory.length, 0);
38 }); 38 });
39 }, 'The request for the notification icon is handled by the fetch event ha ndler.'); 39 }, 'The request for the notification icon is handled by the fetch event ha ndler.');
40 </script> 40 </script>
41 </body> 41 </body>
42 </html> 42 </html>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/notifications/serviceworkerregistration-service-worker-fetch-resources-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698