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

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

Issue 2600733002: Convert budget LayoutTests to use promise_test. (Closed)
Patch Set: Changed then scoping and removed unnecessary rejection. Created 3 years, 11 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>getCost with invalid argument fails from a Service Worker</title> 4 <title>getCost with invalid argument fails 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 getActiveServiceWorkerWithMessagePort(test, script, scope) 20 return getActiveServiceWorkerWithMessagePort(test, script, scope);
21 .then(function(workerInfo) { 21 }).then(function(workerInfo) {
22 port = workerInfo.port; 22 port = workerInfo.port;
23 port.postMessage({ command: 'getCostInvalidType' });
24 23
25 port.addEventListener('message', function(event) { 24 port.addEventListener('message', function(event) {
26 if (typeof event.data != 'object' || !event.data.command) 25 if (typeof event.data != 'object' || !event.data.command)
27 assert_unreached('Invalid message from the service worker'); 26 assert_unreached('Invalid message from the service worker');
28 27
29 assert_equals(event.data.command, 'getCostInvalidType'); 28 assert_equals(event.data.command, 'getCostInvalidType');
30 assert_false(event.data.success, 29 assert_false(event.data.success,
31 'getCost should fail with invalid arguments.'); 30 'getCost should fail with invalid arguments.');
32 assert_equals(event.data.errorMessage, "Failed to execute 'getCo st' on 'BudgetService': The provided value 'frobinator' is not a valid enum valu e of type OperationType."); 31 assert_equals(event.data.errorMessage, "Failed to execute 'getCost' on 'BudgetService': The provided value 'frobinator' is not a valid enum value of type OperationType.");
33 test.done(); 32 });
34 }); 33
35 }) 34 return sendCommand(port, { command: 'getCostInvalidType' });
36 .catch(unreached_rejection(test));
37 }); 35 });
38 }, 'getCost with invalid arugment should fail from Service Worker'); 36 }, 'getCost with invalid arugment should fail from Service Worker');
39 </script> 37 </script>
40 </body> 38 </body>
41 </html> 39 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698