File tree Expand file tree Collapse file tree 4 files changed +24
-2
lines changed
Expand file tree Collapse file tree 4 files changed +24
-2
lines changed Original file line number Diff line number Diff line change 9696 run : vendor/bin/phpunit
9797 env :
9898 CHROME_PATH : /opt/hostedtoolcache/setup-chrome/chromium/122.0.6261.128/x64/chrome
99+ CHROME_NO_SANDBOX : true
Original file line number Diff line number Diff line change 66* Add PHP 8.5 support
77* Add support for using Symfony 8 components
88* Remove support for Symfony 4 components
9+ * Merge options with defaults in factory
10+ * Add ` CHROME_NO_SANDBOX ` env var
911
1012
1113## 1.14.0 (2025-05-28)
Original file line number Diff line number Diff line change @@ -69,4 +69,21 @@ private static function shellExec(string $command): ?string
6969 return null ;
7070 }
7171 }
72+
73+ /**
74+ * Get default browser options from environment variables.
75+ *
76+ * @return array<string, mixed>
77+ */
78+ public function getDefaultOptions (): array
79+ {
80+ $ options = [];
81+
82+ if (\array_key_exists ('CHROME_NO_SANDBOX ' , $ _SERVER )
83+ && \filter_var ($ _SERVER ['CHROME_NO_SANDBOX ' ], \FILTER_VALIDATE_BOOLEAN )) {
84+ $ options ['noSandbox ' ] = true ;
85+ }
86+
87+ return $ options ;
88+ }
7289}
Original file line number Diff line number Diff line change @@ -52,7 +52,9 @@ class BrowserFactory
5252
5353 public function __construct (?string $ chromeBinary = null )
5454 {
55- $ this ->chromeBinary = $ chromeBinary ?? (new AutoDiscover ())->guessChromeBinaryPath ();
55+ $ autoDiscover = new AutoDiscover ();
56+ $ this ->chromeBinary = $ chromeBinary ?? $ autoDiscover ->guessChromeBinaryPath ();
57+ $ this ->options = \array_merge ($ this ->options , $ autoDiscover ->getDefaultOptions ());
5658 }
5759
5860 /**
@@ -66,7 +68,7 @@ public function __construct(?string $chromeBinary = null)
6668 */
6769 public function createBrowser (?array $ options = null ): ProcessAwareBrowser
6870 {
69- $ options ??= $ this ->options ;
71+ $ options = \array_merge ( $ this ->options , $ options ?? []) ;
7072
7173 // create logger from options
7274 $ logger = self ::createLogger ($ options );
You can’t perform that action at this time.
0 commit comments