Add helper class for waiting browser to be set as last active one.
Currently, when Lacros ui code opens a browser window or switch a different browser window, the BrowserList::SetLastActive() is called to set the browser window to the last active one. However, this function is called twice every time such UI update happens. It is first called synchronously from Lacros when Lacros requests the UI update; and later it is called again asynchronously when Wayland notifies Lacros about UI change. If the UI code is switching between different browsers quickly, there could be a race due to the async update of BrowserList::SetLastActive(), which can lead to some potential issue to mess up the last active browser state in Lacros side. This happens in some test cases, since the tests ported from ash assume only the sychronous update of BrowserList::SetLastActive(). Now these tests are flaky in Lacros. Please see more detail in b/325634285 and an example for the related test flaky/failure issue in b/40948433. This cl adds a helper class, so that test code can be prepared to handle the asynchronous update for the last active browser. Eventually, we will change the production code to make Lacros update the last active browser completely asynchrously, but that will break a lot of existing tests. Therefore, we will implement it incrementally by preparing the tests to handle async BrowserList::SetLastActive() from wayland UI update first. Although the waiting in test can not completely fix test flakiness until we making the production code change mentioned above, this reduce the flakiness to a large extent. HostedOrWebAppTest.CtrlClickLink can be enabled now(failed most times without this cl), the tests are still a little flaky (HostedApp variant failed 2 of 24), but passed Flake Endorser. Bug: b:40948433, b:325634285 Change-Id: Id50097eb6b99e4ec3d5f12dfdb92a7b56ee83e76 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5303255 Commit-Queue: Jenny Zhang <jennyz@chromium.org> Reviewed-by:Erik Chen <erikchen@chromium.org> Cr-Commit-Position: refs/heads/main@{#1261967}
Loading
Please register or sign in to comment