Open Bug 1509364 Opened 6 years ago Updated 2 years ago

Internal reftest runner window focus is racy

Categories

(Testing :: web-platform-tests, enhancement)

enhancement

Tracking

(Not tracked)

People

(Reporter: gsnedders, Unassigned)

Details

Currently we run:

this.driver.curBrowser.contentBrowser.focus();
await this.driver.listener.reftestWait(url, this.remote);

If we run this all fast enough, we can actually end up taking the screenshot before we get focus. (I think I can observe this with some of the tests I've written in marionette_harness for the reftest runner when running under Xvfb…)

This is somewhat awkward to fix, because we can't unconditionally wait for the focus event (and probably the activate chrome event), given that doesn't fire if the window already has focus (which if we've reused the window is likely).

bug 1507803 is similar, insofar as it deals with racy windows and focus with marionette
Only when you open a new window you have to wait for `activate` and `focus` events. See my patch for the already mentioned bug which demonstrates how to do it.
(In reply to Henrik Skupin (:whimboo) from comment #1)
> Only when you open a new window you have to wait for `activate` and `focus`
> events. See my patch for the already mentioned bug which demonstrates how to
> do it.

The risk in the reftest case is the reftest opens a new window itself (okay, this would be pretty malicious and definitely into pretty undefined behaviour for WPT), and then the wrong window has focus. We probably don't need to deal with that case…?
Can't you just use `await Promise.all()` for the `load`, the `focus` and `activate` events here?

https://searchfox.org/mozilla-central/source/testing/marionette/reftest.js#105-107
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.