Simple test case:
data:text/html,<input list="datalist"><datalist id="datalist"><option>a</option><option>b</option></datalist>
Bug 1566299 also needs automated testing. We actually have tests for that one (accessible/tests/mochitest/events/test_focus_autocomplete.xul), but they were disabled, which is why that regressed in the first place. That test is super complicated and I think we should just write a new, promise-based test rather than trying to fix that one.
The question is: should we cover the label testing in the same test? Normally, we like to keep tree and event tests separate. In this case, you can't test an autofill without opening it, so I think it probably makes sense to just test the labels in the event test, rather than having two nearly identical tests just so we can categorise our tests nicely.