Skip to content

Commit f60ba77

Browse files
committed
SpeechRecognition interface and friends should be SecureContext
rdar://151240414 https://bugs.webkit.org/show_bug.cgi?id=292941 Reviewed by Brady Eidson, Per Arne Vollan, and Sihui Liu. Align implementation with WebAudio/web-speech-api#31. * LayoutTests/http/wpt/mediastream/speechrecognition-insecure-expected.txt: Added. * LayoutTests/http/wpt/mediastream/speechrecognition-insecure.html: Added. * Source/WebCore/Modules/speech/SpeechRecognition.idl: * Source/WebCore/Modules/speech/SpeechRecognitionAlternative.idl: * Source/WebCore/Modules/speech/SpeechRecognitionErrorEvent.idl: * Source/WebCore/Modules/speech/SpeechRecognitionEvent.idl: * Source/WebCore/Modules/speech/SpeechRecognitionResult.idl: Canonical link: https://commits.webkit.org/294887@main
1 parent 58dae86 commit f60ba77

7 files changed

+41
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
3+
PASS SpeechRecognition and friends should not exist in insecure context
4+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!DOCTYPE html>
2+
<head>
3+
<script src="/resources/testharness.js"></script>
4+
<script src="/resources/testharnessreport.js"></script>
5+
</head>
6+
<body>
7+
<script>
8+
if (window.internals)
9+
internals.markContextAsInsecure();
10+
11+
function with_iframe(url) {
12+
return new Promise(function(resolve) {
13+
var frame = document.createElement('iframe');
14+
frame.className = 'test-iframe';
15+
frame.src = url;
16+
frame.onload = function() { resolve(frame); };
17+
document.body.appendChild(frame);
18+
});
19+
}
20+
21+
promise_test(async () => {
22+
const frame = await with_iframe("/");
23+
const w = frame.contentWindow;
24+
assert_equals(w.SpeechRecognition, undefined);
25+
assert_equals(w.SpeechRecognitionAlternative, undefined);
26+
assert_equals(w.SpeechRecognitionErrorEvent, undefined);
27+
assert_equals(w.SpeechRecognitionEvent, undefined);
28+
assert_equals(w.SpeechRecognitionResult, undefined);
29+
},'SpeechRecognition and friends should not exist in insecure context');
30+
</script>
31+
</body>
32+
</html>

Source/WebCore/Modules/speech/SpeechRecognition.idl

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
ActiveDOMObject,
2828
EnabledBySetting=SpeechRecognitionEnabled,
2929
InterfaceName=webkitSpeechRecognition,
30+
SecureContext,
3031
Exposed=Window
3132
] interface SpeechRecognition : EventTarget {
3233
[CallWith=CurrentDocument] constructor();

Source/WebCore/Modules/speech/SpeechRecognitionAlternative.idl

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
[
2727
EnabledBySetting=SpeechRecognitionEnabled,
28+
SecureContext,
2829
Exposed=Window
2930
] interface SpeechRecognitionAlternative {
3031
readonly attribute DOMString transcript;

Source/WebCore/Modules/speech/SpeechRecognitionErrorEvent.idl

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
[
2727
EnabledBySetting=SpeechRecognitionEnabled,
28+
SecureContext,
2829
Exposed=Window
2930
] interface SpeechRecognitionErrorEvent : Event {
3031
constructor([AtomString] DOMString type, SpeechRecognitionErrorEventInit eventInitDict);

Source/WebCore/Modules/speech/SpeechRecognitionEvent.idl

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
[
2727
EnabledBySetting=SpeechRecognitionEnabled,
28+
SecureContext,
2829
Exposed=Window
2930
] interface SpeechRecognitionEvent : Event {
3031
constructor([AtomString] DOMString type, SpeechRecognitionEventInit eventInitDict);

Source/WebCore/Modules/speech/SpeechRecognitionResult.idl

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
[
2727
EnabledBySetting=SpeechRecognitionEnabled,
28+
SecureContext,
2829
Exposed=Window
2930
] interface SpeechRecognitionResult {
3031
readonly attribute unsigned long length;

0 commit comments

Comments
 (0)