Google chrome 这个论点——Chrome CLI的虚拟时间预算到底意味着什么?

Google chrome 这个论点——Chrome CLI的虚拟时间预算到底意味着什么?,google-chrome,chromium,google-chrome-headless,Google Chrome,Chromium,Google Chrome Headless,我知道Chromium的参数--虚拟时间预算的文档,但我觉得我不理解: // If set the system waits the specified number of virtual milliseconds before // deeming the page to be ready. For determinism virtual time does not advance // while there are pending network fetches (i.e no time

我知道Chromium的参数
--虚拟时间预算
的文档,但我觉得我不理解:

// If set the system waits the specified number of virtual milliseconds before
// deeming the page to be ready.  For determinism virtual time does not advance
// while there are pending network fetches (i.e no timers will fire). Once all
// network fetches have completed, timers fire and if the system runs out of
// virtual time is fastforwarded so the next timer fires immediately, until the
// specified virtual time budget is exhausted.
const char kVirtualTimeBudget[] = "virtual-time-budget";
我做了一些实验,结果让我感到困惑:

# I'm on macOS; you may change this alias according to your own OS
$ alias chrome="/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"
$ chrome --version
Google Chrome 70.0.3538.110

$ time chrome --headless --disable-gpu --print-to-pdf https://www.chromestatus.com/
real    0m0.912s
user    0m0.264s
sys     0m0.219s

$ time chrome --headless --disable-gpu --print-to-pdf --virtual-time-budget=10000 https://www.chromestatus.com/
real    0m2.502s
user    0m0.347s
sys     0m0.244s

$ time chrome --headless --disable-gpu --print-to-pdf --virtual-time-budget=100000 https://www.chromestatus.com/
real    0m15.432s
user    0m0.759s
sys     0m0.406s

$ time chrome --headless --disable-gpu --print-to-pdf --virtual-time-budget=1000000 https://www.chromestatus.com/
real    0m15.755s
user    0m0.755s
sys     0m0.401s

我原以为Chrome会在上述四个示例中等待0、10、100和1000秒,然后再打印成PDF,但实际的等待时间似乎还很遥远。我的问题是,如何让Chrome在将页面打印为PDF之前等待X秒?目前我只考虑Chrome CLI,而不是寻找像Puppeter这样的工具。

我可以很容易地回答你的标题问题(这解释了你的结果)--虚拟时间预算,说明进程等待页面加载的时间,而不是等待的时间。如果请求的结果可用(不再有未决的网络请求),它将立即返回结果


返回的信息应该是正确的,除非混合中有AJAX请求或其他Javascript。如果是这样,您必须求助于Javascript/DOM操作来解决问题

我对这个很感兴趣。我需要打印一些缓慢加载的GIS信息。尝试在可混淆的慢速加载图像中设置。无论虚拟时间设置为什么,我似乎都不能强迫它等待超过2000毫秒