file_global_queue_cancel.html (3237B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=1188099 5 --> 6 <head> 7 <meta charset="utf-8"> 8 <title>Test for Bug 1188099: Calling cancel() should work correctly with global queue</title> 9 <script type="application/javascript"> 10 window.SimpleTest = parent.SimpleTest; 11 window.info = parent.info; 12 window.is = parent.is; 13 window.isnot = parent.isnot; 14 window.ok = parent.ok; 15 window.todo = parent.todo; 16 </script> 17 <script type="application/javascript" src="common.js"></script> 18 </head> 19 <body> 20 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1188099">Mozilla Bug 1188099</a> 21 <iframe id="frame1"></iframe> 22 <iframe id="frame2"></iframe> 23 <div id="content" style="display: none"> 24 25 </div> 26 <pre id="test"> 27 <script type="application/javascript"> 28 Promise.all([loadFrame('frame1'), loadFrame('frame2')]).then(function ([frame1, frame2]) { 29 var win1 = frame1.contentWindow; 30 var win2 = frame2.contentWindow; 31 32 var utterance1 = new win1.SpeechSynthesisUtterance( 33 "u1: Donec ac nunc feugiat, posuere"); 34 utterance1.lang = 'it-IT-noend'; 35 var utterance2 = new win1.SpeechSynthesisUtterance("u2: hello, losers too"); 36 utterance2.lang = 'it-IT-noend'; 37 var utterance3 = new win1.SpeechSynthesisUtterance("u3: hello, losers three"); 38 39 var utterance4 = new win2.SpeechSynthesisUtterance("u4: hello, losers same!"); 40 utterance4.lang = 'it-IT-noend'; 41 var utterance5 = new win2.SpeechSynthesisUtterance("u5: hello, losers too"); 42 utterance5.lang = 'it-IT-noend'; 43 44 var eventOrder = ['start1', 'end1', 'start2', 'end2']; 45 utterance1.addEventListener('start', function(e) { 46 is(eventOrder.shift(), 'start1', 'start1'); 47 testSynthState(win1, { speaking: true, pending: true }); 48 testSynthState(win2, { speaking: true, pending: true }); 49 win2.speechSynthesis.cancel(); 50 SpecialPowers.wrap(win1.speechSynthesis).forceEnd(); 51 52 }); 53 utterance1.addEventListener('end', function(e) { 54 is(eventOrder.shift(), 'end1', 'end1'); 55 testSynthState(win1, { pending: true }); 56 testSynthState(win2, { pending: false }); 57 }); 58 utterance2.addEventListener('start', function(e) { 59 is(eventOrder.shift(), 'start2', 'start2'); 60 testSynthState(win1, { speaking: true, pending: true }); 61 testSynthState(win2, { speaking: true, pending: false }); 62 win1.speechSynthesis.cancel(); 63 }); 64 utterance2.addEventListener('end', function(e) { 65 is(eventOrder.shift(), 'end2', 'end2'); 66 testSynthState(win1, { speaking: false, pending: false }); 67 testSynthState(win2, { speaking: false, pending: false }); 68 SimpleTest.finish(); 69 }); 70 71 function wrongUtterance(e) { 72 ok(false, 'This shall not be uttered: "' + e.target.text + '"'); 73 } 74 75 utterance3.addEventListener('start', wrongUtterance); 76 utterance4.addEventListener('start', wrongUtterance); 77 utterance5.addEventListener('start', wrongUtterance); 78 79 win1.speechSynthesis.speak(utterance1); 80 win1.speechSynthesis.speak(utterance2); 81 win1.speechSynthesis.speak(utterance3); 82 win2.speechSynthesis.speak(utterance4); 83 win2.speechSynthesis.speak(utterance5); 84 }); 85 </script> 86 </pre> 87 </body> 88 </html>