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

Side by Side Diff: LayoutTests/push_messaging/push-messaging.html

Issue 367063002: Push API: set mock behavior from layout tests and exercise success. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | LayoutTests/push_messaging/push-messaging-expected.txt » ('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 <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 shouldBeTrue('!!navigator.push');
16 shouldBeTrue('!!navigator.push.register'); 16 shouldBeTrue('!!navigator.push.register');
17
18 window.testRunner.setMockPushClientSuccess('endpoint', 'registrationId');
17 shouldBe('navigator.push.register("senderId").constructor', 'Promise'); 19 shouldBe('navigator.push.register("senderId").constructor', 'Promise');
Peter Beverloo 2014/07/02 16:40:47 Exposure of the API (and the properties/functions
Michael van Ouwerkerk 2014/07/03 14:16:41 Done.
18 20
19 // Currently we have an empty implementation that always fails. 21 function testPushRegistrationError() {
20 navigator.push.register('senderId').then(function successCallback() { 22 window.testRunner.setMockPushClientError('message');
Peter Beverloo 2014/07/02 16:40:47 Four space indent, please.
Michael van Ouwerkerk 2014/07/03 14:16:41 Done.
21 testFailed('Success callback invoked unexpectedly.'); 23 navigator.push.register('senderId').then(function() {
22 finishJSTest(); 24 testFailed('Success callback invoked unexpectedly.');
23 }, function errorCallback(e) { 25 testPushRegistrationSuccess();
24 error = e; 26 }, function(e) {
25 shouldBeEqualToString('error.name', 'AbortError'); 27 error = e;
26 finishJSTest(); 28 shouldBeEqualToString('error.name', 'AbortError');
27 }); 29 testPushRegistrationSuccess();
30 });
31 }
32 testPushRegistrationError();
28 33
34 function testPushRegistrationSuccess() {
35 window.testRunner.setMockPushClientSuccess('endpoint', 'registrationId');
36 navigator.push.register('senderId').then(function(reg) {
37 registration = reg;
38 shouldBeEqualToString('registration.pushEndpoint', 'endpoint');
39 shouldBeEqualToString('registration.pushRegistrationId', 'registrationId') ;
40 finishJSTest();
41 }, function(e) {
42 testFailed('Error callback invoked unexpectedly.');
43 finishJSTest();
44 });
45 }
29 </script> 46 </script>
30 </body> 47 </body>
31 </html> 48 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/push_messaging/push-messaging-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698