Skip to content
Open
Show file tree
Hide file tree
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: 14 additions & 1 deletion src/Api/AwaitableWebpage.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,21 @@ public function __construct(
private array $nonAwaitableMethods = [
'assertScreenshotMatches',
'assertNoAccessibilityIssues',
// Retrying this action would append the value to what was already typed.
// Retrying these actions would repeat their effect: a re-fired click aims at
// a page its first attempt already changed, a re-sent Enter submits the form
// again, a re-run drag starts from an element the first attempt already
// moved, and typing again appends to what was already typed. A single direct
// call gets Playwright's full actionability wait with the whole timeout
// budget on that one attempt.
'append',
'click',
'drag',
'keys',
'press',
'pressAndWaitFor',
'rightClick',
'typeSlowly',
'withKeyDown',
],
) {
//
Expand Down
34 changes: 34 additions & 0 deletions tests/Browser/Webpage/ClickTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,37 @@
'[name$="test"]',
'button[name="test"]',
]);

it('does not re-fire a click whose first attempt is slow', function (): void {
Route::get('/', fn (): string => '
<button id="open">Open</button>
<div id="overlay" style="display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5);">
<p>Dialog</p>
</div>

<script>
window.downs = 0;

document.getElementById("open").addEventListener("pointerdown", function () {
if (++window.downs === 1) {
const until = Date.now() + 1200;

while (Date.now() < until) {
// Simulate a busy main thread, as on a loaded CI runner.
}
}
});

document.getElementById("open").addEventListener("click", function () {
document.getElementById("overlay").style.display = "block";
});
</script>
');

$page = visit('/');

$page->click('#open');

$page->assertScript('window.downs', 1);
$page->assertVisible('#overlay p');
});