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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/notifications/serviceworker-notification-properties.html

Issue 1644573002: Notification actions may have an icon url. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 10 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: Property reflection in the "notificationclick" event a nd SWR.getNotifications().</title> 4 <title>Notifications: Property reflection in the "notificationclick" event a nd SWR.getNotifications().</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>
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 { property: 'foobar', 45 { property: 'foobar',
46 string: '\uDFFF\u0000\uDBFF', 46 string: '\uDFFF\u0000\uDBFF',
47 scalar: true }, 47 scalar: true },
48 12.15 48 12.15
49 ], 49 ],
50 actions: [] 50 actions: []
51 }; 51 };
52 // Deliberately add more actions than are supported. 52 // Deliberately add more actions than are supported.
53 for (var i = 0; i < 2 * Notification.maxActions; i++) { 53 for (var i = 0; i < 2 * Notification.maxActions; i++) {
54 options.actions.push({ 54 options.actions.push({
55 action: "a" + i, 55 action: 'a' + i,
56 title: "Action " + i 56 title: 'Action ' + i,
57 icon: 'https://example/action_icon_' + i + '.png'
57 }); 58 });
58 } 59 }
59 60
60 testRunner.setPermission('notifications', 'granted', location.origin, location.origin); 61 if (window.testRunner) {
62 testRunner.setPermission('notifications', 'granted', location.orig in, location.origin);
63 }
61 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi on(workerInfo) { 64 getActiveServiceWorkerWithMessagePort(test, script, scope).then(functi on(workerInfo) {
62 // (1) Tell the Service Worker to display a Web Notification. 65 // (1) Tell the Service Worker to display a Web Notification.
63 workerInfo.port.postMessage({ 66 workerInfo.port.postMessage({
64 command: 'show', 67 command: 'show',
65 68
66 title: scope, 69 title: scope,
67 options: options 70 options: options
68 }); 71 });
69 72
70 // Now limit actions to the number that we expect to be reflected on notifications. 73 // Now limit actions to the number that we expect to be reflected on notifications.
71 options.actions = options.actions.slice(0, Notification.maxActions ); 74 options.actions = options.actions.slice(0, Notification.maxActions );
72 75
73 workerInfo.port.addEventListener('message', function(event) { 76 workerInfo.port.addEventListener('message', function(event) {
74 if (typeof event.data != 'object' || !event.data.command) { 77 if (typeof event.data != 'object' || !event.data.command) {
75 assert_unreached('Invalid message from the Service Worker. '); 78 assert_unreached('Invalid message from the Service Worker. ');
76 return; 79 return;
77 } 80 }
78 81
79 // (2) Listen for confirmation from the Service Worker that th e 82 // (2) Listen for confirmation from the Service Worker that th e
80 // notification's display promise has been resolved. 83 // notification's display promise has been resolved.
81 if (event.data.command == 'show') { 84 if (event.data.command == 'show') {
82 assert_true(event.data.success, 'The notification must hav e been displayed.'); 85 assert_true(event.data.success, 'The notification must hav e been displayed.');
83 testRunner.simulateWebNotificationClick(scope, -1 /* actio n_index */); 86 if (window.testRunner) {
87 testRunner.simulateWebNotificationClick(scope, -1 /* a ction_index */);
88 }
84 return; 89 return;
85 } 90 }
86 91
87 // (3) Listen for confirmation from the Service Worker that th e 92 // (3) Listen for confirmation from the Service Worker that th e
88 // notification has been clicked on. Make sure that all proper ties 93 // notification has been clicked on. Make sure that all proper ties
89 // set on the cloned Notification object are as expected. 94 // set on the cloned Notification object are as expected.
90 assert_equals(event.data.command, 'click', 'The notification w as expected to be clicked.'); 95 assert_equals(event.data.command, 'click', 'The notification w as expected to be clicked.');
91 assert_object_is_superset(event.data.notification, options, 'T he Notification object properties must be the same in notificationclick events.' ); 96 assert_object_is_superset(event.data.notification, options, 'T he Notification object properties must be the same in notificationclick events.' );
92 97
93 // (4) Check that the properties are also set correctly on the 98 // (4) Check that the properties are also set correctly on the
94 // non-cloned Notification object from getNotifications. 99 // non-cloned Notification object from getNotifications.
95 workerInfo.registration.getNotifications().then(function(notif ications) { 100 workerInfo.registration.getNotifications().then(function(notif ications) {
96 assert_equals(notifications.length, 1); 101 assert_equals(notifications.length, 1);
97 assert_object_is_superset(notifications[0], options, 'The Notification object properties must be the same in getNotifications.'); 102 assert_object_is_superset(notifications[0], options, 'The Notification object properties must be the same in getNotifications.');
98 103
99 notifications[0].actions.foo = "bar"; 104 notifications[0].actions.foo = 'bar';
100 notifications[0].actions.push({ title: "Foo" }); 105 notifications[0].actions.push({ title: 'Foo' });
101 if (notifications[0].actions.length) { 106 if (notifications[0].actions.length) {
102 notifications[0].actions[0].title = "Changed"; 107 notifications[0].actions[0].title = 'Changed';
103 notifications[0].actions[0].foo = "bar"; 108 notifications[0].actions[0].foo = 'bar';
104 } 109 }
105 assert_object_equals(notifications[0].actions, options.act ions, 'The actions field should be immutable.'); 110 assert_object_equals(notifications[0].actions, options.act ions, 'The actions field should be immutable.');
106 111
107 // TODO(johnme): This should pass before shipping Notifica tion.actions; this is blocked on https://crbug.com/515920. 112 // TODO(johnme): This should pass before shipping Notifica tion.actions; this is blocked on https://crbug.com/515920.
108 //assert_equals(notifications[0].actions, notifications[0] .actions, 'The actions field should === itself.'); 113 //assert_equals(notifications[0].actions, notifications[0] .actions, 'The actions field should === itself.');
109 114
110 test.done(); 115 test.done();
111 }); 116 });
112 }); 117 });
113 }).catch(unreached_rejection(test)); 118 }).catch(unreached_rejection(test));
114 119
115 }, 'Clicking on a notification displayed by a Service Worker the notificat ionclick event.'); 120 }, 'Clicking on a notification displayed by a Service Worker the notificat ionclick event.');
116 </script> 121 </script>
117 </body> 122 </body>
118 </html> 123 </html>
OLDNEW
« no previous file with comments | « content/public/common/platform_notification_data.h ('k') | third_party/WebKit/Source/modules/notifications/Notification.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698