Skip to content

Commit

Permalink
fix: reduced motion support on Windows (#658)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Beru authored Jan 8, 2025
1 parent 1e8718e commit 73ca3da
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/ProcessManager/ChromeManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ private function getDefaultArguments(): array
// Prefer reduced motion, see https://developer.mozilla.org/docs/Web/CSS/@media/prefers-reduced-motion
if (!filter_var($_SERVER['PANTHER_NO_REDUCED_MOTION'] ?? false, \FILTER_VALIDATE_BOOLEAN)) {
$args[] = '--force-prefers-reduced-motion';
} else {
$args[] = '--force-prefers-no-reduced-motion';
}

// Add custom arguments with PANTHER_CHROME_ARGUMENTS
Expand Down
10 changes: 6 additions & 4 deletions src/ProcessManager/FirefoxManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,15 @@ public function start(): WebDriver
$capabilities->setCapability('moz:firefoxOptions', $firefoxOptions);

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

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

0 comments on commit 73ca3da

Please sign in to comment.