Skip to content

Commit ebcdb2d

Browse files
author
Viktor Kopin
committed
MC-39755: Couple of videos cannot be added to the product at once
1 parent c9242e8 commit ebcdb2d

File tree

3 files changed

+50
-4
lines changed

3 files changed

+50
-4
lines changed

app/code/Magento/ProductVideo/etc/csp_whitelist.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
<policies>
1111
<policy id="script-src">
1212
<values>
13-
<value id="youtube_cdn" type="host">s.ytimg.com</value>
14-
<value id="google_video" type="host">www.googleapis.com</value>
13+
<value id="youtube_script" type="host">s.ytimg.com</value>
14+
<value id="google_apis" type="host">www.googleapis.com</value>
1515
<value id="vimeo" type="host">vimeo.com</value>
1616
<value id="www_vimeo" type="host">www.vimeo.com</value>
1717
<value id="vimeo_cdn" type="host">*.vimeocdn.com</value>
@@ -20,11 +20,13 @@
2020
<policy id="img-src">
2121
<values>
2222
<value id="vimeo_cdn" type="host">*.vimeocdn.com</value>
23+
<value id="youtube_image" type="host">i.ytimg.com</value>
2324
</values>
2425
</policy>
2526
<policy id="frame-src">
2627
<values>
2728
<value id="player_vimeo" type="host">player.vimeo.com</value>
29+
<value id="player_youtube" type="host">*.youtube.com</value>
2830
</values>
2931
</policy>
3032
</policies>

app/code/Magento/ProductVideo/view/adminhtml/web/js/get-video-information.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,10 @@ define([
289289
* @private
290290
*/
291291
destroy: function () {
292-
this.stop();
293-
294292
if (this._player) {
293+
this.stop();
295294
this._player.destroy();
295+
this._player = undefined;
296296
}
297297
}
298298
});
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
define([
6+
'jquery',
7+
'Magento_ProductVideo/js/get-video-information'
8+
], function ($) {
9+
'use strict';
10+
11+
describe('Testing Youtube player Widget', function () {
12+
var wdContainer;
13+
14+
beforeEach(function () {
15+
wdContainer = $(
16+
'<div>' +
17+
'<div class="video-information uploader"><span></span></div>' +
18+
'<div class="video-player-container">' +
19+
'<div class="product-video"></div>' +
20+
'</div>' +
21+
'</div>');
22+
});
23+
24+
afterEach(function () {
25+
$(wdContainer).remove();
26+
});
27+
28+
it('Widget does not stops player if player is no defined', function () {
29+
var video = wdContainer.find('.video-player-container').find('.product-video'),
30+
widget;
31+
32+
video.videoYoutube();
33+
widget = video.data('mageVideoYoutube');
34+
widget.stop = jasmine.createSpy();
35+
widget._player = {
36+
destroy: jasmine.createSpy()
37+
};
38+
widget.destroy();
39+
expect(widget._player).toBeUndefined();
40+
widget.destroy();
41+
expect(widget.stop).toHaveBeenCalledTimes(1);
42+
});
43+
});
44+
});

0 commit comments

Comments
 (0)