| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="../resources/js-test.js"></script> | 4 <script src="../resources/js-test.js"></script> |
| 5 </head> | 5 </head> |
| 6 <body> | 6 <body> |
| 7 <script> | 7 <script> |
| 8 description('Tests for the Push API.'); | 8 description('Tests for the Push API.'); |
| 9 | 9 |
| 10 if (!window.testRunner) | 10 if (!window.testRunner) |
| 11 debug('This test can not run without testRunner'); | 11 debug('This test can not run without testRunner'); |
| 12 | 12 |
| 13 window.jsTestIsAsync = true; | 13 window.jsTestIsAsync = true; |
| 14 | 14 |
| 15 shouldBeTrue('!!navigator.push'); | 15 function testPushRegistrationError() { |
| 16 shouldBeTrue('!!navigator.push.register'); | 16 window.testRunner.setMockPushClientError('message'); |
| 17 shouldBe('navigator.push.register("senderId").constructor', 'Promise'); | 17 navigator.push.register('senderId').then(function() { |
| 18 testFailed('Success callback invoked unexpectedly.'); |
| 19 testPushRegistrationSuccess(); |
| 20 }, function(e) { |
| 21 error = e; |
| 22 shouldBeEqualToString('error.name', 'AbortError'); |
| 23 testPushRegistrationSuccess(); |
| 24 }); |
| 25 } |
| 26 testPushRegistrationError(); |
| 18 | 27 |
| 19 // Currently we have an empty implementation that always fails. | 28 function testPushRegistrationSuccess() { |
| 20 navigator.push.register('senderId').then(function successCallback() { | 29 window.testRunner.setMockPushClientSuccess('endpoint', 'registrationId'); |
| 21 testFailed('Success callback invoked unexpectedly.'); | 30 navigator.push.register('senderId').then(function(reg) { |
| 22 finishJSTest(); | 31 registration = reg; |
| 23 }, function errorCallback(e) { | 32 shouldBeEqualToString('registration.pushEndpoint', 'endpoint'); |
| 24 error = e; | 33 shouldBeEqualToString('registration.pushRegistrationId', 'registrationId
'); |
| 25 shouldBeEqualToString('error.name', 'AbortError'); | 34 finishJSTest(); |
| 26 finishJSTest(); | 35 }, function(e) { |
| 27 }); | 36 testFailed('Error callback invoked unexpectedly.'); |
| 28 | 37 finishJSTest(); |
| 38 }); |
| 39 } |
| 29 </script> | 40 </script> |
| 30 </body> | 41 </body> |
| 31 </html> | 42 </html> |
| OLD | NEW |