Delay edits to work around lack of millisecond precision in `stat` and migrate `pageSource` tests to use console logs (#2670)
Currently, CI is red due to two issues on Windows:
- hot_reload_breakpoints_test: On Windows, dart:io doesn't have enough precision to provide a millisecond-based stat. Instead, it just rounds to the nearest second. We use this to determine what files were modified in a recompile whereas we use DateTime.now (which does have millisecond precision) to mark the timestamp of the previous compile. This then potentially leads to frontend_server_common mistakenly not recompiling some files.
To fix this, we stage all the edits at once (if possible) and delay for 1 second to guarantee that stat will always give a time after the previous compile if the file was modified.
- hot_reload_test: This and a number of tests use innerHTML, document.body.append, and the pageSource API to modify the page text and then read it. A previous race condition where we tried to compute the page before main was done executing was resolved by waiting for a log at the end of main. However, this is insufficient, because the changes to the page still may not bubble up by the time we try to calculate the page source, which was the issue with hot_reload_test.
We could do a busy-loop calculating the page until we get the text we want, but that's erroneous and a better solution is to just use console logs, which fixes the original issue. As part of this, a WebkitDebugger is always initialized in the test context so we can inspect console logs regardless of whether DWDS debugging is enabled.
14 files changed