Skip to content

Commit 6efda91

Browse files
committed
Fix filter() to use keys and allow extension capabilities
The filter() method had three bugs: 1. array_filter callback received values instead of keys, causing TypeError when capability values are arrays (e.g. goog:chromeOptions) 2. Extension capabilities (keys containing ':') were stripped, but W3C spec requires them to be allowed through 3. array_values() destroyed the key-value mapping, turning {"browserName": "chrome"} into ["chrome"] Fix by using ARRAY_FILTER_USE_KEY, allowing extension capabilities per W3C spec, and removing array_values() wrapper. References: - https://www.w3.org/TR/webdriver2/#dfn-extension-capability - https://www.php.net/array_filter
1 parent b440f54 commit 6efda91

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

lib/WebDriver/WebDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public function sessions()
166166
*/
167167
private function filter($capabilities)
168168
{
169-
return $capabilities ? array_values(array_filter($capabilities, function ($capability) { return self::$w3cCapabilities[$capability] ?? 0; })) : null;
169+
return $capabilities ? array_filter($capabilities, function ($key) { return isset(self::$w3cCapabilities[$key]) || str_contains($key, ':'); }, ARRAY_FILTER_USE_KEY) : null;
170170
}
171171

172172
/**

0 commit comments

Comments
 (0)