function MediaTest::getLastPreviewRequestTransferSize

Same name in this branch
  1. 9 core/modules/ckeditor5/tests/src/FunctionalJavascript/MediaTest.php \Drupal\Tests\ckeditor5\FunctionalJavascript\MediaTest::getLastPreviewRequestTransferSize()

Gets the transfer size of the last preview request.

Return value

int The size of the bytes transferred.

File

core/modules/ckeditor/tests/src/FunctionalJavascript/MediaTest.php, line 1470

Class

MediaTest
@coversDefaultClass \Drupal\ckeditor\Plugin\CKEditorPlugin\DrupalMedia[[api-linebreak]] @group ckeditor @group legacy

Namespace

Drupal\Tests\ckeditor\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);
}

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