@@ -24,6 +24,7 @@ final class ChromiumPdfTest extends TestCase
2424 * @param array<string,string> $extraHttpHeaders
2525 * @param int[] $failOnHttpStatusCodes
2626 * @param int[] $failOnResourceHttpStatusCodes
27+ * @param string[] $ignoreResourceHttpStatusDomains
2728 * @param array<string,string|bool|float|int|array<string>> $metadata
2829 * @param Stream[] $embeds
2930 * @param Stream[] $assets
@@ -51,12 +52,14 @@ public function it_creates_a_valid_request_for_the_forms_chromium_convert_url_en
5152 Stream |null $ footer = null ,
5253 string |null $ waitDelay = null ,
5354 string |null $ waitForExpression = null ,
55+ string |null $ waitForSelector = null ,
5456 string |null $ emulatedMediaType = null ,
5557 array $ cookies = [],
5658 string |null $ userAgent = null ,
5759 array $ extraHttpHeaders = [],
5860 array $ failOnHttpStatusCodes = [],
5961 array $ failOnResourceHttpStatusCodes = [],
62+ array $ ignoreResourceHttpStatusDomains = [],
6063 bool $ failOnResourceLoadingFailed = false ,
6164 bool $ failOnConsoleExceptions = false ,
6265 bool |null $ skipNetworkIdleEvent = null ,
@@ -92,12 +95,14 @@ public function it_creates_a_valid_request_for_the_forms_chromium_convert_url_en
9295 $ footer ,
9396 $ waitDelay ,
9497 $ waitForExpression ,
98+ $ waitForSelector ,
9599 $ emulatedMediaType ,
96100 $ cookies ,
97101 $ userAgent ,
98102 $ extraHttpHeaders ,
99103 $ failOnHttpStatusCodes ,
100104 $ failOnResourceHttpStatusCodes ,
105+ $ ignoreResourceHttpStatusDomains ,
101106 $ failOnResourceLoadingFailed ,
102107 $ failOnConsoleExceptions ,
103108 $ skipNetworkIdleEvent ,
@@ -139,12 +144,14 @@ public function it_creates_a_valid_request_for_the_forms_chromium_convert_url_en
139144 $ footer ,
140145 $ waitDelay ,
141146 $ waitForExpression ,
147+ $ waitForSelector ,
142148 $ emulatedMediaType ,
143149 $ cookies ,
144150 $ userAgent ,
145151 $ extraHttpHeaders ,
146152 $ failOnHttpStatusCodes ,
147153 $ failOnResourceHttpStatusCodes ,
154+ $ ignoreResourceHttpStatusDomains ,
148155 $ failOnResourceLoadingFailed ,
149156 $ failOnConsoleExceptions ,
150157 $ skipNetworkIdleEvent ,
@@ -183,11 +190,13 @@ public function it_creates_a_valid_request_for_the_forms_chromium_convert_url_en
183190 * string|null,
184191 * string|null,
185192 * string|null,
193+ * string|null,
186194 * array<int, ChromiumCookie>,
187195 * string|null,
188196 * array<string, string>,
189197 * array<int, int>,
190198 * array<int, int>,
199+ * array<int, string>,
191200 * bool,
192201 * bool,
193202 * bool|null,
@@ -227,6 +236,7 @@ public static function provideUrlData(): array
227236 Stream::string ('my_footer.html ' , 'Footer content ' ),
228237 '1s ' ,
229238 "window.status === 'ready' " ,
239+ '#id ' ,
230240 'print ' ,
231241 [
232242 new ChromiumCookie ('yummy_cookie ' , 'choco ' , 'theyummycookie.com ' ),
@@ -239,6 +249,7 @@ public static function provideUrlData(): array
239249 ],
240250 [499 , 599 ],
241251 [499 , 599 ],
252+ ['my.com ' ],
242253 true ,
243254 true ,
244255 true ,
@@ -265,6 +276,7 @@ public static function provideUrlData(): array
265276 * @param array<string,string> $extraHttpHeaders
266277 * @param int[] $failOnHttpStatusCodes
267278 * @param int[] $failOnResourceHttpStatusCodes
279+ * @param string[] $ignoreResourceHttpStatusDomains
268280 * @param array<string,string|bool|float|int|array<string>> $metadata
269281 * @param Stream[] $embeds
270282 * @param Stream[] $assets
@@ -292,12 +304,14 @@ public function it_creates_a_valid_request_for_the_forms_chromium_convert_html_e
292304 Stream |null $ footer = null ,
293305 string |null $ waitDelay = null ,
294306 string |null $ waitForExpression = null ,
307+ string |null $ waitForSelector = null ,
295308 string |null $ emulatedMediaType = null ,
296309 array $ cookies = [],
297310 string |null $ userAgent = null ,
298311 array $ extraHttpHeaders = [],
299312 array $ failOnHttpStatusCodes = [],
300313 array $ failOnResourceHttpStatusCodes = [],
314+ array $ ignoreResourceHttpStatusDomains = [],
301315 bool $ failOnResourceLoadingFailed = false ,
302316 bool $ failOnConsoleExceptions = false ,
303317 bool |null $ skipNetworkIdleEvent = null ,
@@ -333,12 +347,14 @@ public function it_creates_a_valid_request_for_the_forms_chromium_convert_html_e
333347 $ footer ,
334348 $ waitDelay ,
335349 $ waitForExpression ,
350+ $ waitForSelector ,
336351 $ emulatedMediaType ,
337352 $ cookies ,
338353 $ userAgent ,
339354 $ extraHttpHeaders ,
340355 $ failOnHttpStatusCodes ,
341356 $ failOnResourceHttpStatusCodes ,
357+ $ ignoreResourceHttpStatusDomains ,
342358 $ failOnResourceLoadingFailed ,
343359 $ failOnConsoleExceptions ,
344360 $ skipNetworkIdleEvent ,
@@ -382,12 +398,14 @@ public function it_creates_a_valid_request_for_the_forms_chromium_convert_html_e
382398 $ footer ,
383399 $ waitDelay ,
384400 $ waitForExpression ,
401+ $ waitForSelector ,
385402 $ emulatedMediaType ,
386403 $ cookies ,
387404 $ userAgent ,
388405 $ extraHttpHeaders ,
389406 $ failOnHttpStatusCodes ,
390407 $ failOnResourceHttpStatusCodes ,
408+ $ ignoreResourceHttpStatusDomains ,
391409 $ failOnResourceLoadingFailed ,
392410 $ failOnConsoleExceptions ,
393411 $ skipNetworkIdleEvent ,
@@ -426,11 +444,13 @@ public function it_creates_a_valid_request_for_the_forms_chromium_convert_html_e
426444 * string|null,
427445 * string|null,
428446 * string|null,
447+ * string|null,
429448 * array<int, ChromiumCookie>,
430449 * string|null,
431450 * array<string, string>,
432451 * array<int, int>,
433452 * array<int, int>,
453+ * array<int, string>,
434454 * bool,
435455 * bool,
436456 * bool|null,
@@ -470,6 +490,7 @@ public static function provideHtmlData(): array
470490 Stream::string ('my_footer.html ' , 'Footer content ' ),
471491 '1s ' ,
472492 "window.status === 'ready' " ,
493+ '#id ' ,
473494 'screen ' ,
474495 [
475496 new ChromiumCookie ('yummy_cookie ' , 'choco ' , 'theyummycookie.com ' ),
@@ -482,6 +503,7 @@ public static function provideHtmlData(): array
482503 ],
483504 [499 , 599 ],
484505 [499 , 599 ],
506+ ['my.com ' ],
485507 true ,
486508 true ,
487509 true ,
@@ -508,6 +530,7 @@ public static function provideHtmlData(): array
508530 * @param array<string,string> $extraHttpHeaders
509531 * @param int[] $failOnHttpStatusCodes
510532 * @param int[] $failOnResourceHttpStatusCodes
533+ * @param string[] $ignoreResourceHttpStatusDomains
511534 * @param Stream[] $markdowns
512535 * @param array<string,string|bool|float|int|array<string>> $metadata
513536 * @param Stream[] $embeds
@@ -537,12 +560,14 @@ public function it_creates_a_valid_request_for_the_forms_chromium_convert_markdo
537560 Stream |null $ footer = null ,
538561 string |null $ waitDelay = null ,
539562 string |null $ waitForExpression = null ,
563+ string |null $ waitForSelector = null ,
540564 string |null $ emulatedMediaType = null ,
541565 array $ cookies = [],
542566 string |null $ userAgent = null ,
543567 array $ extraHttpHeaders = [],
544568 array $ failOnHttpStatusCodes = [],
545569 array $ failOnResourceHttpStatusCodes = [],
570+ array $ ignoreResourceHttpStatusDomains = [],
546571 bool $ failOnResourceLoadingFailed = false ,
547572 bool $ failOnConsoleExceptions = false ,
548573 bool |null $ skipNetworkIdleEvent = null ,
@@ -578,12 +603,14 @@ public function it_creates_a_valid_request_for_the_forms_chromium_convert_markdo
578603 $ footer ,
579604 $ waitDelay ,
580605 $ waitForExpression ,
606+ $ waitForSelector ,
581607 $ emulatedMediaType ,
582608 $ cookies ,
583609 $ userAgent ,
584610 $ extraHttpHeaders ,
585611 $ failOnHttpStatusCodes ,
586612 $ failOnResourceHttpStatusCodes ,
613+ $ ignoreResourceHttpStatusDomains ,
587614 $ failOnResourceLoadingFailed ,
588615 $ failOnConsoleExceptions ,
589616 $ skipNetworkIdleEvent ,
@@ -632,12 +659,14 @@ public function it_creates_a_valid_request_for_the_forms_chromium_convert_markdo
632659 $ footer ,
633660 $ waitDelay ,
634661 $ waitForExpression ,
662+ $ waitForSelector ,
635663 $ emulatedMediaType ,
636664 $ cookies ,
637665 $ userAgent ,
638666 $ extraHttpHeaders ,
639667 $ failOnHttpStatusCodes ,
640668 $ failOnResourceHttpStatusCodes ,
669+ $ ignoreResourceHttpStatusDomains ,
641670 $ failOnResourceLoadingFailed ,
642671 $ failOnConsoleExceptions ,
643672 $ skipNetworkIdleEvent ,
@@ -677,11 +706,13 @@ public function it_creates_a_valid_request_for_the_forms_chromium_convert_markdo
677706 * string|null,
678707 * string|null,
679708 * string|null,
709+ * string|null,
680710 * array<int, ChromiumCookie>,
681711 * string|null,
682712 * array<string, string>,
683713 * array<int, int>,
684714 * array<int, int>,
715+ * array<int, string>,
685716 * bool,
686717 * bool,
687718 * bool|null,
@@ -730,6 +761,7 @@ public static function provideMarkdownData(): array
730761 Stream::string ('my_footer.html ' , 'Footer content ' ),
731762 '1s ' ,
732763 "window.status === 'ready' " ,
764+ '#id ' ,
733765 'screen ' ,
734766 [
735767 new ChromiumCookie ('yummy_cookie ' , 'choco ' , 'theyummycookie.com ' ),
@@ -742,6 +774,7 @@ public static function provideMarkdownData(): array
742774 ],
743775 [499 , 599 ],
744776 [499 , 599 ],
777+ ['my.com ' ],
745778 true ,
746779 true ,
747780 true ,
@@ -768,6 +801,7 @@ public static function provideMarkdownData(): array
768801 * @param array<string,string> $extraHttpHeaders
769802 * @param int[] $failOnHttpStatusCodes
770803 * @param int[] $failOnResourceHttpStatusCodes
804+ * @param string[] $ignoreResourceHttpStatusDomains
771805 * @param array<string,string|bool|float|int|array<string>> $metadata
772806 * @param Stream[] $embeds
773807 * @param Stream[] $assets
@@ -793,12 +827,14 @@ private function hydrateChromiumPdfFormData(
793827 Stream |null $ footer = null ,
794828 string |null $ waitDelay = null ,
795829 string |null $ waitForExpression = null ,
830+ string |null $ waitForSelector = null ,
796831 string |null $ emulatedMediaType = null ,
797832 array $ cookies = [],
798833 string |null $ userAgent = null ,
799834 array $ extraHttpHeaders = [],
800835 array $ failOnHttpStatusCodes = [],
801836 array $ failOnResourceHttpStatusCodes = [],
837+ array $ ignoreResourceHttpStatusDomains = [],
802838 bool $ failOnResourceLoadingFailed = false ,
803839 bool $ failOnConsoleExceptions = false ,
804840 bool |null $ skipNetworkIdleEvent = null ,
@@ -872,6 +908,10 @@ private function hydrateChromiumPdfFormData(
872908 $ chromium ->waitForExpression ($ waitForExpression );
873909 }
874910
911+ if ($ waitForSelector !== null ) {
912+ $ chromium ->waitForSelector ($ waitForSelector );
913+ }
914+
875915 if ($ emulatedMediaType === 'print ' ) {
876916 $ chromium ->emulatePrintMediaType ();
877917 }
@@ -900,6 +940,10 @@ private function hydrateChromiumPdfFormData(
900940 $ chromium ->failOnResourceHttpStatusCodes ($ failOnResourceHttpStatusCodes );
901941 }
902942
943+ if (count ($ ignoreResourceHttpStatusDomains ) > 0 ) {
944+ $ chromium ->ignoreResourceHttpStatusDomains ($ ignoreResourceHttpStatusDomains );
945+ }
946+
903947 if ($ failOnResourceLoadingFailed ) {
904948 $ chromium ->failOnResourceLoadingFailed ();
905949 }
@@ -952,6 +996,7 @@ private function hydrateChromiumPdfFormData(
952996 * @param array<string,string> $extraHttpHeaders
953997 * @param int[] $failOnHttpStatusCodes
954998 * @param int[] $failOnResourceHttpStatusCodes
999+ * @param string[] $ignoreResourceHttpStatusDomains
9551000 * @param array<string,string|bool|float|int|array<string>> $metadata
9561001 * @param Stream[] $embeds
9571002 * @param Stream[] $assets
@@ -977,12 +1022,14 @@ private function assertChromiumPdfOptions(
9771022 Stream |null $ footer ,
9781023 string |null $ waitDelay ,
9791024 string |null $ waitForExpression ,
1025+ string |null $ waitForSelector ,
9801026 string |null $ emulatedMediaType ,
9811027 array $ cookies ,
9821028 string |null $ userAgent ,
9831029 array $ extraHttpHeaders ,
9841030 array $ failOnHttpStatusCodes ,
9851031 array $ failOnResourceHttpStatusCodes ,
1032+ array $ ignoreResourceHttpStatusDomains ,
9861033 bool $ failOnResourceLoadingFailed ,
9871034 bool $ failOnConsoleExceptions ,
9881035 bool |null $ skipNetworkIdleEvent ,
@@ -1062,6 +1109,10 @@ private function assertChromiumPdfOptions(
10621109 $ this ->assertContainsFormValue ($ body , 'waitForExpression ' , $ waitForExpression );
10631110 }
10641111
1112+ if ($ waitForSelector !== null ) {
1113+ $ this ->assertContainsFormValue ($ body , 'waitForSelector ' , $ waitForSelector );
1114+ }
1115+
10651116 if ($ emulatedMediaType !== null ) {
10661117 $ this ->assertContainsFormValue ($ body , 'emulatedMediaType ' , $ emulatedMediaType );
10671118 }
@@ -1106,6 +1157,15 @@ private function assertChromiumPdfOptions(
11061157 $ this ->assertContainsFormValue ($ body , 'failOnResourceHttpStatusCodes ' , $ json );
11071158 }
11081159
1160+ if (count ($ ignoreResourceHttpStatusDomains ) > 0 ) {
1161+ $ json = json_encode ($ ignoreResourceHttpStatusDomains );
1162+ if ($ json === false ) {
1163+ throw NativeFunctionErrored::createFromLastPhpError ();
1164+ }
1165+
1166+ $ this ->assertContainsFormValue ($ body , 'ignoreResourceHttpStatusDomains ' , $ json );
1167+ }
1168+
11091169 if ($ failOnResourceLoadingFailed ) {
11101170 $ this ->assertContainsFormValue ($ body , 'failOnResourceLoadingFailed ' , '1 ' );
11111171 }
0 commit comments