Skip to content

Commit 78a878b

Browse files
committed
Bug 1966443: Clean up after tests that open context menus r=masayuki
For test_contextmenu_chorded_buttons.html, the synthesized escape key was not dismissing the contextmenu, and it was blocking an upcoming DND test when run in automation. Switched to a left-mouse-click to close it, since closing the contextmenu is not part of the test. test_contextmenu_by_mouse_on_unix.html isn't causing any test problems but it was leaving a context menu open as well (it didn't attempt to close it). Differential Revision: https://phabricator.services.mozilla.com/D259298
1 parent 0d1a205 commit 78a878b

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

widget/tests/test_contextmenu_by_mouse_on_unix.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@
3939
await process_contextmenu_event({ isMousedown: false, preventEvent: true });
4040
});
4141

42+
add_task(async function teardown() {
43+
// Dismiss context menu if any
44+
await promiseNativeMouseEvent({
45+
type: "click",
46+
target: document.body,
47+
offsetX: 10,
48+
offsetY: 10,
49+
button: 0,
50+
});
51+
});
52+
4253
async function process_contextmenu_event({ isMousedown, preventEvent }) {
4354
await SpecialPowers.contentTransformsReceived(window);
4455

widget/tests/test_contextmenu_chorded_buttons.html

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,14 @@
6868
info("waiting for contextmenu event...");
6969
contextMenuEvent = await promiseContextMenu;
7070

71-
const promiseContextMenuClosed = new Promise(resolve => {
72-
addEventListener("keyup", resolve, {once: true});
73-
synthesizeKey("KEY_Escape");
74-
});
7571
info("waiting for closing contextmenu...");
76-
await promiseContextMenuClosed;
72+
await promiseNativeMouseEvent({
73+
type: "click",
74+
target: document.body,
75+
offsetX: 10,
76+
offsetY: 10,
77+
button: 0,
78+
});
7779

7880
// It depends on the platform whether the context menu opens before/after
7981
// mouseup of the secondary mouse button. Therefore, we should ignore

0 commit comments

Comments
 (0)