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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/notifications/serviceworker-notificationclick-event-reply-reflection.html

Issue 2403893002: Add layout test for reply property of notificationclick event (Closed)
Patch Set: Make reply field nullable in .idl files; add test cases for empty and null Created 4 years, 2 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: third_party/WebKit/LayoutTests/http/tests/notifications/serviceworker-notificationclick-event-reply-reflection.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/notifications/serviceworker-notificationclick-event-action-reflection.html b/third_party/WebKit/LayoutTests/http/tests/notifications/serviceworker-notificationclick-event-reply-reflection.html
similarity index 59%
copy from third_party/WebKit/LayoutTests/http/tests/notifications/serviceworker-notificationclick-event-action-reflection.html
copy to third_party/WebKit/LayoutTests/http/tests/notifications/serviceworker-notificationclick-event-reply-reflection.html
index 67c439072ce1ac8cd4c00cd54496462c91b32344..355cf1cddf1b70c5731a5c4457725f0e3fd81a30 100644
--- a/third_party/WebKit/LayoutTests/http/tests/notifications/serviceworker-notificationclick-event-action-reflection.html
+++ b/third_party/WebKit/LayoutTests/http/tests/notifications/serviceworker-notificationclick-event-reply-reflection.html
@@ -1,7 +1,7 @@
<!doctype html>
<html>
<head>
- <title>Notifications: Action reflection in the "notificationclick" event.</title>
+ <title>Notifications: Reply reflection in the "notificationclick" event.</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="../serviceworker/resources/test-helpers.js"></script>
@@ -9,8 +9,8 @@
</head>
<body>
<script>
- // Tests that the action property of the "notificationclick" event in the
- // Service Worker accurately reflects which action was activated, if any.
+ // Tests that the reply property of the "notificationclick" event in the
+ // Service Worker accurately reflects the reply entered.
async_test(function(test) {
var scope = 'resources/scope/' + location.pathname;
@@ -18,18 +18,9 @@
var port;
var options = {
- actions: []
+ actions: [{ action: 'actionName', title: 'ActionTitle', type: 'text' }]
};
- var expectedActions = [];
- for (var i = 0; i < Notification.maxActions; ++i) {
- var action = { action: 'action' + i, title: 'Action ' + i };
- options.actions.push(action);
- expectedActions.push(action.action);
- }
- // Expect empty string when main body of notification is activated.
- expectedActions.push('');
-
testRunner.setPermission('notifications', 'granted', location.origin, location.origin);
getActiveServiceWorkerWithMessagePort(test, script, scope).then(function(info) {
port = info.port;
@@ -44,25 +35,34 @@
// (2) Confirm that the service worker displayed the notification successfully.
assert_true(data.success, 'The notification must have been displayed.');
- // (3) Simulate a click on each button and on the notification body.
- for (var i = 0; i < options.actions.length; ++i)
- testRunner.simulateWebNotificationClick(scope, i);
+ var expectedReplies = [];
+ // (3) Simulate some clicks on the notification, with and without replies.
+ // (3.1) Simulate a reply to the notification text action.
+ testRunner.simulateWebNotificationClickWithReply(scope, 0 /* action_index */, 'My reply.');
+ expectedReplies.push('My reply.');
+
+ // (3.2) Simulate an empty reply to the notification text action.
+ testRunner.simulateWebNotificationClickWithReply(scope, 0 /* action_index */, '');
+ expectedReplies.push('');
+
+ // (3.3) Simulate a click on the notification body (reply should be null).
testRunner.simulateWebNotificationClick(scope, -1 /* action_index */);
+ expectedReplies.push(null);
port.addEventListener('message', function(event) {
// (4) Listen for confirmation from the Service Worker that the
- // notification has been clicked on. Make sure that the action
+ // notification has been clicked on. Make sure that the reply
// property set on the NotificationEvent object is as expected.
assert_equals(event.data.command, 'click', 'The notification was expected to be clicked.');
- assert_equals(event.data.action, expectedActions.shift());
+ assert_equals(event.data.reply, expectedReplies.shift());
- if (expectedActions.length === 0)
+ if (expectedReplies.length === 0)
test.done();
});
}).catch(unreached_rejection(test));
- }, 'NotificationEvent action property should be reflect which action was clicked.');
+ }, 'NotificationEvent reply property should reflect the reply that was entered');
</script>
</body>
</html>

Powered by Google App Engine
This is Rietveld 408576698