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

Side by Side Diff: LayoutTests/http/tests/notifications/serviceworkerregistration-document-actions-throw.html

Issue 1263043003: Add NotificationAction.action member (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@actions
Patch Set: Rebase Created 5 years, 4 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>Notifications: Check that showNotifications rejects if actions is set incorrectly.</title> 4 <title>Notifications: Check that showNotifications rejects if actions is set incorrectly.</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="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 serviceWorkerRegistration.showNotification throws a 12 // Tests that serviceWorkerRegistration.showNotification throws a
13 // TypeError if NotificationOptions.actions is set incorrectly. 13 // TypeError if NotificationOptions.actions is set incorrectly.
14 var script = 'resources/instrumentation-service-worker.js'; 14 var script = 'resources/instrumentation-service-worker.js';
15 15
16 testRunner.setPermission('notifications', 'granted', location.origin, loca tion.origin); 16 testRunner.setPermission('notifications', 'granted', location.origin, loca tion.origin);
17 17
18 async_test(function(test) { 18 async_test(function(test) {
19 var scope = 'resources/scope/' + location.pathname + "/notitle"; 19 var scope = 'resources/scope/' + location.pathname + "/notitle";
20 20
21 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi on(workerInfo) { 21 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi on(workerInfo) {
22 assert_inherits(workerInfo.registration, 'showNotification', 'show Notification() must be exposed.'); 22 assert_inherits(workerInfo.registration, 'showNotification', 'show Notification() must be exposed.');
23 23
24 workerInfo.registration.showNotification('Title', { 24 workerInfo.registration.showNotification('Title', {
25 actions: [{}] 25 actions: [{ title: "Foo" }]
26 }).then(unreached_fulfillment(test)).catch(function(error) {
27 assert_equals(error.name, 'TypeError');
28 assert_equals(error.message, "Failed to execute 'showNotificat ion' on 'ServiceWorkerRegistration': required member action is undefined.");
29 test.done();
30 });
31 }).catch(unreached_rejection(test));
32
33 }, 'showNotification() must reject if a NotificationAction has no action.' );
34
35 async_test(function(test) {
36
37 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi on(workerInfo) {
38 assert_inherits(workerInfo.registration, 'showNotification', 'show Notification() must be exposed.');
39
40 workerInfo.registration.showNotification('Title', {
41 actions: [{ action: "foo" }]
26 }).then(unreached_fulfillment(test)).catch(function(error) { 42 }).then(unreached_fulfillment(test)).catch(function(error) {
27 assert_equals(error.name, 'TypeError'); 43 assert_equals(error.name, 'TypeError');
28 assert_equals(error.message, "Failed to execute 'showNotificat ion' on 'ServiceWorkerRegistration': required member title is undefined."); 44 assert_equals(error.message, "Failed to execute 'showNotificat ion' on 'ServiceWorkerRegistration': required member title is undefined.");
29 test.done(); 45 test.done();
30 }); 46 });
31 }).catch(unreached_rejection(test)); 47 }).catch(unreached_rejection(test));
32 48
33 }, 'showNotification() must reject if an action has no title.'); 49 }, 'showNotification() must reject if a NotificationAction has no title.') ;
50
51 async_test(function(test) {
52
53 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi on(workerInfo) {
54 assert_inherits(workerInfo.registration, 'showNotification', 'show Notification() must be exposed.');
55
56 workerInfo.registration.showNotification('Title', {
57 actions: [{ action: "", title: "Foo" }]
58 }).then(unreached_fulfillment(test)).catch(function(error) {
59 assert_equals(error.name, 'TypeError');
60 assert_equals(error.message, 'NotificationAction action must n ot be empty.');
61 test.done();
62 });
63 }).catch(unreached_rejection(test));
64
65 }, 'showNotification() must reject if a NotificationAction has an empty ac tion.');
34 66
35 async_test(function(test) { 67 async_test(function(test) {
36 var scope = 'resources/scope/' + location.pathname + "/emptytitle"; 68 var scope = 'resources/scope/' + location.pathname + "/emptytitle";
37 69
38 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi on(workerInfo) { 70 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi on(workerInfo) {
39 assert_inherits(workerInfo.registration, 'showNotification', 'show Notification() must be exposed.'); 71 assert_inherits(workerInfo.registration, 'showNotification', 'show Notification() must be exposed.');
40 72
41 workerInfo.registration.showNotification('Title', { 73 workerInfo.registration.showNotification('Title', {
42 actions: [{title: ""}] 74 actions: [{ action: "foo", title: "" }]
43 }).then(unreached_fulfillment(test)).catch(function(error) { 75 }).then(unreached_fulfillment(test)).catch(function(error) {
44 assert_equals(error.name, 'TypeError'); 76 assert_equals(error.name, 'TypeError');
45 assert_equals(error.message, 'Notification action titles must not be empty.'); 77 assert_equals(error.message, 'NotificationAction title must no t be empty.');
46 test.done(); 78 test.done();
47 }); 79 });
48 }).catch(unreached_rejection(test)); 80 }).catch(unreached_rejection(test));
49 81
50 }, 'showNotification() must reject if an action has an empty title.'); 82 }, 'showNotification() must reject if a NotificationAction has an empty ti tle.');
51 </script> 83 </script>
52 </body> 84 </body>
53 </html> 85 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698