diff --git a/.gitlab-ci/pipeline-test-only.yml b/.gitlab-ci/pipeline-test-only.yml index 460763eeb85c26d896dafbdb271d8fc930dd92bd..7f78a3af315aac184017f6f863b67d3f16bd86ba 100644 --- a/.gitlab-ci/pipeline-test-only.yml +++ b/.gitlab-ci/pipeline-test-only.yml @@ -14,7 +14,7 @@ variables: POSTGRES_DB: drupaltestbot POSTGRES_USER: drupaltestbot POSTGRES_PASSWORD: drupaltestbotpw - MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", {"browserName":"chrome","chromeOptions":{"args":["--disable-dev-shm-usage","--disable-gpu","--headless"]}}, "http://localhost:9515"]' + MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", {"browserName":"chrome","goog:chromeOptions":{"args":["--disable-dev-shm-usage","--disable-gpu","--headless"]}}, "http://localhost:9515"]' '🩹 Test-only changes': stage: ðŸ—œï¸ Test diff --git a/.gitlab-ci/pipeline.yml b/.gitlab-ci/pipeline.yml index abca7943880a0614443d91d8b59bb7c53e169120..faa0cf2fdd1b4ca793421502d9ed12de2ee17e64 100644 --- a/.gitlab-ci/pipeline.yml +++ b/.gitlab-ci/pipeline.yml @@ -67,7 +67,7 @@ variables: POSTGRES_DB: drupaltestbot POSTGRES_USER: drupaltestbot POSTGRES_PASSWORD: drupaltestbotpw - MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", {"browserName":"chrome","chromeOptions":{"args":["--disable-dev-shm-usage","--disable-gpu","--headless","--dns-prefetch-disable"]}}, "http://localhost:9515"]' + MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", {"browserName":"chrome","goog:chromeOptions":{"args":["--disable-dev-shm-usage","--disable-gpu","--headless","--dns-prefetch-disable"]}}, "http://localhost:9515"]' CI_PARALLEL_NODE_INDEX: $CI_NODE_INDEX CI_PARALLEL_NODE_TOTAL: $CI_NODE_TOTAL diff --git a/composer.json b/composer.json index 78a8fa159d4bbb2209219db3ca9daac9c4620adc..671f2875d99d6e0ae65ef27a2e7dc9a01934234c 100644 --- a/composer.json +++ b/composer.json @@ -17,12 +17,12 @@ "require-dev": { "behat/mink": "^1.11", "behat/mink-browserkit-driver": "^2.2", - "behat/mink-selenium2-driver": "^1.7", "colinodell/psr-testlogger": "^1.2", "composer/composer": "^2.7", "drupal/coder": "^8.3.10", - "instaclick/php-webdriver": "^1.4.1", "justinrainbow/json-schema": "^5.2", + "lullabot/mink-selenium2-driver": "^1.7", + "lullabot/php-webdriver": "^2.0.3", "mglaman/phpstan-drupal": "^1.2.1", "micheh/phpcs-gitlab": "^1.1", "mikey179/vfsstream": "^1.6.11", diff --git a/composer.lock b/composer.lock index 6a5cfd4b5ff14e4ac2449cd4232ad2852cc2ac5a..5b5f39617770e674238e0f50fef501bf5da4b574 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "9103791a18c3a090bfd3335ff65a404a", + "content-hash": "50678d888725975acfa1fb438696b593", "packages": [ { "name": "asm89/stack-cors", @@ -4576,76 +4576,6 @@ }, "time": "2023-12-09T11:30:50+00:00" }, - { - "name": "behat/mink-selenium2-driver", - "version": "v1.7.0", - "source": { - "type": "git", - "url": "https://github.com/minkphp/MinkSelenium2Driver.git", - "reference": "4ca4083f305de7dff4434ac402dc4e3f39c0866a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/minkphp/MinkSelenium2Driver/zipball/4ca4083f305de7dff4434ac402dc4e3f39c0866a", - "reference": "4ca4083f305de7dff4434ac402dc4e3f39c0866a", - "shasum": "" - }, - "require": { - "behat/mink": "^1.11@dev", - "ext-json": "*", - "instaclick/php-webdriver": "^1.4.14", - "php": ">=7.2" - }, - "require-dev": { - "mink/driver-testsuite": "dev-master", - "phpstan/phpstan": "^1.10", - "phpstan/phpstan-phpunit": "^1.3", - "phpunit/phpunit": "^8.5.22 || ^9.5.11", - "symfony/error-handler": "^4.4 || ^5.0 || ^6.0 || ^7.0" - }, - "type": "mink-driver", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Behat\\Mink\\Driver\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Pete Otaqui", - "email": "pete@otaqui.com", - "homepage": "https://github.com/pete-otaqui" - }, - { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - } - ], - "description": "Selenium2 (WebDriver) driver for Mink framework", - "homepage": "https://mink.behat.org/", - "keywords": [ - "ajax", - "browser", - "javascript", - "selenium", - "testing", - "webdriver" - ], - "support": { - "issues": "https://github.com/minkphp/MinkSelenium2Driver/issues", - "source": "https://github.com/minkphp/MinkSelenium2Driver/tree/v1.7.0" - }, - "time": "2023-12-09T11:58:45+00:00" - }, { "name": "colinodell/psr-testlogger", "version": "v1.3.0", @@ -5517,69 +5447,6 @@ }, "time": "2023-11-15T21:36:03+00:00" }, - { - "name": "instaclick/php-webdriver", - "version": "1.4.18", - "source": { - "type": "git", - "url": "https://github.com/instaclick/php-webdriver.git", - "reference": "a61a8459f86c79dd1f19934ea3929804f2e41f8c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/instaclick/php-webdriver/zipball/a61a8459f86c79dd1f19934ea3929804f2e41f8c", - "reference": "a61a8459f86c79dd1f19934ea3929804f2e41f8c", - "shasum": "" - }, - "require": { - "ext-curl": "*", - "php": ">=5.3.2" - }, - "require-dev": { - "phpunit/phpunit": "^8.5 || ^9.5", - "satooshi/php-coveralls": "^1.0 || ^2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4.x-dev" - } - }, - "autoload": { - "psr-0": { - "WebDriver": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache-2.0" - ], - "authors": [ - { - "name": "Justin Bishop", - "email": "jubishop@gmail.com", - "role": "Developer" - }, - { - "name": "Anthon Pang", - "email": "apang@softwaredevelopment.ca", - "role": "Fork Maintainer" - } - ], - "description": "PHP WebDriver for Selenium 2", - "homepage": "http://instaclick.com/", - "keywords": [ - "browser", - "selenium", - "webdriver", - "webtest" - ], - "support": { - "issues": "https://github.com/instaclick/php-webdriver/issues", - "source": "https://github.com/instaclick/php-webdriver/tree/1.4.18" - }, - "time": "2023-12-08T07:11:19+00:00" - }, { "name": "justinrainbow/json-schema", "version": "v5.2.13", @@ -5650,6 +5517,124 @@ }, "time": "2023-09-26T02:20:38+00:00" }, + { + "name": "lullabot/mink-selenium2-driver", + "version": "v1.7.2", + "source": { + "type": "git", + "url": "https://github.com/Lullabot/MinkSelenium2Driver.git", + "reference": "5f9ecc2dc329d87442843f6143a4307a62fc5f8c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Lullabot/MinkSelenium2Driver/zipball/5f9ecc2dc329d87442843f6143a4307a62fc5f8c", + "reference": "5f9ecc2dc329d87442843f6143a4307a62fc5f8c", + "shasum": "" + }, + "require": { + "behat/mink": "^1.11@dev", + "ext-json": "*", + "lullabot/php-webdriver": "^2.0", + "php": ">=7.2" + }, + "replace": { + "behat/mink-selenium2-driver": "1.7.0" + }, + "require-dev": { + "mink/driver-testsuite": "dev-master", + "phpstan/phpstan": "^1.10", + "phpstan/phpstan-phpunit": "^1.3", + "phpunit/phpunit": "^8.5.22 || ^9.5.11", + "symfony/error-handler": "^4.4 || ^5.0 || ^6.0 || ^7.0" + }, + "type": "mink-driver", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Behat\\Mink\\Driver\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Pete Otaqui", + "email": "pete@otaqui.com", + "homepage": "https://github.com/pete-otaqui" + }, + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + } + ], + "description": "Selenium2 (WebDriver) driver for Mink framework", + "homepage": "https://mink.behat.org/", + "keywords": [ + "ajax", + "browser", + "javascript", + "selenium", + "testing", + "webdriver" + ], + "support": { + "source": "https://github.com/Lullabot/MinkSelenium2Driver/tree/v1.7.2" + }, + "time": "2024-02-12T10:40:39+00:00" + }, + { + "name": "lullabot/php-webdriver", + "version": "v2.0.3", + "source": { + "type": "git", + "url": "https://github.com/Lullabot/php-webdriver.git", + "reference": "ca66013201d8b0ef634ee5d1685fc7bb95c88d89" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Lullabot/php-webdriver/zipball/ca66013201d8b0ef634ee5d1685fc7bb95c88d89", + "reference": "ca66013201d8b0ef634ee5d1685fc7bb95c88d89", + "shasum": "" + }, + "require": { + "ext-curl": "*" + }, + "replace": { + "instaclick/php-webdriver": "1.4.16" + }, + "require-dev": { + "phpunit/phpunit": "^8.5 || ^9.5" + }, + "type": "library", + "autoload": { + "psr-0": { + "WebDriver": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "description": "PHP WebDriver for Selenium 2", + "homepage": "https://www.lullabot.com/", + "keywords": [ + "browser", + "selenium", + "webdriver", + "webtest" + ], + "support": { + "source": "https://github.com/Lullabot/php-webdriver/tree/v2.0.3" + }, + "time": "2024-02-20T16:25:25+00:00" + }, { "name": "mglaman/phpstan-drupal", "version": "1.2.4", diff --git a/composer/Metapackage/DevDependencies/composer.json b/composer/Metapackage/DevDependencies/composer.json index fef6d5681c9c637e0562c8d7b0ed1e6c8de41561..7a5931134873e36cd84c68c5b24140b3ca26cdb6 100644 --- a/composer/Metapackage/DevDependencies/composer.json +++ b/composer/Metapackage/DevDependencies/composer.json @@ -9,12 +9,12 @@ "require": { "behat/mink": "^1.11", "behat/mink-browserkit-driver": "^2.2", - "behat/mink-selenium2-driver": "^1.7", "colinodell/psr-testlogger": "^1.2", "composer/composer": "^2.7", "drupal/coder": "^8.3.10", - "instaclick/php-webdriver": "^1.4.1", "justinrainbow/json-schema": "^5.2", + "lullabot/mink-selenium2-driver": "^1.7", + "lullabot/php-webdriver": "^2.0.3", "mglaman/phpstan-drupal": "^1.2.1", "micheh/phpcs-gitlab": "^1.1", "mikey179/vfsstream": "^1.6.11", diff --git a/composer/Metapackage/PinnedDevDependencies/composer.json b/composer/Metapackage/PinnedDevDependencies/composer.json index b04ef07535c6c4f448bc45131eaaf16704c8b737..94a2c8a5a16c79672f03d67429382246851c4c3f 100644 --- a/composer/Metapackage/PinnedDevDependencies/composer.json +++ b/composer/Metapackage/PinnedDevDependencies/composer.json @@ -10,7 +10,6 @@ "drupal/core": "11.x-dev", "behat/mink": "v1.11.0", "behat/mink-browserkit-driver": "v2.2.0", - "behat/mink-selenium2-driver": "v1.7.0", "colinodell/psr-testlogger": "v1.3.0", "composer/ca-bundle": "1.3.7", "composer/class-map-generator": "1.1.0", @@ -23,8 +22,9 @@ "doctrine/instantiator": "2.0.0", "drupal/coder": "8.3.22", "google/protobuf": "v3.25.1", - "instaclick/php-webdriver": "1.4.18", "justinrainbow/json-schema": "v5.2.13", + "lullabot/mink-selenium2-driver": "v1.7.2", + "lullabot/php-webdriver": "v2.0.3", "mglaman/phpstan-drupal": "1.2.4", "micheh/phpcs-gitlab": "1.1.0", "mikey179/vfsstream": "v1.6.11", diff --git a/composer/Plugin/VendorHardening/Config.php b/composer/Plugin/VendorHardening/Config.php index ab15475ec674005d5ad7428752544c531215fa9e..3db5c3372a3b0338c7ab19d26172726adc64dfd9 100644 --- a/composer/Plugin/VendorHardening/Config.php +++ b/composer/Plugin/VendorHardening/Config.php @@ -22,7 +22,6 @@ class Config { protected static $defaultConfig = [ 'behat/mink' => ['tests'], 'behat/mink-browserkit-driver' => ['tests'], - 'behat/mink-selenium2-driver' => ['tests'], 'composer/composer' => ['bin'], 'drupal/coder' => [ 'coder_sniffer/Drupal/Test', @@ -32,8 +31,9 @@ class Config { 'egulias/email-validator' => ['documentation', 'tests'], 'guzzlehttp/promises' => ['tests'], 'guzzlehttp/psr7' => ['tests'], - 'instaclick/php-webdriver' => ['doc', 'test'], 'justinrainbow/json-schema' => ['demo'], + 'lullabot/mink-selenium2-driver' => ['tests'], + 'lullabot/php-webdriver' => ['doc', 'test'], 'masterminds/html5' => ['bin', 'test'], 'mck89/peast' => ['doc'], 'mikey179/vfsstream' => ['src/test'], diff --git a/core/misc/cspell/drupal-dictionary.txt b/core/misc/cspell/drupal-dictionary.txt index ad9b37217b465dc60035a3be86788a841b3c218e..734ad8e1aaacac6de1b3ca2793753d4cd571d532 100644 --- a/core/misc/cspell/drupal-dictionary.txt +++ b/core/misc/cspell/drupal-dictionary.txt @@ -8,6 +8,7 @@ druplicon drush langcode langcodes +lullabot olivero olivero's simpletest diff --git a/core/phpunit.xml.dist b/core/phpunit.xml.dist index 1acb8cc92fc53442698ae7f4ea793279decafd46..c616c8c179f608d03bb9c546ddf8bf456595b3cf 100644 --- a/core/phpunit.xml.dist +++ b/core/phpunit.xml.dist @@ -57,7 +57,7 @@ <env name="MINK_DRIVER_CLASS" value=''/> <!-- Example for changing the driver args to mink tests MINK_DRIVER_ARGS value: '["http://127.0.0.1:8510"]' --> <env name="MINK_DRIVER_ARGS" value=''/> - <!-- Example for changing the driver args to webdriver tests MINK_DRIVER_ARGS_WEBDRIVER value: '["chrome", { "chromeOptions": { "w3c": false } }, "http://localhost:4444/wd/hub"]' For using the Firefox browser, replace "chrome" with "firefox" --> + <!-- Example for changing the driver args to webdriver tests MINK_DRIVER_ARGS_WEBDRIVER value: '["chrome", { "goog:chromeOptions": { "w3c": false } }, "http://localhost:4444/wd/hub"]' For using the Firefox browser, replace "chrome" with "firefox" --> <env name="MINK_DRIVER_ARGS_WEBDRIVER" value=''/> </php> <testsuites> diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Tests/DrupalSelenium2DriverTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Tests/DrupalSelenium2DriverTest.php index 45ad21bcf13c60af504a1dc57ec9d1817247d198..16089b7a26fe3dc07a0789fa8aaf4b7486bdf35e 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/Tests/DrupalSelenium2DriverTest.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/Tests/DrupalSelenium2DriverTest.php @@ -4,6 +4,7 @@ namespace Drupal\FunctionalJavascriptTests\Tests; +use Behat\Mink\Driver\Selenium2Driver; use Drupal\entity_test\Entity\EntityTest; use Drupal\FunctionalJavascriptTests\WebDriverTestBase; use Drupal\Tests\file\Functional\FileFieldCreationTrait; @@ -48,6 +49,9 @@ protected function setUp(): void { */ public function testGetRemoteFilePath() { $web_driver = $this->getSession()->getDriver(); + $this->assertInstanceOf(Selenium2Driver::class, $web_driver); + $this->assertFalse($web_driver->isW3C(), 'Driver is not operating in W3C mode'); + $file_system = \Drupal::service('file_system'); $entity = EntityTest::create(); $entity->save(); diff --git a/core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php b/core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php index 0ce8dddf67752c018e06826db27b93a22b7b2dcc..9ec27626137cb0446ef0747389102652c75b01a8 100644 --- a/core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php +++ b/core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php @@ -48,7 +48,7 @@ protected function initMink() { if (!is_a($this->minkDefaultDriverClass, DrupalSelenium2Driver::class, TRUE)) { throw new \UnexpectedValueException(sprintf("%s has to be an instance of %s", $this->minkDefaultDriverClass, DrupalSelenium2Driver::class)); } - $this->minkDefaultDriverArgs = ['chrome', NULL, 'http://localhost:4444']; + $this->minkDefaultDriverArgs = ['chrome', ['goog:chromeOptions' => ['w3c' => FALSE]], 'http://localhost:4444']; try { return parent::initMink(); @@ -145,7 +145,22 @@ protected function failOnJavaScriptErrors(): void { */ protected function getMinkDriverArgs() { if ($this->minkDefaultDriverClass === DrupalSelenium2Driver::class) { - return getenv('MINK_DRIVER_ARGS_WEBDRIVER') ?: parent::getMinkDriverArgs(); + $json = getenv('MINK_DRIVER_ARGS_WEBDRIVER') ?: parent::getMinkDriverArgs(); + if (!($json === FALSE || $json === '')) { + $args = json_decode($json, TRUE); + if (isset($args[1]['chromeOptions'])) { + @trigger_error('The "chromeOptions" array key is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use "goog:chromeOptions instead. See https://www.drupal.org/node/3422624', E_USER_DEPRECATED); + $args[1]['goog:chromeOptions'] = $args[1]['chromeOptions']; + unset($args[1]['chromeOptions']); + } + if (isset($args[0]) && $args[0] === 'chrome' && !isset($args[1]['goog:chromeOptions']['w3c'])) { + // @todo https://www.drupal.org/project/drupal/issues/3421202 + // Deprecate defaulting behavior and require w3c to be set. + $args[1]['goog:chromeOptions']['w3c'] = FALSE; + } + $json = json_encode($args); + } + return $json; } return parent::getMinkDriverArgs(); } diff --git a/core/tests/Drupal/Tests/Composer/fixtures/ensureBehatDriverVersionsFixture/composer.lock b/core/tests/Drupal/Tests/Composer/fixtures/ensureBehatDriverVersionsFixture/composer.lock index bcf6d8a30393f78dd416a27bec590b48b5c4f29d..42bc36ee59012ff0674238d9e3d85b2803fb1b1e 100644 --- a/core/tests/Drupal/Tests/Composer/fixtures/ensureBehatDriverVersionsFixture/composer.lock +++ b/core/tests/Drupal/Tests/Composer/fixtures/ensureBehatDriverVersionsFixture/composer.lock @@ -5,12 +5,12 @@ "content-hash": "da9910627bab73a256b39ceda83d7167", "packages-dev": [ { - "name": "behat/mink-selenium2-driver", - "version": "dev-master", + "name": "lullabot/mink-selenium2-driver", + "version": "dev-main", "source": { "type": "git", - "url": "https://github.com/minkphp/MinkSelenium2Driver.git", - "reference": "0a09c4341621fca937a726827611b20ce3e2c259" + "url": "https://github.com/Lullabot/MinkSelenium2Driver.git", + "reference": "228004452354c1945fec2d273de2586da8c29213" } } ] diff --git a/core/tests/Drupal/Tests/Core/Test/WebDriverTestBaseTest.php b/core/tests/Drupal/Tests/Core/Test/WebDriverTestBaseTest.php new file mode 100644 index 0000000000000000000000000000000000000000..d457f21e81e7a7efb044a8ad2d627e5247e26089 --- /dev/null +++ b/core/tests/Drupal/Tests/Core/Test/WebDriverTestBaseTest.php @@ -0,0 +1,75 @@ +<?php + +declare(strict_types=1); + +namespace Drupal\Tests\Core\Test; + +use Drupal\FunctionalJavascriptTests\WebDriverTestBase; +use Drupal\Tests\UnitTestCase; + +/** + * @coversDefaultClass \Drupal\FunctionalJavascriptTests\WebDriverTestBase + * @group Test + * @runTestsInSeparateProcesses + */ +class WebDriverTestBaseTest extends UnitTestCase { + + /** + * Tests W3C setting is added to goog:chromeOptions as expected. + * + * @testWith [false, null] + * [false, ""] + * ["", "", ""] + * ["[\"chrome\",{\"browserName\":\"chrome\",\"goog:chromeOptions\":{\"w3c\":true,\"args\":[\"--headless\"]}},\"http:\\/\\/localhost:4444\"]", "[\"chrome\",{\"browserName\":\"chrome\",\"goog:chromeOptions\":{\"w3c\":true,\"args\":[\"--headless\"]}},\"http:\\/\\/localhost:4444\"]"] + * ["[\"chrome\",{\"browserName\":\"chrome\",\"goog:chromeOptions\":{\"w3c\":false,\"args\":[\"--headless\"]}},\"http:\\/\\/localhost:4444\"]", "[\"chrome\",{\"browserName\":\"chrome\",\"goog:chromeOptions\":{\"w3c\":false,\"args\":[\"--headless\"]}},\"http:\\/\\/localhost:4444\"]"] + * ["[\"chrome\",{\"browserName\":\"chrome\",\"goog:chromeOptions\":{\"args\":[\"--headless\"],\"w3c\":false}},\"http:\\/\\/localhost:4444\"]", "[\"chrome\",{\"browserName\":\"chrome\",\"goog:chromeOptions\":{\"args\":[\"--headless\"]}},\"http:\\/\\/localhost:4444\"]"] + * ["[\"chrome\",{\"browserName\":\"chrome\",\"goog:chromeOptions\":{\"w3c\":false}},\"http:\\/\\/localhost:4444\"]", "[\"chrome\",{\"browserName\":\"chrome\"},\"http:\\/\\/localhost:4444\"]"] + * + * @covers ::getMinkDriverArgs + */ + public function testCapabilities($expected, ?string $mink_driver_args_webdriver, ?string $mink_driver_args = NULL): void { + $this->putEnv("MINK_DRIVER_ARGS_WEBDRIVER", $mink_driver_args_webdriver); + $this->putEnv("MINK_DRIVER_ARGS", $mink_driver_args); + + $object = $this->getMockForAbstractClass(WebDriverTestBase::class); + $method = new \ReflectionMethod($object, 'getMinkDriverArgs'); + $this->assertSame($expected, $method->invoke($object)); + } + + /** + * Sets or deletes an environment variable. + * + * @param string $variable + * The environment variable to set or delete. + * @param string|null $value + * The value to set the variable to. If the value is NULL then the + * environment variable will be unset. + * + * @return void + */ + private function putEnv(string $variable, ?string $value): void { + if (is_string($value)) { + putenv($variable . "=" . $value); + } + else { + putenv($variable); + } + } + + /** + * Tests "chromeOptions" deprecation. + * + * @group legacy + * + * @covers ::getMinkDriverArgs + */ + public function testChromeOptions(): void { + $this->expectDeprecation('The "chromeOptions" array key is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use "goog:chromeOptions instead. See https://www.drupal.org/node/3422624'); + putenv('MINK_DRIVER_ARGS_WEBDRIVER=["chrome",{"browserName":"chrome","chromeOptions":{"args":["--headless"]}},"http://localhost:4444"]'); + + $object = $this->getMockForAbstractClass(WebDriverTestBase::class); + $method = new \ReflectionMethod($object, 'getMinkDriverArgs'); + $this->assertSame('["chrome",{"browserName":"chrome","goog:chromeOptions":{"args":["--headless"],"w3c":false}},"http:\\/\\/localhost:4444"]', $method->invoke($object)); + } + +} diff --git a/core/tests/Drupal/Tests/PerformanceTestTrait.php b/core/tests/Drupal/Tests/PerformanceTestTrait.php index 92fba9b31c99acd753bb637b69bf7bb0ff93d4b4..cf55441128741ca2636d12c6b7419a66e666adb0 100644 --- a/core/tests/Drupal/Tests/PerformanceTestTrait.php +++ b/core/tests/Drupal/Tests/PerformanceTestTrait.php @@ -75,7 +75,9 @@ private function doGetMinkDriverArgs(): string { 'performance' => 'ALL', 'performanceTimeline' => 'ALL', ]; - $driver_args[1]['chromeOptions']['perfLoggingPrefs'] = [ + // Support legacy key. + $chrome_options_key = isset($driver_args[1]['chromeOptions']) ? 'chromeOptions' : 'goog:chromeOptions'; + $driver_args[1][$chrome_options_key]['perfLoggingPrefs'] = [ 'traceCategories' => 'timeline,devtools.timeline,browser', ];