Bug 1601532 - Make `test_bug1332876.html` synthesizes on `<span>` element in the `<iframe>` rather than on the `<iframe>` r=smaug

The timeout is caused by that `iframe.contentWindow` may not receive `click`
event (as far as I've tested, neither `mousedown` nor `mouseup` is fired in
that case) when synthesizing a mouse click over the `<iframe>` element with
parent window.  However, if it synthesizes mouse click with `<span>` element
in the `<iframe>` and `iframe.contentWindow`, `click` event is always fired.

Differential Revision: https://phabricator.services.mozilla.com/D62992

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Masayuki Nakano 2020-02-16 14:54:11 +00:00
Родитель a98323bb51
Коммит fe30c6ad87
1 изменённых файлов: 14 добавлений и 6 удалений

Просмотреть файл

@ -1,7 +1,7 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=795418
https://bugzilla.mozilla.org/show_bug.cgi?id=1332876
-->
<head>
<meta charset="utf-8">
@ -25,21 +25,29 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=795418
/** Test for Bug 1332876 **/
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(function() {
var iframe = document.querySelector("iframe");
let iframe = document.querySelector("iframe");
iframe.contentDocument.designMode = "on";
iframe.contentWindow.addEventListener("keypress", function() {
info("Hiding the iframe...");
iframe.style.display = "none";
document.body.offsetHeight;
ok(true, "did not crash");
SimpleTest.finish();
});
}, {once: true});
iframe.contentWindow.addEventListener("click", function() {
synthesizeKey("a", {}, iframe.contentWindow);
});
info("Waiting keypress event...");
// Use another macro task for avoiding impossible event nesting.
SimpleTest.executeSoon(() => {
synthesizeKey("a", {}, iframe.contentWindow);
});
}, {once: true});
synthesizeMouse(iframe, 20, 20, {});
let span = iframe.contentDocument.querySelector("span");
ok(span != null, "The span element should've been loaded in the iframe");
info("Waiting click event to focus the iframe...");
synthesizeMouseAtCenter(span, {}, iframe.contentWindow);
});
</script>