Skip to content
This repository was archived by the owner on Jun 24, 2022. It is now read-only.

Commit 3455a31

Browse files
web audio api outputs silence for 302 redirected resource in safari
https://bugs.webkit.org/show_bug.cgi?id=214932 <rdar://problem/66300050> Reviewed by Darin Adler. Source/WebCore: If the resource is redirected to another origin, treat it as tainted only if the crossorigin attribute is not set. This is done for consistency with Blink: - https://github.com/chromium/chromium/blob/master/media/blink/webmediaplayer_impl.cc (see WouldTaintOrigin()) The new behavior also seems to match Firefox. Tests: http/tests/security/webaudio-render-remote-audio-allowed-crossorigin-redirect.html http/tests/security/webaudio-render-remote-audio-blocked-no-crossorigin-redirect.html * Modules/webaudio/MediaElementAudioSourceNode.cpp: (WebCore::MediaElementAudioSourceNode::wouldTaintOrigin): LayoutTests: Add layout test coverage. Update existing test to reflect the fact that the frequency returned by the AnalyserNode is -Infinity when input is silent, not minDecibels (this has changed fairly recently). * http/tests/security/webaudio-render-remote-audio-allowed-crossorigin-redirect-expected.txt: Added. * http/tests/security/webaudio-render-remote-audio-allowed-crossorigin-redirect.html: Copied from LayoutTests/http/tests/security/webaudio-render-remote-audio-allowed-crossorigin.html. * http/tests/security/webaudio-render-remote-audio-allowed-crossorigin.html: * http/tests/security/webaudio-render-remote-audio-blocked-no-crossorigin-redirect-expected.txt: Added. * http/tests/security/webaudio-render-remote-audio-blocked-no-crossorigin-redirect.html: Copied from LayoutTests/http/tests/security/webaudio-render-remote-audio-allowed-crossorigin.html. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@267532 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent c3aa4e6 commit 3455a31

9 files changed

+167
-5
lines changed

LayoutTests/ChangeLog

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
2020-09-24 Chris Dumez <[email protected]>
2+
3+
web audio api outputs silence for 302 redirected resource in safari
4+
https://bugs.webkit.org/show_bug.cgi?id=214932
5+
<rdar://problem/66300050>
6+
7+
Reviewed by Darin Adler.
8+
9+
Add layout test coverage. Update existing test to reflect the fact that the frequency returned by
10+
the AnalyserNode is -Infinity when input is silent, not minDecibels (this has changed fairly
11+
recently).
12+
13+
* http/tests/security/webaudio-render-remote-audio-allowed-crossorigin-redirect-expected.txt: Added.
14+
* http/tests/security/webaudio-render-remote-audio-allowed-crossorigin-redirect.html: Copied from LayoutTests/http/tests/security/webaudio-render-remote-audio-allowed-crossorigin.html.
15+
* http/tests/security/webaudio-render-remote-audio-allowed-crossorigin.html:
16+
* http/tests/security/webaudio-render-remote-audio-blocked-no-crossorigin-redirect-expected.txt: Added.
17+
* http/tests/security/webaudio-render-remote-audio-blocked-no-crossorigin-redirect.html: Copied from LayoutTests/http/tests/security/webaudio-render-remote-audio-allowed-crossorigin.html.
18+
119
2020-09-24 Frederic Wang <[email protected]>
220

321
Resync WPT's mathml and math-script-level-and-math-style tests
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Ensure that audio is rendered when tainted by a remote audio resource when CORS is enabled.
2+
3+
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
4+
5+
6+
PASS outputArray is not silentArray
7+
PASS successfullyParsed is true
8+
9+
TEST COMPLETE
10+
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<script src="../../../resources/js-test-pre.js"></script>
5+
<script src="../../media-resources/media-file.js"></script>
6+
</head>
7+
<body>
8+
<pre id="console"></pre>
9+
<script>
10+
description("Ensure that audio is rendered when tainted by a remote audio resource when CORS is enabled.");
11+
window.jsTestIsAsync = true;
12+
13+
function go() {
14+
let audio = new Audio();
15+
audio.crossOrigin = "anonymous";
16+
let mediaFile = findMediaFile("audio", "../../media/resources/1000Hz-sin");
17+
let type = mimeTypeForExtension(mediaFile.split('.').pop());
18+
audio.src = "http://localhost:8080/security/resources/redirect-allow-star.php?url=" + encodeURIComponent("http://127.0.0.1:8080/security/resources/video-cross-origin-allow.php?name=" + mediaFile + "&type=" + type);
19+
20+
context = new AudioContext();
21+
let mediaSource = context.createMediaElementSource(audio);
22+
let analyser = context.createAnalyser();
23+
analyser.fftSize = 32;
24+
25+
mediaSource.connect(analyser);
26+
27+
context.resume().then(() => {
28+
audio.play();
29+
});
30+
31+
window.outputArray = new Float32Array(analyser.frequencyBinCount);
32+
window.silentArray = new Float32Array(analyser.frequencyBinCount);
33+
silentArray.fill(-Infinity);
34+
35+
var intervalToken = setInterval(() => {
36+
analyser.getFloatFrequencyData(outputArray);
37+
}, 30);
38+
39+
audio.addEventListener("ended", event => {
40+
clearInterval(intervalToken);
41+
context.suspend().then(() => {
42+
shouldNotBe("outputArray", "silentArray");
43+
finishJSTest();
44+
});
45+
});
46+
}
47+
window.addEventListener('load', go);
48+
</script>
49+
<script src="../../../resources/js-test-post.js"></script>
50+
</body>
51+
</html>

LayoutTests/http/tests/security/webaudio-render-remote-audio-allowed-crossorigin.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
window.outputArray = new Float32Array(analyser.frequencyBinCount);
3232
window.silentArray = new Float32Array(analyser.frequencyBinCount);
33-
silentArray.fill(analyser.minDecibels);
33+
silentArray.fill(-Infinity);
3434

3535
var intervalToken = setInterval(() => {
3636
analyser.getFloatFrequencyData(outputArray);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Ensure that audio is not rendered when tainted by a remote audio resource when CORS is not enabled.
2+
3+
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
4+
5+
6+
PASS outputArray is silentArray
7+
PASS successfullyParsed is true
8+
9+
TEST COMPLETE
10+
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<script src="../../../resources/js-test-pre.js"></script>
5+
<script src="../../media-resources/media-file.js"></script>
6+
</head>
7+
<body>
8+
<pre id="console"></pre>
9+
<script>
10+
description("Ensure that audio is not rendered when tainted by a remote audio resource when CORS is not enabled.");
11+
window.jsTestIsAsync = true;
12+
13+
function go() {
14+
let audio = new Audio();
15+
let mediaFile = findMediaFile("audio", "../../media/resources/1000Hz-sin");
16+
let type = mimeTypeForExtension(mediaFile.split('.').pop());
17+
audio.src = "http://localhost:8080/security/resources/redirect-allow-star.php?url=" + encodeURIComponent("http://127.0.0.1:8080/security/resources/video-cross-origin-allow.php?name=" + mediaFile + "&type=" + type);
18+
19+
context = new AudioContext();
20+
let mediaSource = context.createMediaElementSource(audio);
21+
let analyser = context.createAnalyser();
22+
analyser.fftSize = 32;
23+
24+
mediaSource.connect(analyser);
25+
26+
context.resume().then(() => {
27+
audio.play();
28+
});
29+
30+
window.outputArray = new Float32Array(analyser.frequencyBinCount);
31+
window.silentArray = new Float32Array(analyser.frequencyBinCount);
32+
silentArray.fill(-Infinity);
33+
34+
var intervalToken = setInterval(() => {
35+
analyser.getFloatFrequencyData(outputArray);
36+
}, 30);
37+
38+
audio.addEventListener("ended", event => {
39+
clearInterval(intervalToken);
40+
context.suspend().then(() => {
41+
shouldBe("outputArray", "silentArray");
42+
finishJSTest();
43+
});
44+
});
45+
}
46+
window.addEventListener('load', go);
47+
</script>
48+
<script src="../../../resources/js-test-post.js"></script>
49+
</body>
50+
</html>

LayoutTests/platform/win/TestExpectations

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,10 @@ webkit.org/b/86914 fast/history/page-cache-closed-audiocontext.html [ Skip ]
529529
webkit.org/b/86914 fast/history/page-cache-running-audiocontext.html [ Skip ]
530530
webkit.org/b/86914 fast/history/page-cache-suspended-audiocontext.html [ Skip ]
531531
webkit.org/b/86914 media/W3C/audio [ Skip ]
532+
webkit.org/b/86914 http/tests/security/webaudio-render-remote-audio-allowed-crossorigin.html [ Skip ]
533+
webkit.org/b/86914 http/tests/security/webaudio-render-remote-audio-blocked-no-crossorigin.html [ Skip ]
534+
webkit.org/b/86914 http/tests/security/webaudio-render-remote-audio-allowed-crossorigin-redirect.html [ Skip ]
535+
webkit.org/b/86914 http/tests/security/webaudio-render-remote-audio-blocked-no-crossorigin-redirect.html [ Skip ]
532536

533537
# ENABLE(DRAGGABLE_REGION) is disabled
534538
fast/css/draggable-region-parser.html [ Skip ]
@@ -4018,9 +4022,6 @@ webkit.org/b/185075 css3/color-filters/color-filter-inherits.html [ ImageOnlyFai
40184022
webkit.org/b/185075 css3/color-filters/color-filter-outline.html [ ImageOnlyFailure ]
40194023
webkit.org/b/185075 css3/color-filters/color-filter-text-emphasis.html [ ImageOnlyFailure ]
40204024

4021-
webkit.org/b/185471 http/tests/security/webaudio-render-remote-audio-allowed-crossorigin.html [ Skip ]
4022-
webkit.org/b/185471 http/tests/security/webaudio-render-remote-audio-blocked-no-crossorigin.html [ Skip ]
4023-
40244025
webkit.org/b/185765 fast/images/animated-image-mp4-crash.html [ Skip ]
40254026

40264027
webkit.org/b/185678 fast/css-generated-content/pseudo-animation.html [ Failure ]

Source/WebCore/ChangeLog

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
2020-09-24 Chris Dumez <[email protected]>
2+
3+
web audio api outputs silence for 302 redirected resource in safari
4+
https://bugs.webkit.org/show_bug.cgi?id=214932
5+
<rdar://problem/66300050>
6+
7+
Reviewed by Darin Adler.
8+
9+
If the resource is redirected to another origin, treat it as tainted only if the crossorigin attribute
10+
is not set. This is done for consistency with Blink:
11+
- https://github.com/chromium/chromium/blob/master/media/blink/webmediaplayer_impl.cc (see WouldTaintOrigin())
12+
13+
The new behavior also seems to match Firefox.
14+
15+
Tests: http/tests/security/webaudio-render-remote-audio-allowed-crossorigin-redirect.html
16+
http/tests/security/webaudio-render-remote-audio-blocked-no-crossorigin-redirect.html
17+
18+
* Modules/webaudio/MediaElementAudioSourceNode.cpp:
19+
(WebCore::MediaElementAudioSourceNode::wouldTaintOrigin):
20+
121
2020-09-24 Youenn Fablet <[email protected]>
222

323
Regression(r265280) Web Audio sources malfunction when disconnected from the audio graph

Source/WebCore/Modules/webaudio/MediaElementAudioSourceNode.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ void MediaElementAudioSourceNode::setFormat(size_t numberOfChannels, float sourc
123123

124124
bool MediaElementAudioSourceNode::wouldTaintOrigin()
125125
{
126-
if (!m_mediaElement->hasSingleSecurityOrigin())
126+
// If the resource is redirected to another origin, treat it as tainted if the crossorigin attribute
127+
// is not set. This is done for consistency with Blink.
128+
if (!m_mediaElement->hasSingleSecurityOrigin() && m_mediaElement->crossOrigin().isNull())
127129
return true;
128130

129131
if (m_mediaElement->didPassCORSAccessCheck())

0 commit comments

Comments
 (0)