tor-browser

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

test_abort.html (1852B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=650295
      5 -->
      6 <head>
      7  <meta charset="utf-8">
      8  <title>Test for Bug 650295 -- Call abort from inside handlers</title>
      9  <script src="/tests/SimpleTest/SimpleTest.js"></script>
     10  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     11  <script type="application/javascript" src="head.js"></script>
     12 </head>
     13 <body>
     14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=650295">Mozilla Bug 650295</a>
     15 <p id="display"></p>
     16 <div id="content" style="display: none">
     17 
     18 </div>
     19 <pre id="test">
     20 <script type="text/javascript">
     21  SimpleTest.waitForExplicitFinish();
     22 
     23  // Abort inside event handlers, should't get a
     24  // result after that
     25 
     26  var nextEventIdx = 0;
     27  var eventsToAbortOn = [
     28    "start",
     29    "audiostart",
     30    "speechstart",
     31    "speechend",
     32    "audioend"
     33  ];
     34 
     35  function doNextTest() {
     36    var nextEvent = eventsToAbortOn[nextEventIdx];
     37    var expectedEvents = {
     38      "start": null,
     39      "audiostart": null,
     40      "audioend": null,
     41      "end": null
     42    };
     43 
     44    if (nextEventIdx >= eventsToAbortOn.indexOf("speechstart")) {
     45        expectedEvents.speechstart = null;
     46    }
     47 
     48    if (nextEventIdx >= eventsToAbortOn.indexOf("speechend")) {
     49        expectedEvents.speechend = null;
     50    }
     51 
     52    info("Aborting on " + nextEvent);
     53    expectedEvents[nextEvent] = function(evt, sr) {
     54      sr.abort();
     55    };
     56 
     57    nextEventIdx++;
     58 
     59    performTest({
     60      eventsToRequest: [],
     61      expectedEvents,
     62      doneFunc: (nextEventIdx < eventsToAbortOn.length) ? doNextTest : SimpleTest.finish,
     63      prefs: [["media.webspeech.test.fake_fsm_events", true],
     64              ["media.webspeech.test.fake_recognition_service", true],
     65              ["media.webspeech.recognition.timeout", 100000]]
     66    });
     67  }
     68 
     69  doNextTest();
     70 </script>
     71 </pre>
     72 </body>
     73 </html>