| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>Stringifying a PushSubscription object includes all object members</title
> | 4 <title>Stringifying a PushSubscription object includes all object members</title
> |
| 5 <link rel="manifest" href="resources/push_manifest.json"> | 5 <link rel="manifest" href="resources/push_manifest.json"> |
| 6 <script src="../resources/testharness.js"></script> | 6 <script src="../resources/testharness.js"></script> |
| 7 <script src="../resources/testharnessreport.js"></script> | 7 <script src="../resources/testharnessreport.js"></script> |
| 8 <script src="../resources/testharness-helpers.js"></script> | 8 <script src="../resources/testharness-helpers.js"></script> |
| 9 <script src="../serviceworker/resources/test-helpers.js"></script> | 9 <script src="../serviceworker/resources/test-helpers.js"></script> |
| 10 </head> | 10 </head> |
| 11 <body> | 11 <body> |
| 12 <script> | 12 <script> |
| 13 async_test(function(test) { | 13 async_test(function(test) { |
| 14 var workerUrl = 'resources/empty_worker.js'; | 14 var workerUrl = 'resources/empty_worker.js'; |
| 15 var workerScope = 'resources/scope/' + location.pathname; | 15 var workerScope = 'resources/scope/' + location.pathname; |
| 16 var swRegistration; | 16 var swRegistration; |
| 17 service_worker_unregister_and_register(test, workerUrl, workerScope) | 17 service_worker_unregister_and_register(test, workerUrl, workerScope) |
| 18 .then(function(serviceWorkerRegistration) { | 18 .then(function(serviceWorkerRegistration) { |
| 19 swRegistration = serviceWorkerRegistration; | 19 swRegistration = serviceWorkerRegistration; |
| 20 return wait_for_state(test, swRegistration.installing, 'activated'); | 20 return wait_for_state(test, swRegistration.installing, 'activated'); |
| 21 }) | 21 }) |
| 22 .then(function() { | 22 .then(function() { |
| 23 // If running manually, grant permission when prompted. | 23 // If running manually, grant permission when prompted. |
| 24 if (window.testRunner) | 24 if (window.testRunner) |
| 25 testRunner.setPermission('push-messaging', 'granted', location.o
rigin, location.origin); | 25 testRunner.setPermission('push-messaging', 'granted', location.o
rigin, location.origin); |
| 26 return swRegistration.pushManager.subscribe(); | 26 return swRegistration.pushManager.subscribe(); |
| 27 }) | 27 }) |
| 28 .then(function(pushSubscription) { | 28 .then(function(pushSubscription) { |
| 29 var reflectedObject = JSON.parse(JSON.stringify(pushSubscription)); | 29 var reflectedObject = JSON.parse(JSON.stringify(pushSubscription)); |
| 30 var expectedProperties = ['endpoint', 'subscriptionId']; | 30 var expectedProperties = ['endpoint']; |
| 31 | 31 |
| 32 assert_equals(expectedProperties.length, | 32 assert_equals(expectedProperties.length, |
| 33 Object.getOwnPropertyNames(reflectedObject).length); | 33 Object.getOwnPropertyNames(reflectedObject).length); |
| 34 | 34 |
| 35 for (var key of expectedProperties) | 35 for (var key of expectedProperties) |
| 36 assert_equals(reflectedObject[key], pushSubscription[key]); | 36 assert_equals(reflectedObject[key], pushSubscription[key]); |
| 37 | 37 |
| 38 return service_worker_unregister_and_done(test, workerScope); | 38 return service_worker_unregister_and_done(test, workerScope); |
| 39 }) | 39 }) |
| 40 .catch(unreached_rejection(test)); | 40 .catch(unreached_rejection(test)); |
| 41 }, 'Stringifying a PushSubscription object includes all object members'); | 41 }, 'Stringifying a PushSubscription object includes all object members'); |
| 42 </script> | 42 </script> |
| 43 </body> | 43 </body> |
| 44 </html> | 44 </html> |
| OLD | NEW |