diff --git a/src/Modules/ChromiumMultipartFormDataModule.php b/src/Modules/ChromiumMultipartFormDataModule.php index 6aa6872..05c5082 100644 --- a/src/Modules/ChromiumMultipartFormDataModule.php +++ b/src/Modules/ChromiumMultipartFormDataModule.php @@ -150,11 +150,12 @@ public function failOnConsoleExceptions(): self } /** - * Tells Chromium to not wait for its network to be idle. + * Specifies whether Chromium have to wait or not for its network to be + * idle. */ - public function skipNetworkIdleEvent(): self + public function skipNetworkIdleEvent(bool $skip = true): self { - $this->formValue('skipNetworkIdleEvent', true); + $this->formValue('skipNetworkIdleEvent', $skip); return $this; } diff --git a/tests/Modules/ChromiumPdfTest.php b/tests/Modules/ChromiumPdfTest.php index 6f380ae..46b8975 100644 --- a/tests/Modules/ChromiumPdfTest.php +++ b/tests/Modules/ChromiumPdfTest.php @@ -42,7 +42,7 @@ function ( array $extraHttpHeaders = [], array $failOnHttpStatusCodes = [], bool $failOnConsoleExceptions = false, - bool $skipNetworkIdleEvent = false, + bool|null $skipNetworkIdleEvent = null, string|null $pdfa = null, bool $pdfua = false, array $metadata = [], @@ -197,7 +197,7 @@ function ( array $extraHttpHeaders = [], array $failOnHttpStatusCodes = [], bool $failOnConsoleExceptions = false, - bool $skipNetworkIdleEvent = false, + bool|null $skipNetworkIdleEvent = null, string|null $pdfa = null, bool $pdfua = false, array $metadata = [], @@ -355,7 +355,7 @@ function ( array $extraHttpHeaders = [], array $failOnHttpStatusCodes = [], bool $failOnConsoleExceptions = false, - bool $skipNetworkIdleEvent = false, + bool|null $skipNetworkIdleEvent = null, string|null $pdfa = null, bool $pdfua = false, array $metadata = [], @@ -523,7 +523,7 @@ function hydrateChromiumPdfFormData( array $extraHttpHeaders = [], array $failOnHttpStatusCodes = [], bool $failOnConsoleExceptions = false, - bool $skipNetworkIdleEvent = false, + bool|null $skipNetworkIdleEvent = null, string|null $pdfa = null, bool $pdfua = false, array $metadata = [], @@ -609,8 +609,8 @@ function hydrateChromiumPdfFormData( $chromium->failOnConsoleExceptions(); } - if ($skipNetworkIdleEvent) { - $chromium->skipNetworkIdleEvent(); + if ($skipNetworkIdleEvent !== null) { + $chromium->skipNetworkIdleEvent($skipNetworkIdleEvent); } if ($pdfa !== null) { @@ -664,7 +664,7 @@ function expectChromiumPdfOptions( array $extraHttpHeaders, array $failOnHttpStatusCodes, bool $failOnConsoleExceptions, - bool $skipNetworkIdleEvent, + bool|null $skipNetworkIdleEvent, string|null $pdfa, bool $pdfua, array $metadata, @@ -737,7 +737,7 @@ function expectChromiumPdfOptions( } expect($body)->unless($failOnConsoleExceptions === false, fn ($body) => $body->toContainFormValue('failOnConsoleExceptions', '1')); - expect($body)->unless($skipNetworkIdleEvent === false, fn ($body) => $body->toContainFormValue('skipNetworkIdleEvent', '1')); + expect($body)->unless($skipNetworkIdleEvent === null, fn ($body) => $body->toContainFormValue('skipNetworkIdleEvent', $skipNetworkIdleEvent === true ? '1' : '0')); expect($body)->unless($pdfa === null, fn ($body) => $body->toContainFormValue('pdfa', $pdfa)); expect($body)->unless($pdfua === false, fn ($body) => $body->toContainFormValue('pdfua', '1')); diff --git a/tests/Modules/ChromiumScreenshotTest.php b/tests/Modules/ChromiumScreenshotTest.php index 40138ee..46c55f2 100644 --- a/tests/Modules/ChromiumScreenshotTest.php +++ b/tests/Modules/ChromiumScreenshotTest.php @@ -33,7 +33,7 @@ function ( array $extraHttpHeaders = [], array $failOnHttpStatusCodes = [], bool $failOnConsoleExceptions = false, - bool $skipNetworkIdleEvent = false, + bool|null $skipNetworkIdleEvent = null, array $assets = [], ): void { $chromium = Gotenberg::chromium('')->screenshot(); @@ -142,7 +142,7 @@ function ( array $extraHttpHeaders = [], array $failOnHttpStatusCodes = [], bool $failOnConsoleExceptions = false, - bool $skipNetworkIdleEvent = false, + bool|null $skipNetworkIdleEvent = null, array $assets = [], ): void { $chromium = Gotenberg::chromium('')->screenshot(); @@ -255,7 +255,7 @@ function ( array $extraHttpHeaders = [], array $failOnHttpStatusCodes = [], bool $failOnConsoleExceptions = false, - bool $skipNetworkIdleEvent = false, + bool|null $skipNetworkIdleEvent = null, array $assets = [], ): void { $chromium = Gotenberg::chromium('')->screenshot(); @@ -378,7 +378,7 @@ function hydrateChromiumScreenshotFormData( array $extraHttpHeaders = [], array $failOnHttpStatusCodes = [], bool $failOnConsoleExceptions = false, - bool $skipNetworkIdleEvent = false, + bool|null $skipNetworkIdleEvent = null, array $assets = [], ): ChromiumScreenshot { if ($width !== null) { @@ -453,8 +453,8 @@ function hydrateChromiumScreenshotFormData( $chromium->failOnConsoleExceptions(); } - if ($skipNetworkIdleEvent) { - $chromium->skipNetworkIdleEvent(); + if ($skipNetworkIdleEvent !== null) { + $chromium->skipNetworkIdleEvent($skipNetworkIdleEvent); } if (count($assets) > 0) { @@ -487,7 +487,7 @@ function expectChromiumScreenshotOptions( array $extraHttpHeaders, array $failOnHttpStatusCodes, bool $failOnConsoleExceptions, - bool $skipNetworkIdleEvent, + bool|null $skipNetworkIdleEvent, array $assets, ): void { expect($body)->unless($width === null, fn ($body) => $body->toContainFormValue('width', $width . '')); @@ -531,7 +531,7 @@ function expectChromiumScreenshotOptions( } expect($body)->unless($failOnConsoleExceptions === false, fn ($body) => $body->toContainFormValue('failOnConsoleExceptions', '1')); - expect($body)->unless($skipNetworkIdleEvent === false, fn ($body) => $body->toContainFormValue('skipNetworkIdleEvent', '1')); + expect($body)->unless($skipNetworkIdleEvent === null, fn ($body) => $body->toContainFormValue('skipNetworkIdleEvent', $skipNetworkIdleEvent === true ? '1' : '0')); if (count($assets) <= 0) { return;