@@ -1318,6 +1318,11 @@ pub const Window = struct {
13181318 try browser .open (self .state .gpa , io , page_url );
13191319 }
13201320
1321+ /// Return whether at least one browser client is connected.
1322+ pub fn isShown (self : Window , io : std.Io ) bool {
1323+ return self .state .hasClients (io );
1324+ }
1325+
13211326 /// Wait for at least one browser connection and return the first client.
13221327 pub fn waitForConnection (
13231328 self : Window ,
@@ -2790,6 +2795,7 @@ test "window connection waiting observes clients and timeouts" {
27902795 const window = try app .createWindow (.{
27912796 .content = .{ .html = "connection wait test" },
27922797 });
2798+ try std .testing .expect (! window .isShown (io ));
27932799 var running = try app .start (io );
27942800 defer running .stop () catch {};
27952801
@@ -2821,6 +2827,7 @@ test "window connection waiting observes clients and timeouts" {
28212827 ));
28222828
28232829 const delayed = try waiting .await (io );
2830+ try std .testing .expect (window .isShown (io ));
28242831 try std .testing .expect (delayed .isConnected (io ));
28252832 const immediate = try window .waitForConnection (io , .zero );
28262833 try std .testing .expectEqual (delayed .id (), immediate .id ());
@@ -2831,6 +2838,7 @@ test "window connection waiting observes clients and timeouts" {
28312838 try std .Io .sleep (io , .fromMilliseconds (1 ), .awake );
28322839 }
28332840 try std .testing .expect (! delayed .isConnected (io ));
2841+ try std .testing .expect (! window .isShown (io ));
28342842 try std .testing .expectError (
28352843 error .Timeout ,
28362844 window .waitForConnection (io , .fromMilliseconds (5 )),
@@ -3654,6 +3662,7 @@ test "multi-client limits, targeting, and disconnect lifecycle" {
36543662 try window .bind ("greet" , integrationHandler , & called_client_id );
36553663 var running = try app .start (io );
36563664 defer running .stop () catch {};
3665+ try std .testing .expect (! window .isShown (io ));
36573666
36583667 const first_stream = try connectTestWebSocket (
36593668 running .inner .address ,
@@ -3670,6 +3679,7 @@ test "multi-client limits, targeting, and disconnect lifecycle" {
36703679 & window .state .capability ,
36713680 & first_response ,
36723681 ));
3682+ try std .testing .expect (window .isShown (io ));
36733683
36743684 var packet : std .ArrayList (u8 ) = .empty ;
36753685 defer packet .deinit (gpa );
@@ -3705,6 +3715,7 @@ test "multi-client limits, targeting, and disconnect lifecycle" {
37053715 & window .state .capability ,
37063716 & second_response ,
37073717 ));
3718+ try std .testing .expect (window .isShown (io ));
37083719 packet .clearRetainingCapacity ();
37093720 try protocol .append (& packet , gpa , .{
37103721 .token = window .state .token ,
@@ -4074,6 +4085,7 @@ test "multi-client limits, targeting, and disconnect lifecycle" {
40744085 }
40754086 try std .testing .expect (first_disconnected );
40764087 try std .testing .expect (second .isConnected (io ));
4088+ try std .testing .expect (window .isShown (io ));
40774089 try std .testing .expect (! app .closed .load (.acquire ));
40784090 try std .testing .expectError (error .ConnectionClosed , first_eval .await (io ));
40794091 try std .testing .expectError (
@@ -4115,4 +4127,5 @@ test "multi-client limits, targeting, and disconnect lifecycle" {
41154127 try std .testing .expectEqual (protocol .Command .close , second_close .header .command );
41164128 try second_stream .shutdown (io , .both );
41174129 try running .wait ();
4130+ try std .testing .expect (! window .isShown (io ));
41184131}
0 commit comments