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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/budget/get-budget-in-service-worker.html

Issue 2600733002: Convert budget LayoutTests to use promise_test. (Closed)
Patch Set: Created 3 years, 12 months 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/budget/get-cost-fails-in-service-worker.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>getBudget succeeds from a Service Worker</title> 4 <title>getBudget succeeds from a 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="../notifications/resources/test-helpers.js"></script> 8 <script src="../notifications/resources/test-helpers.js"></script>
9 <script src="/js-test-resources/mojo-helpers.js"></script> 9 <script src="/js-test-resources/mojo-helpers.js"></script>
10 <script src="budget-service-mock.js"></script> 10 <script src="budget-service-mock.js"></script>
11 </head> 11 </head>
12 <body> 12 <body>
13 <script> 13 <script>
14 async_test(function(test) { 14 promise_test(function(test) {
15 var script = 'resources/instrumentation-service-worker.js'; 15 const script = 'resources/instrumentation-service-worker.js';
16 var scope = 'resources/scope/' + location.pathname; 16 const scope = 'resources/scope/' + location.pathname;
17 var port; 17 let port;
18 18
19 budgetServiceMock.then(mock => { 19 return budgetServiceMock.then(mock => {
20 mock.addBudget(TEST_BUDGET_TIME, TEST_BUDGET_AT); 20 mock.addBudget(TEST_BUDGET_TIME, TEST_BUDGET_AT);
21 getActiveServiceWorkerWithMessagePort(test, script, scope) 21 return getActiveServiceWorkerWithMessagePort(test, script, scope)
22 .then(function(workerInfo) { 22 .then(function(workerInfo) {
Peter Beverloo 2017/01/04 18:18:11 nit: I'd move the .then() a level up, i.e. return
harkness 2017/01/06 13:37:09 Done.
23 port = workerInfo.port; 23 port = workerInfo.port;
24 port.postMessage({command: 'getBudget'});
25 24
26 port.addEventListener('message', function(event) { 25 port.addEventListener('message', function(event) {
27 if (typeof event.data != 'object' || !event.data.command) 26 if (typeof event.data != 'object' || !event.data.command)
28 assert_unreached('Invalid message from the service worker'); 27 assert_unreached('Invalid message from the service worker');
29 28
30 assert_equals(event.data.command, 'getBudget'); 29 assert_equals(event.data.command, 'getBudget');
31 assert_true(event.data.success, 30 assert_true(event.data.success,
32 'getBudget should succeed. Error message: ' + event.data.err orMessage); 31 'getBudget should succeed. Error message: ' + event.data.err orMessage);
33 assert_equals(event.data.budgetAt, TEST_BUDGET_AT); 32 assert_equals(event.data.budgetAt, TEST_BUDGET_AT);
34 assert_equals(event.data.time, TEST_BUDGET_TIME); 33 assert_equals(event.data.time, TEST_BUDGET_TIME);
35 test.done();
36 }); 34 });
35
36 return sendCommand(port, { command: 'getBudget' });
37 }) 37 })
38 .catch(unreached_rejection(test)); 38 .catch(unreached_rejection(test));
Peter Beverloo 2017/01/04 18:18:11 You should drop these - a rejection in a promise_t
harkness 2017/01/06 13:37:09 Done.
39 }); 39 });
40 }, 'getBudget should succeed from Service Worker'); 40 }, 'getBudget should succeed from Service Worker');
41 </script> 41 </script>
42 </body> 42 </body>
43 </html> 43 </html>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/budget/get-cost-fails-in-service-worker.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698