Problem/Motivation

With curl 7.66.0 instaclick/php-webdriver fail when testing with selenium/standalone-chrome with WebDriver\Exception\CurlExec: Webdriver http error: 400, payload :<h1>Bad Message 400</h1><pre>reason: Bad Content-Length</pre>

Proposed resolution

This is resolved in this commit from instaclick, but we subclass their service, so we need to update our class to match

Remaining tasks

None.

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

None.

CommentFileSizeAuthor
#2 3083183.patch1017 byteslarowlan
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

larowlan created an issue. See original summary.

larowlan’s picture

Status: Active » Needs review
FileSize
1017 bytes
jibran’s picture

https://www.drupal.org/pift-ci-job/1414084 is passing so we do need a failing patch here.

acbramley’s picture

My guess would be that the 7.1 containers aren't using the new cURL. Definitely need the fix to run WebDriver tests on the latest version.

Wim Leers’s picture

Title: Newer versions of curl/selenium webdriver require additional headers » FunctionalJavaScript tests fail because newer versions of curl/selenium webdriver require additional headers
Priority: Normal » Critical
Status: Needs review » Reviewed & tested by the community
Related issues: +#3084651: WebDriver HTTP error 400 Bad Content-Length errors

Thanks to @acbramley for pointing out I filed a duplicate issue at #3084651: WebDriver HTTP error 400 Bad Content-Length errors. I wrote the exact same patch and a similar but slightly more detailed issue summary:

Problem/Motivation

#2942900: Convert JavascriptTestBase Tests to use DrupalSelenium2Driver introduced \Drupal\FunctionalJavascriptTests\WebDriverCurlService.

That extends \WebDriver\Service\CurlService, which was recently updated to not send

                    $customHeaders[] = 'Content-Length: 0';

but

                    $customHeaders[] = 'Content-Length: 0';

                    // Suppress "Transfer-Encoding: chunked" header automatically added by cURL that
                    // causes a 400 bad request (bad content-length).
                    $customHeaders[] = 'Transfer-Encoding:';

Drupal's subclass does not do that, and hence results in errors like this:

1) Drupal\Tests\media\FunctionalJavascript\CKEditorIntegrationTest::testPreviewUsesDefaultThemeAndIsClientCacheable
WebDriver\Exception\CurlExec: Curl error thrown for http POST to http://localhost:4444/wd/hub/session/96b11bb539709524afdbb8393ed07e6c/element/0.8283755658968526-1/click

The requested URL returned error: 400 Bad Content-Length

/Users/wim.leers/Work/d8/vendor/instaclick/php-webdriver/lib/WebDriver/Exception.php:155
/Users/wim.leers/Work/d8/core/tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php:107
/Users/wim.leers/Work/d8/vendor/instaclick/php-webdriver/lib/WebDriver/AbstractWebDriver.php:123
/Users/wim.leers/Work/d8/vendor/instaclick/php-webdriver/lib/WebDriver/AbstractWebDriver.php:218
/Users/wim.leers/Work/d8/vendor/instaclick/php-webdriver/lib/WebDriver/Container.php:224
/Users/wim.leers/Work/d8/vendor/behat/mink-selenium2-driver/src/Selenium2Driver.php:781
/Users/wim.leers/Work/d8/vendor/behat/mink-selenium2-driver/src/Selenium2Driver.php:769
/Users/wim.leers/Work/d8/vendor/behat/mink/src/Element/NodeElement.php:153
/Users/wim.leers/Work/d8/vendor/behat/mink/src/Element/NodeElement.php:161
/Users/wim.leers/Work/d8/core/tests/Drupal/Tests/UiHelperTrait.php:100
/Users/wim.leers/Work/d8/core/tests/Drupal/Tests/UiHelperTrait.php:250
/Users/wim.leers/Work/d8/core/modules/media/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php:153

This happens with:

Proposed resolution

Port the upstream changes.

Wim Leers’s picture

I bumped this to Critical because while it does not break DrupalCI today, it will whenever it is updated. It already breaks local development environments of core developers.

Wim Leers’s picture

acbramley’s picture

I've updated the blog post to make it more clear that core needs a different fix, I did have it in there but it wasn't as obvious :)

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 56895fda5c to 8.8.x and 23240dd132 to 8.7.x. Thanks!

Backported to 8.7.x since this is a test fix.

diff --git a/core/tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php b/core/tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php
index eba9dcce7a..eb2eb301f3 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php
@@ -42,6 +42,10 @@ public function execute($requestMethod, $url, $parameters = NULL, $extraOptions
             }
             else {
               $customHeaders[] = 'Content-Length: 0';
+
+              // Suppress "Transfer-Encoding: chunked" header automatically
+              // added by cURL that causes a 400 bad request (bad
+              // content-length).
               $customHeaders[] = 'Transfer-Encoding:';
             }
 
@@ -63,6 +67,10 @@ public function execute($requestMethod, $url, $parameters = NULL, $extraOptions
             }
             else {
               $customHeaders[] = 'Content-Length: 0';
+
+              // Suppress "Transfer-Encoding: chunked" header automatically
+              // added by cURL that causes a 400 bad request (bad
+              // content-length).
               $customHeaders[] = 'Transfer-Encoding:';
             }
 

I added the comment from the upstream commit because that seems useful.

  • alexpott committed 56895fd on 8.8.x
    Issue #3083183 by larowlan, Wim Leers, acbramley: FunctionalJavaScript...

  • alexpott committed 23240dd on 8.7.x
    Issue #3083183 by larowlan, Wim Leers, acbramley: FunctionalJavaScript...
Wim Leers’s picture

@acbramley++ — I definitely missed that 😅

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

larowlan’s picture

Version: 8.8.x-dev » 8.7.x-dev

this was backported to 8.7.x