Files
tubestation/testing/web-platform/tests/speech-api/SpeechRecognition-onDeviceWebSpeechAvailable.https.html
Evan Liu 7223dfc960 Bug 1940503 [wpt PR 49972] - Add WPT for installOnDeviceSpeechRecognition and onDeviceSpeechRecognitionAvailable, a=testonly
Automatic update from web-platform-tests
Add WPT for installOnDeviceSpeechRecognition and onDeviceSpeechRecognitionAvailable

This CL adds web platform tests for the installOnDeviceSpeechRecognition and onDeviceSpeechRecognitionAvailable methods of the Web Speech API.

Change-Id: If3c9d54bca005dbbd8aa625df5821884761a446e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6150488
Commit-Queue: Evan Liu <evliu@google.com>
Reviewed-by: Frank Liberato <liberato@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1403950}

--

wpt-commits: 4df4ce208afd3305fc63bb24b418f71003de4425
wpt-pr: 49972
2025-01-13 08:53:03 +00:00

39 lines
1.4 KiB
HTML

<!DOCTYPE html>
<title>SpeechRecognition onDeviceWebSpeechAvailable</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
promise_test(async (t) => {
const lang = "en-US";
window.SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
const speechRecognition = new SpeechRecognition();
// Ensure the onDeviceWebSpeechAvailable method exists.
assert_true(
"onDeviceWebSpeechAvailable" in speechRecognition,
"SpeechRecognition should have the onDeviceWebSpeechAvailable method."
);
// Test that it returns a promise.
const resultPromise = speechRecognition.onDeviceWebSpeechAvailable(lang);
assert_true(
resultPromise instanceof Promise,
"onDeviceWebSpeechAvailable should return a Promise."
);
// Verify the resolved value is a boolean.
const result = await resultPromise;
assert_true(
typeof result === "boolean",
"The resolved value of the onDeviceWebSpeechAvailable promise should be a boolean."
);
// Verify that method returns false if on-device speech recognition is not installed.
assert_equals(
result,
false,
"onDeviceWebSpeechAvailable should resolve with `false` if on-device speech recognition is not installed."
);
}, "SpeechRecognition.onDeviceWebSpeechAvailable resolves with a boolean value.");
</script>