diff --git a/core/modules/simpletest/src/AssertContentTrait.php b/core/modules/simpletest/src/AssertContentTrait.php index 4efee0e..fc5ddbc 100644 --- a/core/modules/simpletest/src/AssertContentTrait.php +++ b/core/modules/simpletest/src/AssertContentTrait.php @@ -65,9 +65,8 @@ protected function setRawContent($content) { $this->plainTextContent = NULL; $this->elements = NULL; $this->drupalSettings = array(); - $result = $this->xpath('//body/script[@type="application/json"][@data-drupal-selector="drupal-settings-json"]'); - if ($result) { - $this->drupalSettings = Json::decode((string) $result[0]); + if (preg_match('@@', $content, $matches)) { + $this->drupalSettings = Json::decode($matches[1]); } } diff --git a/core/modules/system/src/Tests/Common/AttachedAssetsTest.php b/core/modules/system/src/Tests/Common/AttachedAssetsTest.php index ca8dbc6..e9a1974 100644 --- a/core/modules/system/src/Tests/Common/AttachedAssetsTest.php +++ b/core/modules/system/src/Tests/Common/AttachedAssetsTest.php @@ -185,9 +185,9 @@ function testAggregation() { $rendered_footer_js = \Drupal::service('asset.js.collection_renderer')->render($footer_js); $this->assertTrue( count($rendered_footer_js) == 2 - && substr($rendered_footer_js[0]['#value'], 0, 20) === 'var drupalSettings =' + && $rendered_footer_js[0]['#attributes']['data-drupal-selector'] === 'drupal-settings-json' && substr($rendered_footer_js[1]['#attributes']['src'], 0, 7) === 'http://', - 'There are 2 JavaScript assets in the footer: one with drupalSettings, one with the sole aggregated JavaScript asset.' + 'There are 2 JavaScript assets in the footer: one with drupal settings, one with the sole aggregated JavaScript asset.' ); } @@ -206,9 +206,9 @@ function testSettings() { $rendered_js = $this->renderer->renderPlain($js_render_array); // Parse the generated drupalSettings