Bug 1635806 - [testing] Expose eventName in BrowserTestUtils.waitForContentEvent r=ahal

This should make it easier to write tests for race-conditions, as
the resolving value now indicates which event was received.

This required updating a test which for some reason asserted
undefined being the resolving value, as a way of "testing" if the
Promise resolved at all. Since await already throws Errors when it
is rejected, and the test throws a timeout if it doesn't resolve in
time, this assertion was removed. It did not add any value.

Differential Revision: https://phabricator.services.mozilla.com/D74124
This commit is contained in:
Etienne Bruines 2020-05-11 21:29:05 +00:00
Родитель bc2c84ac2b
Коммит 2dcc34270a
2 изменённых файлов: 2 добавлений и 3 удалений

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

@ -106,8 +106,7 @@ add_task(async function() {
"fullscreenchange"
);
EventUtils.synthesizeKey("KEY_Escape");
state = await fullscreenExitPromise;
ok(!state, "The content should have exited fullscreen");
await fullscreenExitPromise;
ok(!document.fullscreenElement, "The chrome should have exited fullscreen");
gBrowser.removeTab(tab);

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

@ -1193,7 +1193,7 @@ var BrowserTestUtils = {
eventName,
() => {
removeEventListener();
resolve();
resolve(eventName);
},
{ capture, wantUntrusted },
checkFn