Skip to content
Snippets Groups Projects
Commit a67e60e2 authored by Paul Zuehlcke's avatar Paul Zuehlcke
Browse files

Bug 1879850 - Test, r=Gijs a=test-only

parent d0623081
No related branches found
No related tags found
No related merge requests found
......@@ -294,3 +294,104 @@ add_task(async function test_notificationReshowTabSwitch() {
"Should not longer see the notification."
);
});
/**
* Tests that the security delay gets reset when a window is repositioned and
* the PopupNotifications panel position is updated.
*/
add_task(async function test_notificationWindowMove() {
await ensureSecurityDelayReady();
info("Open a notification.");
let popupShownPromise = waitForNotificationPanel();
showNotification();
await popupShownPromise;
ok(
PopupNotifications.isPanelOpen,
"PopupNotification should be open after show call."
);
// Test that the initial security delay works.
info("Trigger main action via button click during the new security delay.");
triggerMainCommand(PopupNotifications.panel);
await new Promise(resolve => setTimeout(resolve, 0));
ok(PopupNotifications.isPanelOpen, "PopupNotification should still be open.");
let notification = PopupNotifications.getNotification(
"foo",
gBrowser.selectedBrowser
);
ok(
notification,
"Notification should still be open because we clicked during the security delay."
);
// If the notification is no longer shown (test failure) skip the remaining
// checks.
if (!notification) {
return;
}
info("Wait for security delay to expire.");
await new Promise(resolve =>
// eslint-disable-next-line mozilla/no-arbitrary-setTimeout
setTimeout(resolve, TEST_SECURITY_DELAY + 500)
);
info("Reposition the window");
// Remember original window position.
let { screenX, screenY } = window;
let promisePopupPositioned = BrowserTestUtils.waitForEvent(
PopupNotifications.panel,
"popuppositioned"
);
// Move the window.
window.moveTo(200, 200);
// Wait for the panel to reposition and the PopupNotifications listener to run.
await promisePopupPositioned;
await new Promise(resolve => setTimeout(resolve, 0));
info("Trigger main action via button click during the new security delay.");
triggerMainCommand(PopupNotifications.panel);
await new Promise(resolve => setTimeout(resolve, 0));
ok(PopupNotifications.isPanelOpen, "PopupNotification should still be open.");
notification = PopupNotifications.getNotification(
"foo",
gBrowser.selectedBrowser
);
ok(
notification,
"Notification should still be open because we clicked during the security delay."
);
// If the notification is no longer shown (test failure) skip the remaining
// checks.
if (!notification) {
return;
}
// Ensure that once the security delay has passed the notification can be
// closed again.
let fakeTimeShown = TEST_SECURITY_DELAY + 500;
info(`Manually set timeShown to ${fakeTimeShown}ms in the past.`);
notification.timeShown = performance.now() - fakeTimeShown;
info("Trigger main action via button click outside security delay");
let notificationHiddenPromise = waitForNotificationPanelHidden();
triggerMainCommand(PopupNotifications.panel);
info("Wait for panel to be hidden.");
await notificationHiddenPromise;
ok(
!PopupNotifications.getNotification("foo", gBrowser.selectedBrowser),
"Should not longer see the notification."
);
// Reset window position
window.moveTo(screenX, screenY);
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment