tor-browser

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

SpeechSynthesisEvent-constructor.html (2232B)


      1 <!DOCTYPE html>
      2 <meta charset="utf-8">
      3 <script src="/resources/testharness.js"></script>
      4 <script src="/resources/testharnessreport.js"></script>
      5 <script>
      6 /*
      7 [Exposed=Window,
      8 Constructor(DOMString type, SpeechSynthesisEventInit eventInitDict)]
      9 interface SpeechSynthesisEvent : Event {
     10    readonly attribute SpeechSynthesisUtterance utterance;
     11    readonly attribute unsigned long charIndex;
     12    readonly attribute float elapsedTime;
     13    readonly attribute DOMString name;
     14 };
     15 */
     16 test(() => {
     17  assert_throws_js(TypeError, () => {
     18    new SpeechSynthesisEvent();
     19  });
     20 }, "SpeechSynthesisEvent with no arguments throws TypeError");
     21 
     22 test(() => {
     23  assert_throws_js(TypeError, () => {
     24    new SpeechSynthesisEvent("type");
     25  });
     26 }, "SpeechSynthesisEvent with no eventInitDict throws TypeError");
     27 
     28 test(() => {
     29  assert_throws_js(TypeError, () => {
     30    new SpeechSynthesisEvent("type", {});
     31  });
     32 }, `SpeechSynthesisEvent with empty eventInitDict throws TypeError (requires
     33    utterance)`);
     34 
     35 test(() => {
     36  assert_throws_js(TypeError, () => {
     37    new SpeechSynthesisEvent("type", {charIndex: 10, elapsedTime: 50, name:"foo"});
     38  });
     39 }, `SpeechSynthesisEvent with eventInitDict not having utterance throws
     40    TypeError`);
     41 
     42 test(() => {
     43  const utterance = new SpeechSynthesisUtterance("foo");
     44  const event = new SpeechSynthesisEvent("type", {utterance: utterance});
     45  assert_equals(event.utterance, utterance);
     46  assert_equals(event.charIndex, 0);
     47  assert_equals(event.charLength, 0);
     48  assert_equals(event.elapsedTime, 0);
     49  assert_equals(event.name, "");
     50 }, "SpeechSynthesisEvent with eventInitDict having an utterance");
     51 
     52 test(() => {
     53  const utterance = new SpeechSynthesisUtterance("foo");
     54  const event = new SpeechSynthesisEvent("type", {
     55    utterance: utterance,
     56    charIndex: 5,
     57    charLength: 3,
     58    elapsedTime: 100,
     59    name: "foo"
     60  });
     61  assert_equals(event.bubbles, false);
     62  assert_equals(event.cancelable, false);
     63  assert_equals(event.type, "type");
     64  assert_equals(event.utterance, utterance);
     65  assert_equals(event.charIndex, 5);
     66  assert_equals(event.charLength, 3);
     67  assert_equals(event.elapsedTime, 100);
     68  assert_equals(event.name, "foo");
     69 }, "SpeechSynthesisEvent with custom eventInitDict");
     70 </script>