Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Limit DOMAudioSession to third-party iframes having microphone access
https://bugs.webkit.org/show_bug.cgi?id=249577 rdar://problem/103514560 Reviewed by Eric Carlson. We might want to allow access to DOMAudioSession to more third party iframes in the future. For now, since the main use case is microphone/WebRTC related, let's reduce access to those iframes that can access microphones. * LayoutTests/http/tests/webrtc/audioSessionInFrames-expected.txt: Added. * LayoutTests/http/tests/webrtc/audioSessionInFrames.html: Added. * LayoutTests/http/tests/webrtc/resources/audioSessionFrame.html: Added. * LayoutTests/platform/glib/TestExpectations: * Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml: * Source/WebCore/Modules/audiosession/DOMAudioSession.cpp: (WebCore::DOMAudioSession::setType): (WebCore::DOMAudioSession::type const): (WebCore::DOMAudioSession::state const): (WebCore::DOMAudioSession::scheduleStateChangeEvent): Canonical link: https://commits.webkit.org/258423@main
- Loading branch information
Showing
5 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
LayoutTests/http/tests/webrtc/audioSessionInFrames-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
PASS Allow audioSession in iframes where microphone is allowed | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<!DOCTYPE html> | ||
<body> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
function with_iframe(url, allow) { | ||
let frame = document.createElement('iframe'); | ||
frame.src = url; | ||
frame.setAttribute('allow', allow); | ||
return new Promise(resolve => { | ||
frame.onload = () => { resolve(frame); }; | ||
document.body.appendChild(frame); | ||
}); | ||
} | ||
|
||
promise_test(async () => { | ||
navigator.audioSession.type = "play-and-record"; | ||
await navigator.mediaDevices.getUserMedia({ audio: true }); | ||
|
||
const frame1 = await with_iframe("http://localhost:8080/webrtc/resources/audioSessionFrame.html", "microphone:'none'"); | ||
const result1 = await new Promise(resolve => window.onmessage = (event) => resolve(event.data)); | ||
frame1.remove(); | ||
|
||
const frame2 = await with_iframe("http://localhost:8080/webrtc/resources/audioSessionFrame.html", "microphone"); | ||
const result2 = await new Promise(resolve => window.onmessage = (event) => resolve(event.data)); | ||
frame2.remove(); | ||
|
||
assert_equals(result1.type, "auto"); | ||
assert_equals(result1.state, "inactive"); | ||
|
||
assert_equals(result2.type, "play-and-record"); | ||
assert_equals(result2.state, "active"); | ||
}, "Allow audioSession in iframes where microphone is allowed"); | ||
</script> | ||
</body> |
11 changes: 11 additions & 0 deletions
11
LayoutTests/http/tests/webrtc/resources/audioSessionFrame.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!DOCTYPE html> | ||
<body> | ||
<script> | ||
onload = () => { | ||
parent.postMessage({ | ||
type: navigator.audioSession.type, | ||
state: navigator.audioSession.state | ||
}, "*"); | ||
} | ||
</script> | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters