Commit bba0cee1 authored by Anita Woodruff's avatar Anita Woodruff Committed by Commit Bot

[Notifications] Add interactive ui test for Notification.close()

R=peter@chromium.org

Change-Id: Ia25e9c21b020dfa524c5d2e8ccbf7ba5bf440dcd
Reviewed-on: https://chromium-review.googlesource.com/888525Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Commit-Queue: Anita Woodruff <awdf@chromium.org>
Cr-Commit-Position: refs/heads/master@{#532416}
parent 672b4492
......@@ -347,6 +347,20 @@ IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest,
all_options_notification.timestamp().ToJsTime());
}
IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest,
DisplayAndCloseNonPersistentNotification) {
ASSERT_NO_FATAL_FAILURE(GrantNotificationPermissionForTest());
std::string script_result;
ASSERT_TRUE(RunScript("DisplayAndCloseNonPersistentNotification('')",
&script_result));
EXPECT_EQ("ok", script_result);
std::vector<message_center::Notification> notifications =
GetDisplayedNotifications(false /* is_persistent */);
EXPECT_EQ(0u, notifications.size());
}
IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest,
WebNotificationOptionsReflection) {
ASSERT_NO_FATAL_FAILURE(GrantNotificationPermissionForTest());
......
......@@ -31,6 +31,19 @@
domAutomationController.send('could not show notification'));
}
// Instantiates a new non-persistent notification with the given |title|
// and |options| and then closes it.
// Forwards 'ok' upon receiving the 'close' event.
function DisplayAndCloseNonPersistentNotification(title, options) {
const notification = new Notification(title, options || {});
notification.addEventListener('show', e => {
notification.close();
});
notification.addEventListener('close', e => {
domAutomationController.send('ok');
});
}
// Renews the registered Service Worker registration for this page, then
// displays a notification on the activated ServiceWorkerRegistration.
function DisplayPersistentNotification(title, options) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment