Skip to content

Commit

Permalink
fix legacy array "moz:firefoxOptions"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Beru committed Dec 10, 2024
1 parent 3315ce1 commit 83527aa
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/ProcessManager/FirefoxManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,23 @@ public function start(): WebDriver
$this->waitUntilReady($this->process, $url.$this->options['path'], 'firefox');
}

$capabilities = DesiredCapabilities::firefox();

/** @var FirefoxOptions $firefoxOptions */
$firefoxOptions = $capabilities->getCapability(FirefoxOptions::CAPABILITY);
$firefoxOptions = [];
if (isset($_SERVER['PANTHER_FIREFOX_BINARY'])) {
$firefoxOptions->setOption('binary', $_SERVER['PANTHER_FIREFOX_BINARY']);
$firefoxOptions['binary'] = $_SERVER['PANTHER_FIREFOX_BINARY'];
}
if ($this->arguments) {
$firefoxOptions->addArguments($this->arguments);
$firefoxOptions['args'] = $this->arguments;
}

$capabilities = DesiredCapabilities::firefox();
$capabilities->setCapability('moz:firefoxOptions', $firefoxOptions);

// Prefer reduced motion, see https://developer.mozilla.org/fr/docs/Web/CSS/@media/prefers-reduced-motion
if ($_SERVER['PANTHER_REDUCED_MOTION'] ?? false) {
$firefoxOptions->setPreference('ui.prefersReducedMotion', 'reduced');
/** @var FirefoxOptions|array $firefoxOptions */
$firefoxOptions = $capabilities->getCapability('moz:firefoxOptions') ?? [];
$firefoxOptions = $firefoxOptions instanceof FirefoxOptions ? $firefoxOptions->toArray() : $firefoxOptions;
$firefoxOptions['prefs']['ui.prefersReducedMotion'] = 'reduced';
}

foreach ($this->options['capabilities'] as $capability => $value) {
Expand Down

0 comments on commit 83527aa

Please sign in to comment.