tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

SpeechRecognition-onstart-onend.https.html (982B)


      1 <!DOCTYPE html>
      2 <title>SpeechRecognition onstart and onend events</title>
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <script>
      6  promise_test(async t => {
      7  window.SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
      8  const recognition = new SpeechRecognition();
      9 
     10  // Promise that resolves when the 'start' event is fired.
     11  const startPromise = new Promise(resolve => {
     12    recognition.onstart = () => {
     13      resolve();
     14    };
     15  });
     16 
     17  // Promise that resolves when the 'end' event is fired.
     18  const endPromise = new Promise(resolve => {
     19    recognition.onend = () => {
     20      resolve();
     21    };
     22  });
     23 
     24  // Start speech recognition.
     25  recognition.start();
     26 
     27  // Wait for the 'start' event.
     28  await startPromise;
     29 
     30  // Stop speech recognition.
     31  recognition.stop();
     32 
     33  // Wait for the 'end' event.
     34  await endPromise;
     35 }, 'Speech recognition onstart and onend events are called.');
     36 </script>