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
49 lines
1.8 KiB
HTML
49 lines
1.8 KiB
HTML
<!DOCTYPE html>
|
|
<title>SpeechRecognition installOnDeviceSpeechRecognition</title>
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<script>
|
|
promise_test(async (t) => {
|
|
const validLang = "en-US";
|
|
const invalidLang = "invalid language code";
|
|
window.SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
|
|
const speechRecognition = new SpeechRecognition();
|
|
|
|
// Ensure the installOnDeviceSpeechRecognition method exists.
|
|
assert_true(
|
|
"installOnDeviceSpeechRecognition" in speechRecognition,
|
|
"SpeechRecognition should have the installOnDeviceSpeechRecognition method."
|
|
);
|
|
|
|
// Test that it returns a promise.
|
|
const validResultPromise = speechRecognition.installOnDeviceSpeechRecognition(validLang);
|
|
assert_true(
|
|
validResultPromise instanceof Promise,
|
|
"installOnDeviceSpeechRecognition should return a Promise."
|
|
);
|
|
|
|
// Verify the resolved value is a boolean.
|
|
const validResult = await validResultPromise;
|
|
assert_true(
|
|
typeof validResult === "boolean",
|
|
"The resolved value of the installOnDeviceSpeechRecognition promise should be a boolean."
|
|
);
|
|
|
|
// Verify that the method returns true when called with a supported language code.
|
|
assert_equals(
|
|
validResult,
|
|
true,
|
|
"installOnDeviceSpeechRecognition should resolve with `true` when called with a supported language code."
|
|
);
|
|
|
|
// Test that it returns a promise.
|
|
const invalidResultPromise = speechRecognition.installOnDeviceSpeechRecognition(invalidLang);
|
|
const invalidResult = await invalidResultPromise;
|
|
assert_equals(
|
|
invalidResult,
|
|
false,
|
|
"installOnDeviceSpeechRecognition should resolve with `false` when called with an unsupported language code."
|
|
);
|
|
}, "SpeechRecognition.installOnDeviceSpeechRecognition resolves with a boolean value.");
|
|
</script>
|