function BigPipeRegressionTest::doInlineScriptTest

Tests for the correct replacement of a chunk with inline javascript.

Parsing a <script> tag causes a mutation to be reported because it triggers a micro task checkpoint. Watching for template tags directly results in early mutation reporting, and the trailing markup is not yet parsed when the template is processed.

Also, chunk markup needs to not be double escaped. We encountered both regressions in https://www.drupal.org/project/drupal/issues/3526267.

1 call to BigPipeRegressionTest::doInlineScriptTest()
BigPipeRegressionTest::testPlaceholderHtmlEdgeCases in core/modules/big_pipe/tests/src/FunctionalJavascript/BigPipeRegressionTest.php
Tests edge cases with placeholder HTML.

File

core/modules/big_pipe/tests/src/FunctionalJavascript/BigPipeRegressionTest.php, line 198

Class

BigPipeRegressionTest
BigPipe regression tests.

Namespace

Drupal\Tests\big_pipe\FunctionalJavascript

Code

protected function doInlineScriptTest() : void {
  $user = $this->drupalCreateUser();
  $this->drupalLogin($user);
  $assert_session = $this->assertSession();
  $this->drupalGet(Url::fromRoute('big_pipe_regression_test.inline_script'));
  $this->assertNotNull($assert_session->waitForElement('css', 'script[data-big-pipe-event="stop"]'));
  $assert_session->elementExists('css', 'div.container-before');
  $assert_session->elementExists('css', 'body.inline-script-fires');
  $assert_session->elementExists('css', 'div.container-after');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.