Mercurial > hg > cmmr2012-drupal-site
diff core/modules/media/tests/src/FunctionalJavascript/MediaSourceOEmbedVideoTest.php @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | a9cd425dd02b |
children |
line wrap: on
line diff
--- a/core/modules/media/tests/src/FunctionalJavascript/MediaSourceOEmbedVideoTest.php Thu Feb 28 13:11:55 2019 +0000 +++ b/core/modules/media/tests/src/FunctionalJavascript/MediaSourceOEmbedVideoTest.php Thu May 09 15:34:47 2019 +0100 @@ -91,6 +91,16 @@ $assert_session->selectExists('field_map[author_name]')->setValue('field_string_author_name'); $assert_session->buttonExists('Save')->press(); + // Configure the iframe to be narrower than the actual video, so we can + // verify that the video scales correctly. + $display = entity_get_display('media', $media_type_id, 'default'); + $this->assertFalse($display->isNew()); + $component = $display->getComponent('field_media_oembed_video'); + $this->assertInternalType('array', $component); + $component['settings']['max_width'] = 240; + $display->setComponent('field_media_oembed_video', $component); + $this->assertSame(SAVED_UPDATED, $display->save()); + $this->hijackProviderEndpoints(); $video_url = 'https://vimeo.com/7073899'; ResourceController::setResourceUrl($video_url, $this->getFixturesDirectory() . '/video_vimeo.json'); @@ -112,16 +122,24 @@ $thumbnail = $media->getSource()->getMetadata($media, 'thumbnail_uri'); $this->assertFileExists($thumbnail); - // Ensure the iframe exists and that its src attribute contains a coherent - // URL with the query parameters we expect. - $iframe_url = $assert_session->elementExists('css', 'iframe')->getAttribute('src'); - $iframe_url = parse_url($iframe_url); + // Ensure the iframe exists and has the expected CSS class, and that its src + // attribute contains a coherent URL with the query parameters we expect. + $iframe = $assert_session->elementExists('css', 'iframe.media-oembed-content'); + $iframe_url = parse_url($iframe->getAttribute('src')); $this->assertStringEndsWith('/media/oembed', $iframe_url['path']); $this->assertNotEmpty($iframe_url['query']); $query = []; parse_str($iframe_url['query'], $query); $this->assertSame($video_url, $query['url']); $this->assertNotEmpty($query['hash']); + // Ensure that the outer iframe's width respects the formatter settings. + $this->assertSame('240', $iframe->getAttribute('width')); + // Check the inner iframe to make sure that CSS has been applied to scale it + // correctly, regardless of whatever its width attribute may be (the fixture + // hard-codes it to 480). + $inner_frame = 'frames[0].document.querySelector("iframe")'; + $this->assertSame('480', $session->evaluateScript("$inner_frame.getAttribute('width')")); + $this->assertLessThanOrEqual(240, $session->evaluateScript("$inner_frame.clientWidth")); // Make sure the thumbnail is displayed from uploaded image. $assert_session->elementAttributeContains('css', '.image-style-thumbnail', 'src', '/oembed_thumbnails/' . basename($thumbnail));