Bug 1208197: Use addEventListener() in test_bug533845.xul to prevent raciness. r=smaug

This commit is contained in:
Jet Villegas 2017-06-02 14:11:32 +09:00
Родитель 322546b85a
Коммит 5358af1fa7
1 изменённых файлов: 12 добавлений и 3 удалений

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

@ -10,7 +10,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=533845
onload="doTest()">
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<panel id="panel" width="50" height="50" onpopupshown="continueTest()">
<panel id="panel" width="50" height="50">
<iframe type="content" id="contentFrame" src="data:text/html,&lt;html&gt;&lt;body onclick='document.body.textContent=1'&gt;This is a panel!&lt;/body&gt;&lt;/html&gt;" width="500" height="500"/>
</panel>
<body xmlns="http://www.w3.org/1999/xhtml">
@ -23,7 +23,17 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=533845
SimpleTest.waitForExplicitFinish();
function doTest() {
document.getElementById('panel').showPopup();
let panel = document.getElementById("panel");
panel.addEventListener("popupshown", function onpopupshown() {
panel.removeEventListener("popupshown", onpopupshown);
continueTest();
panel.addEventListener("popuphidden", function onpopuphidden() {
panel.removeEventListener("popuphidden", onpopuphidden);
SimpleTest.finish();
});
panel.hidePopup();
});
panel.openPopup();
}
function continueTest() {
@ -37,7 +47,6 @@ function continueTest() {
utils.sendMouseEvent("mousedown", x, y, 0, 1, 0);
utils.sendMouseEvent("mouseup", x, y, 0, 1, 0);
is(ifrwindow.document.body.textContent, "1", "Should have got a click event!");
SimpleTest.finish();
}
]]></script>