mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-06-11 01:25:53 -04:00
Apply suggestions from code review
Remove no-longer needed setTimeouts in test now that messages are queued. Runner also checks ready_queue when determining doneness. Co-authored-by: Navid EMAD <design.navid@gmail.com>
This commit is contained in:
@@ -212,7 +212,18 @@ fn _tick(self: *Runner, comptime is_cdp: bool, opts: TickOpts) !CDPTickResult {
|
||||
},
|
||||
}
|
||||
|
||||
if (http_active == 0 and http_client.ws_active == 0 and http_client.queue.first == null and (comptime is_cdp == false)) {
|
||||
if (http_active == 0 and http_client.ws_active == 0 and http_client.queue.first == null and http_client.ready_queue.first == null and (comptime is_cdp == false)) {
|
||||
// we don't need to consider http_client.intercepted here
|
||||
// because is_cdp is false, and that can only be
|
||||
// the case when interception isn't possible.
|
||||
//
|
||||
// ready_queue is also part of the check: makeRequest now
|
||||
// wraps its handles.perform() in a performing=true window,
|
||||
// and any synchronous libcurl callback that ends up
|
||||
// calling trackConn during that window (e.g. JS creating
|
||||
// a WebSocket) will append to ready_queue. Without this
|
||||
// check we could observe it non-empty after
|
||||
// http_client.tick returns.
|
||||
// we don't need to consider http_client.intercepted here
|
||||
// because is_cdp is false, and that can only be
|
||||
// the case when interception isn't possible.
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
const state = await testing.async();
|
||||
const worker = new Worker('./xhr-worker.js');
|
||||
worker.onmessage = (e) => state.resolve(e.data);
|
||||
setTimeout(() => worker.postMessage({ kind: 'basic' }), 100);
|
||||
worker.postMessage({ kind: 'basic' });
|
||||
|
||||
await state.done((data) => {
|
||||
testing.expectTrue(data.ok, 'worker xhr error: ' + data.err);
|
||||
@@ -29,7 +29,7 @@
|
||||
const state = await testing.async();
|
||||
const worker = new Worker('./xhr-worker.js');
|
||||
worker.onmessage = (e) => state.resolve(e.data);
|
||||
setTimeout(() => worker.postMessage({ kind: 'arraybuffer' }), 100);
|
||||
worker.postMessage({ kind: 'arraybuffer' });
|
||||
|
||||
await state.done((data) => {
|
||||
testing.expectTrue(data.ok, 'worker xhr error: ' + data.err);
|
||||
@@ -48,7 +48,7 @@
|
||||
const state = await testing.async();
|
||||
const worker = new Worker('./xhr-worker.js');
|
||||
worker.onmessage = (e) => state.resolve(e.data);
|
||||
setTimeout(() => worker.postMessage({ kind: 'document_unsupported' }), 100);
|
||||
worker.postMessage({ kind: 'document_unsupported' });
|
||||
|
||||
await state.done((data) => {
|
||||
testing.expectTrue(data.ok, 'worker xhr error: ' + data.err);
|
||||
|
||||
Reference in New Issue
Block a user