forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This CL adds some basic web platform tests to ensure that the onstart, onend, and onerror events are fired for the Web Speech API. Change-Id: Ieeaab551b95b56503917e468f9ec33d857790dad Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6137598 Commit-Queue: Evan Liu <[email protected]> Reviewed-by: Yiren Wang <[email protected]> Cr-Commit-Position: refs/heads/main@{#1402727}
- Loading branch information
1 parent
f13ebbb
commit 9ff4054
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
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,27 @@ | ||
<!DOCTYPE html> | ||
<title>SpeechRecognition onerror event</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
promise_test(async t => { | ||
window.SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition; | ||
const recognition = new SpeechRecognition(); | ||
|
||
// Promise that resolves when the 'error' event is fired. | ||
const errorPromise = new Promise(resolve => { | ||
recognition.onerror = (event) => { | ||
assert_equals("audio-capture", event.error); | ||
resolve(); | ||
}; | ||
}); | ||
|
||
// Start speech recognition. | ||
recognition.start(); | ||
|
||
// Wait for the 'error' event. | ||
await errorPromise; | ||
|
||
// Stop speech recognition. | ||
recognition.stop(); | ||
}, 'Speech recognition onerror event is called.'); | ||
</script> |
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,36 @@ | ||
<!DOCTYPE html> | ||
<title>SpeechRecognition onstart and onend events</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script> | ||
promise_test(async t => { | ||
window.SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition; | ||
const recognition = new SpeechRecognition(); | ||
|
||
// Promise that resolves when the 'start' event is fired. | ||
const startPromise = new Promise(resolve => { | ||
recognition.onstart = () => { | ||
resolve(); | ||
}; | ||
}); | ||
|
||
// Promise that resolves when the 'end' event is fired. | ||
const endPromise = new Promise(resolve => { | ||
recognition.onend = () => { | ||
resolve(); | ||
}; | ||
}); | ||
|
||
// Start speech recognition. | ||
recognition.start(); | ||
|
||
// Wait for the 'start' event. | ||
await startPromise; | ||
|
||
// Stop speech recognition. | ||
recognition.stop(); | ||
|
||
// Wait for the 'end' event. | ||
await endPromise; | ||
}, 'Speech recognition onstart and onend events are called.'); | ||
</script> |