diff --git a/src/Appwrite/Screenshots/Client.php b/src/Appwrite/Screenshots/Client.php index 573b4c89fe..f33708090f 100644 --- a/src/Appwrite/Screenshots/Client.php +++ b/src/Appwrite/Screenshots/Client.php @@ -20,12 +20,6 @@ class Client */ public const SCALE = 1.5; - /** - * Wait for subresources such as webfonts and images, not just the DOM, - * otherwise pages are captured mid-render. - */ - public const WAIT_UNTIL = 'load'; - private Factory $factory; /** @@ -55,7 +49,6 @@ class Client 'height' => self::VIEWPORT_HEIGHT, ], 'deviceScaleFactor' => self::SCALE, - 'waitUntil' => self::WAIT_UNTIL, ])); $status = $response->getStatusCode(); diff --git a/tests/unit/Screenshots/ClientTest.php b/tests/unit/Screenshots/ClientTest.php index b90ab15c27..ac5efba65f 100644 --- a/tests/unit/Screenshots/ClientTest.php +++ b/tests/unit/Screenshots/ClientTest.php @@ -60,7 +60,6 @@ final class ClientTest extends TestCase 'sleep' => 500, 'viewport' => ['width' => 1280, 'height' => 720], 'deviceScaleFactor' => 1.5, - 'waitUntil' => 'load', ], \json_decode((string)$this->request->getBody(), true)); } @@ -80,16 +79,18 @@ final class ClientTest extends TestCase $this->assertSame(720, $body['viewport']['height']); } - public function testCreateWaitsForSubresources(): void + public function testCreateDoesNotBlockOnSubresources(): void { $response = (new Response(200, body: new Stream('png-bytes'))) ->withHeader('Content-Type', 'image/png'); $this->client($response)->create('http://appwrite/', 'light'); - // The browser service defaults to `domcontentloaded`, which fires before - // webfonts and images have settled. - $this->assertSame('load', \json_decode((string)$this->request->getBody(), true)['waitUntil']); + // The browser service navigates with `domcontentloaded` unless told + // otherwise. Waiting for `load` risks exhausting the request timeout on + // sites with slow or hanging subresources, which yields no screenshot at + // all rather than an early one. + $this->assertArrayNotHasKey('waitUntil', \json_decode((string)$this->request->getBody(), true)); } public function testCreateError(): void