From dd6f11afea0ed74dadba7f4539a503e41210e870 Mon Sep 17 00:00:00 2001 From: Ponchale Date: Tue, 26 Nov 2024 19:24:54 -0500 Subject: [PATCH] Bug 1921759: Restart Windows Explorer at start of browser_bookmark_copy_folder_tree.js a=dmeehan In a new Windows update, explorer.exe is grabs the clipboard mutex and holds it for a long time, which is causing test failures. Killing explorer.exe restarts it and forces it to give up the mutex, allowing the test to pass. --- .../browser_bookmark_copy_folder_tree.js | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/browser/components/places/tests/browser/browser_bookmark_copy_folder_tree.js b/browser/components/places/tests/browser/browser_bookmark_copy_folder_tree.js index 71b947f7acc..0ce5bc53ece 100644 --- a/browser/components/places/tests/browser/browser_bookmark_copy_folder_tree.js +++ b/browser/components/places/tests/browser/browser_bookmark_copy_folder_tree.js @@ -14,6 +14,33 @@ add_task(async function () { await PlacesUtils.bookmarks.eraseEverything(); }); + if (AppConstants.platform === "win") { + if (Services.env.get("MOZ_AUTOMATION")) { + // When running in CI, pre-emptively kill Windows Explorer, using system + // from the standard library, since it sometimes holds the clipboard for + // long periods, thereby breaking the test (bug 1921759). + const { ctypes } = ChromeUtils.importESModule( + "resource://gre/modules/ctypes.sys.mjs" + ); + let libc = ctypes.open("ucrtbase.dll"); + let exec = libc.declare( + "system", + ctypes.default_abi, + ctypes.int, + ctypes.char.ptr + ); + let rv = exec( + '"powershell -command "&{&Stop-Process -ProcessName explorer}"' + ); + libc.close(); + is(rv, 0, "Launched powershell to stop explorer.exe"); + } else { + info( + "Skipping terminating Windows Explorer since we are not running in automation" + ); + } + } + await withSidebarTree("bookmarks", async function (tree) { const selectedNodeComparator = { equalTitle: itemNode => {