OLD | NEW |
---|---|
1 <!doctype html> | 1 <!doctype html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>Notifications: ServiceWorkerRegistration.showNotification() fails on too much data.</title> | 4 <title>Notifications: Verifying the exception throwing behavior, when data s et invalid value such as method.</title> |
Peter Beverloo
2015/04/21 12:26:36
micro nit: as *a* method.
Sanghyun Park
2015/04/21 13:38:34
Done.
| |
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="resources/test-helpers.js"></script> | 8 <script src="resources/test-helpers.js"></script> |
9 </head> | 9 </head> |
10 <body> | 10 <body> |
11 <script> | 11 <script> |
12 // Tests that the showNotification() function rejects the promise when the | 12 // Tests that the showNotification() function rejects the returned promise with a |
13 // developer-provided data exceeds a megabyte. This is an implementation- | 13 // DataCloneError when data set invalid data such as method. |
14 // defined limit to prevent abuse. | |
15 | 14 |
16 async_test(function(test) { | 15 async_test(function(test) { |
17 var scope = 'resources/scope/' + location.pathname, | 16 var scope = 'resources/scope/' + location.pathname, |
18 script = 'resources/instrumentation-service-worker.js'; | 17 script = 'resources/instrumentation-service-worker.js'; |
19 | 18 |
20 testRunner.grantWebNotificationPermission(location.origin, true); | 19 testRunner.grantWebNotificationPermission(location.origin, true); |
21 | 20 |
22 var workerInfo = null; | 21 var workerInfo = null; |
23 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi on(info) { | 22 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi on(info) { |
24 workerInfo = info; | 23 workerInfo = info; |
25 | 24 |
26 // (1) Display a Web Notification from the document. | 25 // (1) Display a Web Notification from the document. |
27 assert_inherits(workerInfo.registration, 'showNotification', 'show Notification() must be exposed.'); | 26 assert_inherits(workerInfo.registration, 'showNotification', 'show Notification() must be exposed.'); |
28 return workerInfo.registration.showNotification(scope, { | 27 workerInfo.registration.showNotification(scope, { |
29 body: 'Hello, world!', | 28 data: function() { return 1; } |
30 icon: '/icon.png', | 29 }).then(function() { |
Peter Beverloo
2015/04/21 12:26:36
then(unreached_fulfillment(test))
Sanghyun Park
2015/04/21 13:38:34
Done.
| |
31 data: new Array(1024 * 1024 * 2).join('.'), // 2 million dots | 30 assert_unreached('showNotification() is expected to reject.'); |
31 }).catch(function(error) { | |
32 assert_equals(error.name, 'DataCloneError'); | |
33 test.done(); | |
32 }); | 34 }); |
33 }).then(unreached_fulfillment(test)) | 35 }).catch(unreached_rejection(test)); |
34 .catch(function() { | |
35 test.done(); | |
36 }); | |
37 | 36 |
38 }, 'ServiceWorkerRegistration.showNotification() fails on too much data.') ; | 37 }, 'showNotification() must reject If data is invalid value.'); |
Peter Beverloo
2015/04/21 12:26:36
micro nit: s/If/if/
Sanghyun Park
2015/04/21 13:38:34
Done.
| |
39 </script> | 38 </script> |
40 </body> | 39 </body> |
41 </html> | 40 </html> |
OLD | NEW |