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

Unified Diff: chrome/test/data/notifications/notification_tester.html

Issue 187803005: Remove uses of the Legacy Notification API and tests on Linux Aura (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/notifications/notification_tester.html
diff --git a/chrome/test/data/notifications/notification_tester.html b/chrome/test/data/notifications/notification_tester.html
index a5ad952e4a0ef3fbd7d8ff877936dc6dda9a3869..abc17fd0721e85051f25c805db92022fb236b890 100644
--- a/chrome/test/data/notifications/notification_tester.html
+++ b/chrome/test/data/notifications/notification_tester.html
@@ -10,20 +10,18 @@ var g_notifications = [];
// Whether the site has requested and been granted permission.
var g_permissionGranted = false;
-// Creates a notification with a iconUrl, title, text, and replaceId.
+// Creates a notification with a iconUrl, title, text, and tag.
// Returns an id for the notification, which can be used to cancel it with
// |cancelNotification|. If two notifications are created with the same
-// replaceId, the second one should replace the first.
-function createNotification(iconUrl, title, text, replaceId) {
- try {
- var note = webkitNotifications.createNotification(iconUrl,
- title,
- text);
- } catch (exception) {
- sendResultToTest(-1);
- return;
- }
- createNotificationHelper(note, replaceId, true);
+// tag, the second one should replace the first.
+function createNotification(iconUrl, title, text, tag) {
+ var notification = new Notification(title, {
+ icon: iconUrl,
+ body: text,
+ tag: tag
+ });
+
+ createNotificationHelper(notification, true);
}
// Cancels a notification with the given id. The notification must be showing,
@@ -38,12 +36,12 @@ function cancelNotification(id) {
g_notifications[id].onclose = function() {
sendResultToTest(1);
}
- g_notifications[id].cancel();
+ g_notifications[id].close();
}
// Requests permission for this origin to create notifications.
function requestPermission() {
- window.webkitNotifications.requestPermission(onPermissionGranted);
+ Notification.requestPermission(onPermissionGranted);
sendResultToTest(1);
}
@@ -65,19 +63,17 @@ function onPermissionGranted() {
// it. The index of the notification is sent back to the test, or -1 is sent
// back on error. If |waitForDisplay| is true, the response will not be sent
// until the notification is actually displayed.
-function createNotificationHelper(note, replaceId, waitForDisplay) {
+function createNotificationHelper(note, waitForDisplay) {
function sendNotificationIdToTest() {
sendResultToTest(g_notifications.length - 1);
}
g_notifications.push(note);
- note.replaceId = replaceId;
if (waitForDisplay)
- note.ondisplay = sendNotificationIdToTest;
+ note.onshow = sendNotificationIdToTest;
note.onerror = function() {
sendResultToTest(-1);
}
- note.show();
if (!waitForDisplay)
sendNotificationIdToTest();
}

Powered by Google App Engine
This is Rietveld 408576698