content/media/webspeech/recognition/test/test_nested_eventloop.html

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=650295
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <meta charset="utf-8">
michael@0 8 <title>Test for Bug 650295 -- Spin the event loop from inside a callback</title>
michael@0 9 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
michael@0 11 <script type="application/javascript" src="head.js"></script>
michael@0 12 </head>
michael@0 13 <body>
michael@0 14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=650295">Mozilla Bug 650295</a>
michael@0 15 <p id="display"></p>
michael@0 16 <div id="content" style="display: none">
michael@0 17
michael@0 18 </div>
michael@0 19 <pre id="test">
michael@0 20 <script type="text/javascript">
michael@0 21 SimpleTest.waitForExplicitFinish();
michael@0 22
michael@0 23 /*
michael@0 24 * window.showModalDialog() can be used to spin the event loop, causing
michael@0 25 * queued SpeechEvents (such as those created by calls to start(), stop()
michael@0 26 * or abort()) to be processed immediately.
michael@0 27 * When this is done from inside DOM event handlers, it is possible to
michael@0 28 * cause reentrancy in our C++ code, which we should be able to withstand.
michael@0 29 */
michael@0 30
michael@0 31 function abortAndSpinEventLoop(evt, sr) {
michael@0 32 sr.abort();
michael@0 33 window.showModalDialog("javascript:window.close()");
michael@0 34 }
michael@0 35
michael@0 36 function doneFunc() {
michael@0 37 // Trigger gc now and wait some time to make sure this test gets the blame
michael@0 38 // for any assertions caused by showModalDialog
michael@0 39 //
michael@0 40 // NB - The assertions should be gone, but this looks too scary to touch
michael@0 41 // during batch cleanup.
michael@0 42 var count = 0, GC_COUNT = 4;
michael@0 43
michael@0 44 function triggerGCOrFinish() {
michael@0 45 SpecialPowers.gc();
michael@0 46 count++;
michael@0 47
michael@0 48 if (count == GC_COUNT) {
michael@0 49 SimpleTest.finish();
michael@0 50 }
michael@0 51 }
michael@0 52
michael@0 53 for (var i = 0; i < GC_COUNT; i++) {
michael@0 54 setTimeout(triggerGCOrFinish, 0);
michael@0 55 }
michael@0 56 }
michael@0 57
michael@0 58 /*
michael@0 59 * We start by performing a normal start, then abort from the audiostart
michael@0 60 * callback and force the EVENT_ABORT to be processed while still inside
michael@0 61 * the event handler. This causes the recording to stop, which raises
michael@0 62 * the audioend and (later on) end events.
michael@0 63 * Then, we abort (once again spinning the event loop) from the audioend
michael@0 64 * handler, attempting to cause a re-entry into the abort code. This second
michael@0 65 * call should be ignored, and we get the end callback and finish.
michael@0 66 */
michael@0 67
michael@0 68 performTest({
michael@0 69 eventsToRequest: [
michael@0 70 "EVENT_START",
michael@0 71 "EVENT_AUDIO_DATA",
michael@0 72 ],
michael@0 73 expectedEvents: {
michael@0 74 "audiostart": abortAndSpinEventLoop,
michael@0 75 "audioend": abortAndSpinEventLoop,
michael@0 76 "end": null
michael@0 77 },
michael@0 78 doneFunc: doneFunc,
michael@0 79 prefs: [["media.webspeech.test.fake_fsm_events", true],
michael@0 80 ["media.webspeech.test.fake_recognition_service", true]]
michael@0 81 });
michael@0 82
michael@0 83 </script>
michael@0 84 </pre>
michael@0 85 </body>
michael@0 86 </html>

mercurial