On Sat, 21 Mar 2026 23:19:44 GMT, Marius Hanl <[email protected]> wrote:
> Very similar to https://github.com/openjdk/jfx/pull/1829, this PR removes the > questionable behavior that the `MouseEventFirer` may create a temporary > `Stage` for your `Node`. > > Take the following test code: > > Button button = new Button("Button"); > MouseEventFirer mouse = new MouseEventFirer(button); > mouse.fireMousePressAndRelease(); > mouse.fireMousePressAndRelease(); > mouse.dispose() > > What it does is to create a `Stage` in the first method. The second method > does not. This is not immediately clear. > That is also the reason why the dispose method exists. To MAY clean it up. Or > forget to call it. > > This does not test a realistic scenario and the chance is quite high that > developers used that methods without even knowing that it contains such logic. > > So the idea is to remove the StageLoader code from MouseEventFirer and rather > use it in the Test code before calling the Util methods. > > For the example above, this would result in: > > Button button = new Button("Button"); > stageLoader = new StageLoader(button ); > MouseEventFirer mouse = new MouseEventFirer(button); > mouse.fireMousePressAndRelease(); > mouse.fireMousePressAndRelease(); > > > There were only two real tests that did not have a `Stage` yet. So most of > the tests already had a good setup and the questionable code did not run > mostly. > > --------- > - [x] I confirm that I make this contribution in accordance with the [OpenJDK > Interim AI Policy](https://openjdk.org/legal/ai). This pull request has now been integrated. Changeset: db4fcf0e Author: Marius Hanl <[email protected]> URL: https://git.openjdk.org/jfx/commit/db4fcf0e70310ebb7cb9a0fd5fd877c98365c39c Stats: 122 lines in 13 files changed: 36 ins; 64 del; 22 mod 8380574: [TestBug] MouseEventFirer should not create a temporary Stage 8293356: Testbug: broken usage of MouseEventFirer/VirtualFlowTestUtils Reviewed-by: angorya, lkostyra ------------- PR: https://git.openjdk.org/jfx/pull/2124
