FIX: Disable preloading audio + video when secure media enabled (#8922)
Meta topic: https://meta.discourse.org/t/secure-media-uploads-expire/140894 This fixes the issue where if secure media was enabled, audio and video files would do an initial load using the presigned URL for the media to get metadata information e.g. duration of track/video. However this started the expiry countdown for the URL, so when a user pressed play on the media after 15 seconds the media would be expired and AWS would return a 403 error. We do not preload media if secure media is enabled. Otherwise we just set the preload type to "metadata" which is the browser default anyway.
This commit is contained in:
@@ -973,11 +973,37 @@ QUnit.test("images", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("video - secure media enabled", assert => {
|
||||
assert.cookedOptions(
|
||||
"",
|
||||
{ siteSettings: { secure_media: true } },
|
||||
`<p><div class="video-container">
|
||||
<video width="100%" height="100%" preload="none" controls>
|
||||
<source src="/404" data-orig-src="upload://eyPnj7UzkU0AkGkx2dx8G4YM1Jx.mp4">
|
||||
<a href="/404">/404</a>
|
||||
</video>
|
||||
</div></p>`,
|
||||
"It returns the correct video player HTML"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("audio - secure media enabled", assert => {
|
||||
assert.cookedOptions(
|
||||
"",
|
||||
{ siteSettings: { secure_media: true } },
|
||||
`<p><audio preload="none" controls>
|
||||
<source src="/404" data-orig-src="upload://eyPnj7UzkU0AkGkx2dx8G4YM1Jx.mp3">
|
||||
<a href="/404">/404</a>
|
||||
</audio></p>`,
|
||||
"It returns the correct audio player HTML"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("video", assert => {
|
||||
assert.cooked(
|
||||
"",
|
||||
`<p><div class="video-container">
|
||||
<video width="100%" height="100%" controls>
|
||||
<video width="100%" height="100%" preload="metadata" controls>
|
||||
<source src="/404" data-orig-src="upload://eyPnj7UzkU0AkGkx2dx8G4YM1Jx.mp4">
|
||||
<a href="/404">/404</a>
|
||||
</video>
|
||||
@@ -989,7 +1015,7 @@ QUnit.test("video", assert => {
|
||||
QUnit.test("audio", assert => {
|
||||
assert.cooked(
|
||||
"",
|
||||
`<p><audio controls>
|
||||
`<p><audio preload="metadata" controls>
|
||||
<source src="/404" data-orig-src="upload://eyPnj7UzkU0AkGkx2dx8G4YM1Jx.mp3">
|
||||
<a href="/404">/404</a>
|
||||
</audio></p>`,
|
||||
|
||||
Reference in New Issue
Block a user