Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix an query with an empty selector in integration tests #18246

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions test/integration/test_utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -268,23 +268,18 @@ async function pasteFromClipboard(page, data, selector, timeout = 100) {
const handle = await page.evaluateHandle(
(sel, timeOut) => {
let callback = null;
const element = sel ? document.querySelector(sel) : document;
return [
Promise.race([
new Promise(resolve => {
callback = e => resolve(e.clipboardData.items.length !== 0);
(sel ? document.querySelector(sel) : document).addEventListener(
"paste",
callback,
{
once: true,
}
);
element.addEventListener("paste", callback, {
once: true,
});
}),
new Promise(resolve => {
setTimeout(() => {
document
.querySelector(sel)
.removeEventListener("paste", callback);
element.removeEventListener("paste", callback);
resolve(false);
}, timeOut);
}),
Expand Down