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

Side by Side Diff: chrome/test/data/notifications/notification_tester.html

Issue 2729613006: When navigation focuses a web contents, also activate its window. (Closed)
Patch Set: Copyright + nits Created 3 years, 9 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
« no previous file with comments | « chrome/test/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <html> 1 <html>
2 <!--notification_tester.html 2 <!--notification_tester.html
3 Script with javascript functions for creating and canceling notifications. 3 Script with javascript functions for creating and canceling notifications.
4 Also can be used to request permission for notifications. 4 Also can be used to request permission for notifications.
5 --> 5 -->
6 <script> 6 <script>
7 7
8 // Array of all notifications this page has created. 8 // Array of all notifications this page has created.
9 var g_notifications = []; 9 var g_notifications = [];
10 // Whether the site has requested and been granted permission. 10 // Whether the site has requested and been granted permission.
11 var g_permissionGranted = false; 11 var g_permissionGranted = false;
12 12
13 // Creates a notification with a iconUrl, title, text, and tag. 13 // Creates a notification with a iconUrl, title, text, and tag.
14 // Returns an id for the notification, which can be used to cancel it with 14 // Returns an id for the notification, which can be used to cancel it with
15 // |cancelNotification|. If two notifications are created with the same 15 // |cancelNotification|. If two notifications are created with the same
16 // tag, the second one should replace the first. 16 // tag, the second one should replace the first.
17 function createNotification(iconUrl, title, text, tag) { 17 function createNotification(iconUrl, title, text, tag, onclick) {
18 var notification = new Notification(title, { 18 var notification = new Notification(title, {
19 icon: iconUrl, 19 icon: iconUrl,
20 body: text, 20 body: text,
21 tag: tag 21 tag: tag
22 }); 22 });
23 notification.onclick = onclick;
23 24
24 createNotificationHelper(notification, true); 25 createNotificationHelper(notification, true);
25 } 26 }
26 27
27 // Cancels a notification with the given id. The notification must be showing, 28 // Cancels a notification with the given id. The notification must be showing,
28 // as opposed to waiting to be shown in the display queue. 29 // as opposed to waiting to be shown in the display queue.
29 // Returns '1' on success. 30 // Returns '1' on success.
30 function cancelNotification(id) { 31 function cancelNotification(id) {
31 if (id < 0 || id > g_notifications.length) { 32 if (id < 0 || id > g_notifications.length) {
32 var errorMsg = "Attempted to cancel notification with invalid ID.\n" + 33 var errorMsg = "Attempted to cancel notification with invalid ID.\n" +
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 stringResult = JSON.stringify(result); 96 stringResult = JSON.stringify(result);
96 window.domAutomationController.send(stringResult); 97 window.domAutomationController.send(stringResult);
97 } 98 }
98 99
99 </script> 100 </script>
100 101
101 <body> 102 <body>
102 This page is used for testing HTML5 notifications. 103 This page is used for testing HTML5 notifications.
103 </body> 104 </body>
104 </html> 105 </html>
OLDNEW
« no previous file with comments | « chrome/test/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698