browser_bug527935.js (2087B)
1 add_task(async function () { 2 await new Promise(resolve => waitForFocus(resolve, window)); 3 4 const kPageURL = 5 "http://example.org/browser/editor/libeditor/tests/bug527935.html"; 6 await BrowserTestUtils.withNewTab( 7 { 8 gBrowser, 9 url: kPageURL, 10 }, 11 async function (aBrowser) { 12 var popupShown = false; 13 function listener() { 14 popupShown = true; 15 } 16 SpecialPowers.addAutoCompletePopupEventListener( 17 window, 18 "popupshowing", 19 listener 20 ); 21 22 await SpecialPowers.spawn(aBrowser, [], async function () { 23 var window = content.window.wrappedJSObject; 24 var document = window.document; 25 var formTarget = document.getElementById("formTarget"); 26 var initValue = document.getElementById("initValue"); 27 28 window.loadPromise = new Promise(resolve => { 29 formTarget.onload = resolve; 30 }); 31 32 initValue.focus(); 33 initValue.value = "foo"; 34 }); 35 36 EventUtils.synthesizeKey("KEY_Enter"); 37 38 await SpecialPowers.spawn(aBrowser, [], async function () { 39 var window = content.window.wrappedJSObject; 40 var document = window.document; 41 42 await window.loadPromise; 43 44 var newInput = document.createElement("input"); 45 newInput.setAttribute("name", "test"); 46 document.body.appendChild(newInput); 47 48 var event = new window.KeyboardEvent("keypress", { 49 bubbles: true, 50 cancelable: true, 51 view: null, 52 keyCode: 0, 53 charCode: "f".charCodeAt(0), 54 }); 55 newInput.value = ""; 56 newInput.focus(); 57 newInput.dispatchEvent(event); 58 }); 59 60 await new Promise(resolve => hitEventLoop(resolve, 100)); 61 62 ok(!popupShown, "Popup must not be opened"); 63 SpecialPowers.removeAutoCompletePopupEventListener( 64 window, 65 "popupshowing", 66 listener 67 ); 68 } 69 ); 70 }); 71 72 function hitEventLoop(func, times) { 73 if (times > 0) { 74 setTimeout(hitEventLoop, 0, func, times - 1); 75 } else { 76 setTimeout(func, 0); 77 } 78 }