wpt icon indicating copy to clipboard operation
wpt copied to clipboard

Use promise_test in idlharness

Open MattiasBuelens opened this issue 5 years ago • 8 comments

In #24363, we ran into a bug where a rejected promise was not correctly caught by the IDL harness. We fixed it by adding a .step_func() call, but it still feels weird having to manually add these.

This PR refactors all usages of async_test to promise_test in the IDL harness, leveraging async/await to easily chain promises within the tests. We no longer need any manual calls to a_test.step() or a_test.done(), since promise_test handles all of that for us. 😁

MattiasBuelens avatar Jul 02 '20 22:07 MattiasBuelens

Right, so apparently this violates the policy set out in #6266, in that we should avoid using modern JavaScript features in the harness. This resulted in a failure on the harness tests.

It's 2020: async/await has been in the language since ES2017 and is supported by all browsers... Do we still need the harness to work without async/await support, or even without Promise support (#11150)? 😕

MattiasBuelens avatar Jul 03 '20 09:07 MattiasBuelens

Hi Mattias, sorry for the delay in this being reviewed >_<.

I fully agree that using async/await in 2020 is totally reasonable, and have argued as such in https://github.com/web-platform-tests/wpt/pull/6333 just recently. So I'm hopeful that won't turn out to be an issue.

@jgraham - WDYT on using async/await in idlharness.js?

I have some concerns about the potential performance implications of moving from concurrent async_tests to sequential promise_tests, but that doesn't seem borne out by the wpt.fyi results. (They seem pretty much equivalent for the bigger IDL cases, e.g. html/).

stephenmcgruer avatar Oct 20 '20 16:10 stephenmcgruer

Looks like I forgot about this PR. Sorry! 😅

Seeing that the policy around testharness.js has been updated in #26204 and async/await is now officially allowed, I think this PR is still worth considering. I've rebased it, should be ready for review. 🙂

MattiasBuelens avatar Jan 31 '22 22:01 MattiasBuelens

Hmm, it seems the idlharness.js tests are failing because we run many of them both with and without a global Promise.

So... idlharness.js is not allowed to use promise_test, and we can't use async/await after all? 😞

Or has this comment become outdated, and should we as of now require a global Promise? After all, it references #6266, which is now superseded by #26204, right?

MattiasBuelens avatar Jan 31 '22 23:01 MattiasBuelens

@MattiasBuelens in https://github.com/web-platform-tests/rfcs/blob/master/rfcs/promise.md we decided to no longer support browsers/runtimes that don't have Promise. However, it seems like the tests were never cleaned up...

If you'd like to delete those tests, feel free!

foolip avatar Apr 05 '22 09:04 foolip

I've gone ahead and sent https://github.com/web-platform-tests/wpt/pull/33507 to clean that up.

foolip avatar Apr 05 '22 09:04 foolip

Thanks! I didn't know we had RFCs for web-platform-tests, TIL. 😁

I'll rebase this PR after yours lands. 👍

MattiasBuelens avatar Apr 05 '22 10:04 MattiasBuelens

I'm amazed this apparently doesn't have any merge conflicts, but also not totally surprised.

This feels potentially still worthwhile to land, though maybe we should check this doesn't change any results now.

All that leaves is finding someone happy to review idlharness changes (though this is maybe simpler than most!).

gsnedders avatar Jun 07 '25 01:06 gsnedders