[Bug]: Browser plugin: `visit()` and `reload()` return at the first `load` from any frame, so a page with an iframe is used before it has loaded
I maintainer di solito rispondono entro 5 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 57/100
Direzione di ricerca
Start by reading Client::execute() and tracing how its lifecycle messages interact with the replies for goto and reload; the issue does not name file paths or tests. Check how Playwright reports the main frame's load state when a page has an iframe, and verify both visit() and reload() wait for the page to finish loading before returning.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What Happened
visit() asks Playwright for goto with waitUntil: 'load', so a test can expect the page to have loaded when it returns. On a page containing an iframe, it can return while the page is still loading. Scripts and assertions that follow then run against a half-loaded document.
How to Reproduce
A page with an iframe, followed by a script that takes two seconds to arrive:
<!doctype html>
<title>x</title>
<iframe></iframe>
<script src="/slow.js"></script> <!-- served after a 2s delay; sets window.slow = true -->
it('waits for the page', function () {
$page = visit('http://127.0.0.1:8797/');
dump($page->script('document.readyState'), $page->script('window.slow === true'));
});
| Page | document.readyState |
window.slow === true |
|---|---|---|
With the <iframe> |
loading |
false |
| Same page without it | complete |
true |
Sample Repository
No response
Pest Version
pest-plugin-browser v4.3.1, Playwright 1.60.0, Chromium
PHP Version
8.4
Operation System
Linux
Notes
Cause
Client::execute() stops reading messages when either the reply to the request arrives, or any lifecycle message matches waitUntil:
if (
(isset($response['id']) && $response['id'] === $requestId)
|| (isset($params['waitUntil']) && isset($response['params']['add']) && $params['waitUntil'] === $response['params']['add'])
) {
break;
}
Playwright sends loadstate once per frame, with that frame's guid as the message's guid. The second condition does not look at guid, so the load of a blank iframe ends the wait for the main frame.
Page::reload() passes waitUntil: 'load' too, so it goes through the same condition.
Possible fix
Playwright only answers goto and reload once the requested state is reached on the main frame, so the reply matched by id may be enough on its own and the second condition could go. I don't know why it was added, so there may be a case that needs it.
Comparing $response['guid'] with the request's $guid would not cover everything: goto targets the frame, but reload is sent to the page guid, so a loadstate from the frame would never match.
I have not tested either change.
Workaround
After visit(), wait for the page itself:
$page->script(<<<'JS'
new Promise((resolve) => document.readyState === 'complete'
? resolve(true)
: window.addEventListener('load', () => resolve(true), { once: true }))
JS);
- Lingua principale
- PHP
- Stelle
- 11.8k
- Fork
- 559
- Merge medio
- 5g 23h
- PR unite (30g)
- 24
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di pestphp/pest
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 5 giorni
-
[Bug]: --mutate hides unreadable files, so mutants behind a failed read can never be killedForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
I maintainer di solito rispondono entro 5 giorni
-
[Bug]: [mutate] Windows: @pest-mutate-ignore comments land on line 1 in files with LF line endingsForse già presa @webdevsamran l’ha presa 57 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 5 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
I maintainer di solito rispondono entro 5 giorni
-
[pest-plugin-browser] Page::waitForLoadState() never sends its message — waitForEvent() is a silent no-opForse già presa @asllanmaciel l’ha presa 70 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
pestphp/pest#1892 · 2 commenti ·
I maintainer di solito rispondono entro 5 giorni
Tutte le issue di pestphp/pest
Issue simili
-
Group 2 - Data Storage | Tripal DBX | Chado Group 5 - Search | ElasticSearch | Views Priority - Medium
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
-
nginx update required due to NGINX2RootForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 65/100
mailcow/mailcow-dockerized#7668 · 5 commenti · 2 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
lara-zeus/spatie-translatable#80 ·
I maintainer di solito rispondono entro 1 giorno
-
small
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
uiowa/uiowa#10296 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
asyncapi/modelina#2709 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno