Bug 1682035 - Fix test, ensure the event for waitForAttribute won't be missed. r=mkmelin

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

--HG--
extra : rebase_source : d220cfe690043dd04dd8657528fe05eb2e39c34f
This commit is contained in:
Kai Engert 2020-12-11 22:59:48 +01:00
Родитель 3b45bca85f
Коммит 0d0c6ee7bc
1 изменённых файлов: 17 добавлений и 7 удалений

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

@ -305,20 +305,30 @@ add_task(async function testUpdateMessageSignature() {
return true;
});
mc.click(mc.eid("viewSignatureKey"));
await dialogPromise;
// Wait for the icon to reload.
await BrowserTestUtils.waitForAttribute(
// To ensure we won't miss the attribute change event, set up a
// promise to wait for it, before running the actions that trigger it.
// Wait for any new attribute value, because a future bug might
// set an unexpected attribute.
let attributePromise = BrowserTestUtils.waitForAttribute(
"signed",
mc.window.document.getElementById("signedHdrIcon"),
"unverified"
null
);
// This will open the key details, the domWindowOpened handler
// will catch it and execute the changes.
mc.click(mc.eid("viewSignatureKey"));
// Wait until we are done with keyDetailsDlg.
await dialogPromise;
// Wait for the signedHdrIcon state to change.
await attributePromise;
// Verify the new acceptance level is correct.
Assert.ok(
OpenPGPTestUtils.hasSignedIconState(mc.window.document, "unverified"),
"signed unverified icon is displayed"
"signed unverified icon should be displayed"
);
close_window(mc);
});