test_focus_design_mode.html (1698B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=1690747 5 --> 6 <head> 7 <title>Test for Bug 1690747</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <script src="/tests/SimpleTest/EventUtils.js"></script> 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 11 </head> 12 <body> 13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1690747">Mozilla Bug 1690747</a> 14 <p id="display"></p> 15 <div id='content'> 16 </div> 17 <pre id="test"> 18 <iframe src="https://example.org/tests/dom/base/test/file_focus_design_mode_inner.html"></iframe> 19 <script type="application/javascript"> 20 21 /** Test for Bug 1690747 */ 22 23 let iframe = document.querySelector("iframe"); 24 25 function waitForEvent(target, event, checkFn) { 26 return new Promise(resolve => { 27 target.addEventListener(event, e => { 28 if (checkFn && !checkFn(e)) { 29 return; 30 } 31 resolve(); 32 }, { once: true }); 33 }); 34 } 35 36 async function getLog() { 37 let log = ""; 38 SimpleTest.executeSoon(function() { 39 iframe.contentWindow.postMessage("getlog", "*"); 40 }); 41 await waitForEvent(window, "message", (e) => { 42 log = e.data; 43 return true; 44 }); 45 return log; 46 } 47 48 add_setup(async function() { 49 await SpecialPowers.pushPrefEnv({ set: [["dom.disable_window_flip", true]] }); 50 }); 51 52 add_task(async function activeElementAfterBluring() { 53 iframe.contentWindow.postMessage("focus", "*"); 54 is(await getLog(), "innerlog:windowfocus,activeElement:HTML,", "check activeElement"); 55 iframe.contentWindow.blur(); 56 is(await getLog(), "innerlog:windowfocus,activeElement:HTML,activeElement:HTML,", "check activeElement after bluring"); 57 }); 58 59 </script> 60 </pre> 61 </body> 62 </html>