You are here

protected function CKEditorIntegrationTest::getLastPreviewRequestTransferSize in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/media/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php \Drupal\Tests\media\FunctionalJavascript\CKEditorIntegrationTest::getLastPreviewRequestTransferSize()

Gets the transfer size of the last preview request.

Return value

int The size of the bytes transferred.

1 call to CKEditorIntegrationTest::getLastPreviewRequestTransferSize()
CKEditorIntegrationTest::testPreviewUsesDefaultThemeAndIsClientCacheable in core/modules/media/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php
The CKEditor Widget must load a preview generated using the default theme.

File

core/modules/media/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php, line 1457

Class

CKEditorIntegrationTest
@coversDefaultClass \Drupal\media\Plugin\CKEditorPlugin\DrupalMedia @group media

Namespace

Drupal\Tests\media\FunctionalJavascript

Code

protected function getLastPreviewRequestTransferSize() {
  $this
    ->getSession()
    ->switchToIFrame();
  $javascript = <<<JS
(function(){
  return window.performance
    .getEntries()
    .filter(function (entry) {
      return entry.initiatorType == 'xmlhttprequest' && entry.name.indexOf('/media/test_format/preview') !== -1;
    })
    .pop()
    .transferSize;
})()
JS;
  return $this
    ->getSession()
    ->evaluateScript($javascript);
}