function MediaSourceOEmbedVideoTest::testOEmbedSecurityWarning

Same name in other branches
  1. 9 core/modules/media/tests/src/FunctionalJavascript/MediaSourceOEmbedVideoTest.php \Drupal\Tests\media\FunctionalJavascript\MediaSourceOEmbedVideoTest::testOEmbedSecurityWarning()
  2. 8.9.x core/modules/media/tests/src/FunctionalJavascript/MediaSourceOEmbedVideoTest.php \Drupal\Tests\media\FunctionalJavascript\MediaSourceOEmbedVideoTest::testOEmbedSecurityWarning()
  3. 11.x core/modules/media/tests/src/FunctionalJavascript/MediaSourceOEmbedVideoTest.php \Drupal\Tests\media\FunctionalJavascript\MediaSourceOEmbedVideoTest::testOEmbedSecurityWarning()

Tests that a security warning appears if iFrame domain is not set.

File

core/modules/media/tests/src/FunctionalJavascript/MediaSourceOEmbedVideoTest.php, line 241

Class

MediaSourceOEmbedVideoTest
Tests the oembed:video media source.

Namespace

Drupal\Tests\media\FunctionalJavascript

Code

public function testOEmbedSecurityWarning() : void {
    $media_type_id = 'test_media_oembed_type';
    $source_id = 'oembed:video';
    $session = $this->getSession();
    $page = $session->getPage();
    $assert_session = $this->assertSession();
    $this->drupalGet('admin/structure/media/add');
    $page->fillField('label', $media_type_id);
    $this->getSession()
        ->wait(5000, "jQuery('.machine-name-value').text() === '{$media_type_id}'");
    // Make sure the source is available.
    $assert_session->fieldExists('Media source');
    $assert_session->optionExists('Media source', $source_id);
    $page->selectFieldOption('Media source', $source_id);
    $result = $assert_session->waitForElementVisible('css', 'fieldset[data-drupal-selector="edit-source-configuration"]');
    $this->assertNotEmpty($result);
    $assert_session->pageTextContains('It is potentially insecure to display oEmbed content in a frame');
    $this->config('media.settings')
        ->set('iframe_domain', 'http://example.com')
        ->save();
    $this->drupalGet('admin/structure/media/add');
    $page->fillField('label', $media_type_id);
    $this->getSession()
        ->wait(5000, "jQuery('.machine-name-value').text() === '{$media_type_id}'");
    // Make sure the source is available.
    $assert_session->fieldExists('Media source');
    $assert_session->optionExists('Media source', $source_id);
    $page->selectFieldOption('Media source', $source_id);
    $result = $assert_session->waitForElementVisible('css', 'fieldset[data-drupal-selector="edit-source-configuration"]');
    $this->assertNotEmpty($result);
    $assert_session->pageTextNotContains('It is potentially insecure to display oEmbed content in a frame');
}

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