Commit 84ab4133 authored by Sebastian Michaelsen's avatar Sebastian Michaelsen Committed by Georg Ringer
Browse files

[BUGFIX] Provide full url as origin for embedded Youtube videos

To use the javascript API for embedded Youtube videos the documentation
recommends to provide the "full website url" as origin parameter

Change-Id: I318083b4c67b48c7eb708e54b11cd8dd1c69d646
Resolves: #77409
Releases: master, 7.6
Reviewed-on: https://review.typo3.org/49416

Tested-by: default avatarBamboo TYPO3com <info@typo3.com>
Reviewed-by: default avatarDaniel Goerz <ervaude@gmail.com>
Tested-by: default avatarDaniel Goerz <ervaude@gmail.com>
Reviewed-by: default avatarJoerg Boesche <typo3@joergboesche.de>
Tested-by: default avatarJoerg Boesche <typo3@joergboesche.de>
Reviewed-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
Tested-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
parent e5c510f1
......@@ -108,7 +108,7 @@ class YouTubeRenderer implements FileRendererInterface
$urlParams[] = 'loop=1';
}
if (!isset($options['enablejsapi']) || !empty($options['enablejsapi'])) {
$urlParams[] = 'enablejsapi=1&amp;origin=' . GeneralUtility::getIndpEnv('HTTP_HOST');
$urlParams[] = 'enablejsapi=1&amp;origin=' . GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL');
}
$urlParams[] = 'showinfo=' . (int)!empty($options['showinfo']);
......
......@@ -39,6 +39,7 @@ class YouTubeRendererTest extends UnitTestCase
parent::setUp();
GeneralUtility::flushInternalRuntimeCaches();
$_SERVER['HTTP_HOST'] = 'test.server.org';
$_SERVER['REQUEST_URI'] = '/test-page/';
/** @var YouTubeHelper|\PHPUnit_Framework_MockObject_MockObject $youTubeHelper */
$youTubeHelper = $this->getAccessibleMock(YouTubeHelper::class, array('getOnlineMediaId'), array('youtube'));
......@@ -94,7 +95,7 @@ class YouTubeRendererTest extends UnitTestCase
$fileResourceMock = $this->createMock(File::class);
$this->assertSame(
'<iframe src="//www.youtube.com/embed/7331?autohide=1&amp;controls=2&amp;enablejsapi=1&amp;origin=test.server.org&amp;showinfo=0" allowfullscreen width="300" height="200"></iframe>',
'<iframe src="//www.youtube.com/embed/7331?autohide=1&amp;controls=2&amp;enablejsapi=1&amp;origin=http://test.server.org/test-page/&amp;showinfo=0" allowfullscreen width="300" height="200"></iframe>',
$this->subject->render($fileResourceMock, '300m', '200')
);
}
......@@ -108,7 +109,7 @@ class YouTubeRendererTest extends UnitTestCase
$fileResourceMock = $this->createMock(File::class);
$this->assertSame(
'<iframe src="//www.youtube.com/embed/7331?autohide=1&amp;controls=2&amp;loop=1&amp;enablejsapi=1&amp;origin=test.server.org&amp;showinfo=0" allowfullscreen width="300" height="200"></iframe>',
'<iframe src="//www.youtube.com/embed/7331?autohide=1&amp;controls=2&amp;loop=1&amp;enablejsapi=1&amp;origin=http://test.server.org/test-page/&amp;showinfo=0" allowfullscreen width="300" height="200"></iframe>',
$this->subject->render($fileResourceMock, '300m', '200', array('loop' => 1))
);
}
......@@ -122,7 +123,7 @@ class YouTubeRendererTest extends UnitTestCase
$fileResourceMock = $this->createMock(File::class);
$this->assertSame(
'<iframe src="//www.youtube.com/embed/7331?autohide=1&amp;controls=2&amp;autoplay=1&amp;enablejsapi=1&amp;origin=test.server.org&amp;showinfo=0" allowfullscreen width="300" height="200"></iframe>',
'<iframe src="//www.youtube.com/embed/7331?autohide=1&amp;controls=2&amp;autoplay=1&amp;enablejsapi=1&amp;origin=http://test.server.org/test-page/&amp;showinfo=0" allowfullscreen width="300" height="200"></iframe>',
$this->subject->render($fileResourceMock, '300m', '200', array('autoplay' => 1))
);
}
......@@ -141,7 +142,7 @@ class YouTubeRendererTest extends UnitTestCase
$fileReferenceMock->expects($this->any())->method('getOriginalFile')->willReturn($fileResourceMock);
$this->assertSame(
'<iframe src="//www.youtube.com/embed/7331?autohide=1&amp;controls=2&amp;autoplay=1&amp;enablejsapi=1&amp;origin=test.server.org&amp;showinfo=0" allowfullscreen width="300" height="200"></iframe>',
'<iframe src="//www.youtube.com/embed/7331?autohide=1&amp;controls=2&amp;autoplay=1&amp;enablejsapi=1&amp;origin=http://test.server.org/test-page/&amp;showinfo=0" allowfullscreen width="300" height="200"></iframe>',
$this->subject->render($fileReferenceMock, '300m', '200')
);
}
......@@ -155,7 +156,7 @@ class YouTubeRendererTest extends UnitTestCase
$fileResourceMock = $this->createMock(File::class);
$this->assertSame(
'<iframe src="//www.youtube.com/embed/7331?autohide=1&amp;autoplay=1&amp;enablejsapi=1&amp;origin=test.server.org&amp;showinfo=0" allowfullscreen width="300" height="200"></iframe>',
'<iframe src="//www.youtube.com/embed/7331?autohide=1&amp;autoplay=1&amp;enablejsapi=1&amp;origin=http://test.server.org/test-page/&amp;showinfo=0" allowfullscreen width="300" height="200"></iframe>',
$this->subject->render($fileResourceMock, '300m', '200', array('controls' => 0, 'autoplay' => 1))
);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment