test_bug1332876.html (1666B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=1332876 5 --> 6 <head> 7 <meta charset="utf-8"> 8 <title>Test for Bug 1332876</title> 9 <script src="/tests/SimpleTest/SimpleTest.js"></script> 10 <script src="/tests/SimpleTest/EventUtils.js"></script> 11 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 12 </head> 13 <body> 14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1332876">Mozilla Bug 1332876</a> 15 <p id="display"></p> 16 <div id="content" style="display: none"> 17 </div> 18 19 <iframe srcdoc="<html><body><span>Edit me!</span>"></iframe> 20 21 <pre id="test"> 22 23 <script type="application/javascript"> 24 25 /** Test for Bug 1332876 */ 26 SimpleTest.waitForExplicitFinish(); 27 SimpleTest.waitForFocus(function() { 28 let iframe = document.querySelector("iframe"); 29 iframe.contentDocument.designMode = "on"; 30 31 iframe.contentWindow.addEventListener("keypress", function() { 32 info("Hiding the iframe..."); 33 iframe.style.display = "none"; 34 document.body.offsetHeight; 35 ok(true, "did not crash"); 36 SimpleTest.finish(); 37 }, {once: true}); 38 39 iframe.contentWindow.addEventListener("click", function() { 40 info("Waiting keypress event..."); 41 // Use another macro task for avoiding impossible event nesting. 42 SimpleTest.executeSoon(() => { 43 synthesizeKey("a", {}, iframe.contentWindow); 44 }); 45 }, {once: true}); 46 47 let span = iframe.contentDocument.querySelector("span"); 48 ok(span != null, "The span element should've been loaded in the iframe"); 49 info("Waiting click event to focus the iframe..."); 50 synthesizeMouseAtCenter(span, {}, iframe.contentWindow); 51 }); 52 53 </script> 54 55 </pre> 56 </body> 57 </html>