diff -u b/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php b/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php --- b/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php +++ b/core/modules/big_pipe/tests/src/Functional/BigPipeTest.php @@ -58,15 +58,27 @@ * This test disables the automatic refresh checking, each time it is * desired that this runs, a test case must explicitly call this. * + * @param bool $block_redirects + * Set to TRUE to block all redirects during the meta refresh. + * * @see setUp() + * + * @return int + * The number of refreshes done. */ - protected function performMetaRefresh() { - $this->getSession()->getDriver()->getClient()->followRedirects(FALSE); + protected function performMetaRefresh($block_redirects = FALSE) { + if ($block_redirects) { + $this->getSession()->getDriver()->getClient()->followRedirects(FALSE); + } $this->maximumMetaRefreshCount = 1; $this->checkForMetaRefresh(); $this->maximumMetaRefreshCount = 0; + $count = $this->metaRefreshCount; $this->metaRefreshCount = 0; - $this->getSession()->getDriver()->getClient()->followRedirects(TRUE); + if ($block_redirects) { + $this->getSession()->getDriver()->getClient()->followRedirects(TRUE); + } + return $count; } /** @@ -454,9 +466,7 @@ */ protected function assertBigPipeNoJsMetaRefreshRedirect() { $original_url = $this->getSession()->getCurrentUrl(); - - // Perform the MetaRefresh without following any additional redirects. - $this->performMetaRefresh(); + $this->performMetaRefresh(TRUE); $headers[0] = $this->getSession()->getResponseHeaders(); // First response: redirect. @@ -466,8 +476,13 @@ $this->assertTrue(empty(array_diff(['cookies:big_pipe_nojs', 'session.exists'], explode(' ', $headers[0]['X-Drupal-Cache-Contexts'][0]))), 'The first response varies by the "cookies:big_pipe_nojs" and "session.exists" cache contexts.'); $this->assertFalse(isset($headers[0]['Surrogate-Control']), 'The first response has no "Surrogate-Control" header.'); + // Remove the big_pipe_nojs cookie so we can follow the full redirect. + $this->getSession()->setCookie('big_pipe_nojs', NULL); + $this->drupalGet($original_url); + $count = $this->performMetaRefresh(FALSE); $this->assertEquals($original_url, $this->getSession()->getCurrentUrl(), 'Redirected back to the original location.'); + $this->assertEqual(1, $count, 'One refresh was done following the refresh'); $headers[1] = $this->getSession()->getResponseHeaders(); // Second response: redirect followed.