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

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

Issue 802753002: Revert of "Call the Close() event on a Notification when it's being replaced." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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/browser/notifications/notification_browsertest.cc ('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 // Object of notifications which have been closed.
11 var g_closed_notifications = {};
12 // Whether the site has requested and been granted permission. 10 // Whether the site has requested and been granted permission.
13 var g_permissionGranted = false; 11 var g_permissionGranted = false;
14 12
15 // Creates a notification with a iconUrl, title, text, and tag. 13 // Creates a notification with a iconUrl, title, text, and tag.
16 // 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
17 // |cancelNotification|. If two notifications are created with the same 15 // |cancelNotification|. If two notifications are created with the same
18 // tag, the second one should replace the first. 16 // tag, the second one should replace the first.
19 function createNotification(iconUrl, title, text, tag) { 17 function createNotification(iconUrl, title, text, tag) {
20 var notification = new Notification(title, { 18 var notification = new Notification(title, {
21 icon: iconUrl, 19 icon: iconUrl,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 // Callback for requesting notification privileges. 57 // Callback for requesting notification privileges.
60 function onPermissionGranted() { 58 function onPermissionGranted() {
61 g_permissionGranted = true; 59 g_permissionGranted = true;
62 } 60 }
63 61
64 // Helper function that adds a notification to |g_notifications| and shows 62 // Helper function that adds a notification to |g_notifications| and shows
65 // it. The index of the notification is sent back to the test, or -1 is sent 63 // it. The index of the notification is sent back to the test, or -1 is sent
66 // back on error. If |waitForDisplay| is true, the response will not be sent 64 // back on error. If |waitForDisplay| is true, the response will not be sent
67 // until the notification is actually displayed. 65 // until the notification is actually displayed.
68 function createNotificationHelper(note, waitForDisplay) { 66 function createNotificationHelper(note, waitForDisplay) {
69 var notification_id = g_notifications.length; 67 function sendNotificationIdToTest() {
70 68 sendResultToTest(g_notifications.length - 1);
69 }
71 g_notifications.push(note); 70 g_notifications.push(note);
72 g_closed_notifications[notification_id] = false;
73
74 function sendNotificationIdToTest() {
75 sendResultToTest(notification_id);
76 }
77
78 if (waitForDisplay) 71 if (waitForDisplay)
79 note.onshow = sendNotificationIdToTest; 72 note.onshow = sendNotificationIdToTest;
80 note.onerror = function() { 73 note.onerror = function() {
81 sendResultToTest(-1); 74 sendResultToTest(-1);
82 } 75 }
83 note.onclose = function() {
84 g_closed_notifications[notification_id] = true;
85 }
86 76
87 if (!waitForDisplay) 77 if (!waitForDisplay)
88 sendNotificationIdToTest(); 78 sendNotificationIdToTest();
89 } 79 }
90 80
91 // Returns whether the notification with Id has been closed.
92 function hasBeenClosed(notification_id) {
93 sendResultToTest(g_closed_notifications[notification_id]);
94 }
95
96 // Sends a result back to the main test logic. 81 // Sends a result back to the main test logic.
97 function sendResultToTest(result) { 82 function sendResultToTest(result) {
98 // Convert the result to a string. 83 // Convert the result to a string.
99 var stringResult = "" + result; 84 var stringResult = "" + result;
100 if (typeof stringResult != "string") 85 if (typeof stringResult != "string")
101 stringResult = JSON.stringify(result); 86 stringResult = JSON.stringify(result);
102 window.domAutomationController.send(stringResult); 87 window.domAutomationController.send(stringResult);
103 } 88 }
104 89
105 </script> 90 </script>
106 91
107 <body> 92 <body>
108 This page is used for testing HTML5 notifications. 93 This page is used for testing HTML5 notifications.
109 </body> 94 </body>
110 </html> 95 </html>
OLDNEW
« no previous file with comments | « chrome/browser/notifications/notification_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698