RenderDocument: Fix Mac size-related tests.

TL;DR: Modify macOS window sizing workaround to set the size for the
RFH/RWHV being navigated, rather than just the existing RFH/RWHV, but
only for non-popups.

With RenderDocument enabled, a bunch of size-related tests are failing
only on the Mac bots. This is happening because of some quirks with how
macOS headless tests handle setting the window size. Since there is no
window created, macOS will not send window size updates, so a workaround
was put in place to simulate those window size updates so that a
primary main frame is set up with the correct window size.

However, the code assumes that the RenderFrameHost being navigated is
the same as the RenderFrameHost that's the existing primary main frame,
and will only send size updates to the currently established primary
main frame. Up until now, that assumption was correct enough for these
tests (cross-site navigations would involve a RFH swap, but these tests
are usually only performing same-origin navigations). With
RenderDocument enabled, all cross-document navigations now involve a RFH
swap. So the workaround will see a new main frame is being created,
update the old RFH's associated RenderWidgetHostView with the window
size, and leave the new RFH's associated RenderWidgetHostView with an
invalid size.

When the RFH swap occurs, the new document will not have received any
window size update, and will therefore have an incorrect window size in
place, causing issues with anything that is either directly testing
size-related parameters (like window.outerWidth) or testing features
that use window size (like scrolling).

To fix this, the newly created RenderWidgetHostView for the newly
created RenderFrameHost gets SetWindowFrameInScreen() invoked, ensuring
that it has the correct value by the time the navigation commits.

In a perfect world, this would be enough of a fix. But this introduces
an extra corner case with popup windows. Because the window size is
updated later than it would normally be updated, there's a race where,
if a popup is created and then resized while navigating, this
intervention will clobber the resized value of the popup window.

(See: mismatched-snapshot-containing-block-size-skips.html)

The intention of this is to ensure that the first top-level frame
created by the test always has the correct size after a navigation. In
the interest of time, and rather than trying to chase down a race
condition for a corner case that only exists due to a workaround when
tests are being run on macOS in headless mode, the intervention in this
CL will only happen if the render frame being created isn't for a popup.

This fixes the following tests with RenderDocument enabled on macOS:
- external/wpt/css/css-overflow/scrollbar-gutter-propagation-007.html
- external/wpt/html/semantics/forms/the-input-element/change-to-empty-value.html
- fast/dom/icon-url-list-viewport.html
- fast/dom/viewport/resize-event-fired-window-resized.html
- fast/dom/Window/window-resize-contents.html
- fast/dynamic/window-resize-scrollbars-test.html
- inspector-protocol/emulation/device-emulation-desktop.js
- svg/custom/mixed-percent-size-zoom.svg
- svg/custom/percent-size-zoom.svg
- virtual/stable/fast/dom/Window/window-resize-contents.html
- virtual/text-antialias/line-break-between-text-nodes-with-inline-blocks.html

Change-Id: I4c19be42d611392273724af419ef113af23696d5
Bug: 40615943
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6779004
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: Liam Brady <lbrady@google.com>
Cr-Commit-Position: refs/heads/main@{#1492351}
12 files changed
tree: ff13f2db1d4fb224c726c5b1f01939a6bd07965b
  1. .github/
  2. agents/
  3. android_webview/
  4. apps/
  5. ash/
  6. base/
  7. build/
  8. build_overrides/
  9. buildtools/
  10. cc/
  11. chrome/
  12. chromecast/
  13. chromeos/
  14. codelabs/
  15. components/
  16. content/
  17. crypto/
  18. dbus/
  19. device/
  20. docs/
  21. extensions/
  22. fuchsia_web/
  23. gin/
  24. google_apis/
  25. gpu/
  26. headless/
  27. infra/
  28. ios/
  29. ipc/
  30. media/
  31. mojo/
  32. net/
  33. pdf/
  34. printing/
  35. remoting/
  36. rlz/
  37. sandbox/
  38. services/
  39. skia/
  40. sql/
  41. storage/
  42. styleguide/
  43. testing/
  44. third_party/
  45. tools/
  46. ui/
  47. url/
  48. webkit/
  49. .clang-format
  50. .clang-tidy
  51. .clangd
  52. .cursorignore
  53. .geminiignore
  54. .git-blame-ignore-revs
  55. .gitallowed
  56. .gitattributes
  57. .gitignore
  58. .gitmodules
  59. .gn
  60. .mailmap
  61. .rustfmt.toml
  62. .vpython3
  63. .yapfignore
  64. ATL_OWNERS
  65. AUTHORS
  66. BUILD.gn
  67. CODE_OF_CONDUCT.md
  68. codereview.settings
  69. CPPLINT.cfg
  70. CRYPTO_OWNERS
  71. DEPS
  72. DIR_METADATA
  73. LICENSE
  74. LICENSE.chromium_os
  75. OWNERS
  76. PRESUBMIT.py
  77. PRESUBMIT_test.py
  78. PRESUBMIT_test_mocks.py
  79. README.md
  80. SECURITY_OWNERS
  81. WATCHLISTS
README.md

Logo Chromium

Chromium is an open-source browser project that aims to build a safer, faster, and more stable way for all users to experience the web.

The project's web site is https://www.chromium.org.

To check out the source code locally, don't use git clone! Instead, follow the instructions on how to get the code.

Documentation in the source is rooted in docs/README.md.

Learn how to Get Around the Chromium Source Code Directory Structure.

For historical reasons, there are some small top level directories. Now the guidance is that new top level directories are for product (e.g. Chrome, Android WebView, Ash). Even if these products have multiple executables, the code should be in subdirectories of the product.

If you found a bug, please file it at https://crbug.com/new.