Promise vere e await: la coda dei microtask viene svuotata
Il difetto: Boa le Promise le ha, ma nessuno chiamava run_jobs(), quindi ogni .then restava in coda per sempre e la pagina non si aggiornava — senza un solo errore da leggere. - fetch restituisce una Promise costruita dal motore (new Promise + resolve/reject tenuti nella richiesta), non più un oggetto con un then finto - text() e json() restituiscono Promise anche loro, come nel browser: senza, "await r.text()" riceveva la stringa e chi si aspettava una Promise si rompeva - run_jobs() dopo ogni ingresso di JavaScript: script, eventi, timer, consegna delle risposte di fetch - il guscio desktop serve le fetch anche nel percorso senza finestra: con --aspetta l'attesa non serviva a niente e la pagina restava sulla scritta iniziale - 7 test nuovi (tests/promise.rs): then, await, fetch+text, fetch+json, catch, Promise.all, Promise accesa dentro un gestore di clic - aggiornato il test che si aspettava r.text() sincrona: codificava la vecchia semplificazione, non il comportamento giusto Verifica end-to-end su HTTP vero: una pagina con await fetch e await r.json() mostra "ricevuto: Mosaic (200)". Wikipedia, che usa async/await ovunque, si carica senza panic.
This commit is contained in:
1 parent
71f45d8967
commit
6a14853d0d
6 files changed
+241
-18
No files matched your search
@@ -54,6 +54,7 @@ Nessun codice di WebKit, Blink, Gecko o Servo: parser, cascata, layout e raster
|
||||
| Proxy `http_proxy`/`https_proxy`/`no_proxy`, tunnel `CONNECT` | fatto (M2.6b) | `src/net.rs` |
|
||||
| `multipart/form-data` e `text/plain` oltre a `urlencoded` | fatto (M2.6b) | `src/invio.rs` |
|
||||
| Processo di rete separato con IPC su stdin/stdout | fatto (M2.6b, desktop) | `src/bin/mosaic-net.rs` |
|
||||
| Promise vere e `await`, `fetch` come Promise, `run_jobs` sui microtask | fatto (M2.5 chiuso) | `src/script_boa.rs` |
|
||||
| Rete: `GET` http/https con TLS, chunked, reindirizzamenti, limiti | fatto in parte (M2.6) | `src/net.rs`, `render --url`, `desktop --url` |
|
||||
| Sotto-risorse dalla rete: `link[rel=stylesheet]` e `img[src]` | fatto (M2.6) | `src/resource.rs`, `tests/risorse.rs` |
|
||||
| WPT (`html/syntax/parsing` ≥ 90 %) | mancante | — |
|
||||
|
||||
Reference in new issue
Block a user