Clear user activation on cross-site navigations.

When full site isolation is disabled, renderer processes and
RenderFrameHosts are re-used when performing cross-site navigations.
This includes user activation state, and, more specifically, the sticky
`has_been_active_` bit in `UserActivationState`.

Currently, the `UserActivationState` on the renderer-side is reset only
if the navigation's associated frame is a main frame. That means that if
an iframe navigates to a cross-site page, its sticky user activation
state will be the leftover state from the previous page. So, if a user
interacted with the previous page in any capacity, the newly loaded page
will think it has received a user gesture, essentially using an
unintentional cache of the user activation state.

This becomes an issue when dealing with our framebusting interventions.
We only allow an iframe to do a top-level navigation if it received a
user gesture. However, if an iframe's previous document received a user
activation, or worse, if the iframe was not navigated to anything and
got a user activation because its embedder was interacted with, this
allows the current document to circumvent our framebusting
interventions. The latter happens because of same-origin descendant
activation behavior. See:
https://source.chromium.org/chromium/chromium/src/+/main:content/browser/renderer_host/frame_tree_node.cc;l=766-778;drc=30753b1135fa271a3b45bbdbfef6567e46733a7f;bpv=1;bpt=1

Note that this problem does not exist if site isolation is enabled
(which is by default on desktop platforms), since a cross-site
navigation will create a whole new process with a fresh
`UserActivationState`.

To fix this, this CL clears the user activation state on cross-site
subframe navigations in the renderer (user activation is already cleared
for main frames). To ensure that same-site navigations persist user
state even if a cross-origin or same-origin navigation results in a new
process or RenderFrameHost being created, this CL also explicitly
transfers sticky user activation state for all same-site
cross-RenderFrameHost navigations. This takes place in the browser, and
the resulting bit to determine if a frame should have sticky user
activation is passed to the renderer.

The ultimate end goal is to unconditionally clear the user activation
state for all cross-document navigations. That unfortunately is not
possible today as there are entrenched use cases that rely on sticky
user activation state being cached for same-site navigations. See:
https://crbug.com/40228985.

This CL also fixes the aforementioned regression when enabling the
RenderDocument feature, since this CL will now preserve the sticky user
activation state regardless of what
process/RenderFrameHost/RenderDocument state the navigation results in.

This CL adds some tests to the no-auto-wpt-origin-isolation test suite, which requires some additional description:

* These tests are running on all platforms because site isolation behavior may differ per platform
* All of the tests in the-iframe-element are being added because it would be useful to understand their behavior in all expected process
configurations
* The total time taken for this test suite on linux-rel showed a total time percentage of <0.3%

Bug: 41493458
Change-Id: Ibec11437fcd03470571e04a4e0dfaadffddf6c03
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5269464
Reviewed-by: Mustaq Ahmed <mustaq@chromium.org>
Reviewed-by: Charlie Reis <creis@chromium.org>
Reviewed-by: Jeremy Roman <jbroman@chromium.org>
Reviewed-by: Robert Flack <flackr@chromium.org>
Reviewed-by: Andrew Verge <averge@chromium.org>
Commit-Queue: Liam Brady <lbrady@google.com>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Reviewed-by: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1269856}
4 files changed
tree: 0342800c4223c695e4084cf8766ac018bae0c6c3
  1. .github/
  2. .well-known/
  3. accelerometer/
  4. accessibility/
  5. accname/
  6. acid/
  7. ambient-light/
  8. animation-worklet/
  9. annotation-model/
  10. annotation-protocol/
  11. annotation-vocab/
  12. apng/
  13. appmanifest/
  14. attribution-reporting/
  15. audio-output/
  16. autoplay-policy-detection/
  17. avif/
  18. background-fetch/
  19. background-sync/
  20. badging/
  21. battery-status/
  22. beacon/
  23. bluetooth/
  24. browsing-topics/
  25. captured-mouse-events/
  26. clear-site-data/
  27. client-hints/
  28. clipboard-apis/
  29. close-watcher/
  30. common/
  31. compat/
  32. compression/
  33. compute-pressure/
  34. conformance-checkers/
  35. console/
  36. contacts/
  37. content-dpr/
  38. content-index/
  39. content-security-policy/
  40. contenteditable/
  41. cookie-deprecation-label/
  42. cookie-store/
  43. cookies/
  44. core-aam/
  45. cors/
  46. credential-management/
  47. css/
  48. custom-elements/
  49. delegated-ink/
  50. density-size-correction/
  51. deprecation-reporting/
  52. device-memory/
  53. direct-sockets/
  54. docs/
  55. document-picture-in-picture/
  56. document-policy/
  57. dom/
  58. domparsing/
  59. domxpath/
  60. dpub-aam/
  61. dpub-aria/
  62. ecmascript/
  63. editing/
  64. element-timing/
  65. encoding/
  66. encoding-detection/
  67. encrypted-media/
  68. entries-api/
  69. event-timing/
  70. eventsource/
  71. eyedropper/
  72. feature-policy/
  73. fenced-frame/
  74. fetch/
  75. file-system-access/
  76. FileAPI/
  77. fledge/
  78. focus/
  79. font-access/
  80. fonts/
  81. forced-colors-mode/
  82. fs/
  83. fullscreen/
  84. gamepad/
  85. generic-sensor/
  86. geolocation-API/
  87. geolocation-sensor/
  88. graphics-aam/
  89. graphics-aria/
  90. gyroscope/
  91. hr-time/
  92. html/
  93. html-aam/
  94. html-longdesc/
  95. html-media-capture/
  96. https-upgrades/
  97. idle-detection/
  98. imagebitmap-renderingcontext/
  99. images/
  100. import-maps/
  101. IndexedDB/
  102. inert/
  103. infrastructure/
  104. input-device-capabilities/
  105. input-events/
  106. installedapp/
  107. interfaces/
  108. intersection-observer/
  109. intervention-reporting/
  110. is-input-pending/
  111. jpegxl/
  112. js/
  113. js-self-profiling/
  114. keyboard-lock/
  115. keyboard-map/
  116. largest-contentful-paint/
  117. layout-instability/
  118. lifecycle/
  119. loading/
  120. long-animation-frame/
  121. longtask-timing/
  122. magnetometer/
  123. managed/
  124. mathml/
  125. measure-memory/
  126. media/
  127. media-capabilities/
  128. media-playback-quality/
  129. media-source/
  130. mediacapture-extensions/
  131. mediacapture-fromelement/
  132. mediacapture-handle/
  133. mediacapture-image/
  134. mediacapture-insertable-streams/
  135. mediacapture-record/
  136. mediacapture-region/
  137. mediacapture-streams/
  138. mediasession/
  139. merchant-validation/
  140. mimesniff/
  141. mixed-content/
  142. mst-content-hint/
  143. navigation-api/
  144. navigation-timing/
  145. netinfo/
  146. network-error-logging/
  147. notifications/
  148. old-tests/
  149. orientation-event/
  150. orientation-sensor/
  151. page-lifecycle/
  152. page-visibility/
  153. paint-timing/
  154. parakeet/
  155. payment-handler/
  156. payment-method-basic-card/
  157. payment-method-id/
  158. payment-request/
  159. pending-beacon/
  160. performance-timeline/
  161. periodic-background-sync/
  162. permissions/
  163. permissions-policy/
  164. permissions-request/
  165. permissions-revoke/
  166. picture-in-picture/
  167. png/
  168. pointerevents/
  169. pointerlock/
  170. preload/
  171. presentation-api/
  172. print/
  173. private-aggregation/
  174. private-click-measurement/
  175. proximity/
  176. push-api/
  177. quirks/
  178. referrer-policy/
  179. remote-playback/
  180. reporting/
  181. requestidlecallback/
  182. resize-observer/
  183. resource-timing/
  184. resources/
  185. sanitizer-api/
  186. savedata/
  187. scheduler/
  188. screen-capture/
  189. screen-details/
  190. screen-orientation/
  191. screen-wake-lock/
  192. scroll-animations/
  193. scroll-to-text-fragment/
  194. secure-contexts/
  195. secure-payment-confirmation/
  196. selection/
  197. serial/
  198. server-timing/
  199. service-workers/
  200. shadow-dom/
  201. shape-detection/
  202. shared-storage/
  203. shared-storage-selecturl-limit/
  204. signed-exchange/
  205. soft-navigation-heuristics/
  206. speculation-rules/
  207. speech-api/
  208. storage/
  209. storage-access-api/
  210. streams/
  211. subapps/
  212. subresource-integrity/
  213. svg/
  214. svg-aam/
  215. timing-entrytypes-registry/
  216. tools/
  217. top-level-storage-access-api/
  218. touch-events/
  219. trust-tokens/
  220. trusted-types/
  221. ua-client-hints/
  222. uievents/
  223. upgrade-insecure-requests/
  224. url/
  225. urlpattern/
  226. user-timing/
  227. vibration/
  228. video-rvfc/
  229. virtual-keyboard/
  230. visual-viewport/
  231. wai-aria/
  232. wasm/
  233. web-animations/
  234. web-bundle/
  235. web-locks/
  236. web-nfc/
  237. web-otp/
  238. web-share/
  239. webaudio/
  240. webauthn/
  241. webcodecs/
  242. WebCryptoAPI/
  243. webdriver/
  244. webgl/
  245. webgpu/
  246. webhid/
  247. webidl/
  248. webmessaging/
  249. webmidi/
  250. webnn/
  251. webrtc/
  252. webrtc-encoded-transform/
  253. webrtc-extensions/
  254. webrtc-ice/
  255. webrtc-identity/
  256. webrtc-priority/
  257. webrtc-stats/
  258. webrtc-svc/
  259. websockets/
  260. webstorage/
  261. webtransport/
  262. webusb/
  263. webvr/
  264. webvtt/
  265. webxr/
  266. window-management/
  267. workers/
  268. worklets/
  269. x-frame-options/
  270. xhr/
  271. .azure-pipelines.yml
  272. .gitattributes
  273. .gitignore
  274. .mailmap
  275. .taskcluster.yml
  276. CODE_OF_CONDUCT.md
  277. CODEOWNERS
  278. CONTRIBUTING.md
  279. LICENSE.md
  280. lint.ignore
  281. README.md
  282. wpt
  283. wpt.py
README.md

The web-platform-tests Project

Taskcluster CI Status documentation manifest Python 3

The web-platform-tests Project is a cross-browser test suite for the Web-platform stack. Writing tests in a way that allows them to be run in all browsers gives browser projects confidence that they are shipping software that is compatible with other implementations, and that later implementations will be compatible with their implementations. This in turn gives Web authors/developers confidence that they can actually rely on the Web platform to deliver on the promise of working across browsers and devices without needing extra layers of abstraction to paper over the gaps left by specification editors and implementors.

The most important sources of information and activity are:

  • github.com/web-platform-tests/wpt: the canonical location of the project's source code revision history and the discussion forum for changes to the code
  • web-platform-tests.org: the documentation website; details how to set up the project, how to write tests, how to give and receive peer review, how to serve as an administrator, and more
  • wpt.live: a public deployment of the test suite, allowing anyone to run the tests by visiting from an Internet-enabled browser of their choice
  • wpt.fyi: an archive of test results collected from an array of web browsers on a regular basis
  • Real-time chat room: the wpt:matrix.org matrix channel; includes participants located around the world, but busiest during the European working day.
  • Mailing list: a public and low-traffic discussion list
  • RFCs: a repo for requesting comments on substantial changes that would impact other stakeholders or users; people who work on WPT infra are encouraged to watch the repo.

If you'd like clarification about anything, don't hesitate to ask in the chat room or on the mailing list.

Setting Up the Repo

Clone or otherwise get https://github.com/web-platform-tests/wpt.

Note: because of the frequent creation and deletion of branches in this repo, it is recommended to “prune” stale branches when fetching updates, i.e. use git pull --prune (or git fetch -p && git merge).

Running the Tests

See the documentation website and in particular the system setup for running tests locally.

Command Line Tools

The wpt command provides a frontend to a variety of tools for working with and running web-platform-tests. Some of the most useful commands are:

  • wpt serve - For starting the wpt http server
  • wpt run - For running tests in a browser
  • wpt lint - For running the lint against all tests
  • wpt manifest - For updating or generating a MANIFEST.json test manifest
  • wpt install - For installing the latest release of a browser or webdriver server on the local machine.
  • wpt serve-wave - For starting the wpt http server and the WAVE test runner. For more details on how to use the WAVE test runner see the documentation.

Windows Notes

On Windows wpt commands must be prefixed with python or the path to the python binary (if python is not in your %PATH%).

python wpt [command]

Alternatively, you may also use Bash on Ubuntu on Windows in the Windows 10 Anniversary Update build, then access your windows partition from there to launch wpt commands.

Please make sure git and your text editor do not automatically convert line endings, as it will cause lint errors. For git, please set git config core.autocrlf false in your working tree.

Publication

The master branch is automatically synced to wpt.live and w3c-test.org.

Contributing

Save the Web, Write Some Tests!

Absolutely everyone is welcome to contribute to test development. No test is too small or too simple, especially if it corresponds to something for which you've noted an interoperability bug in a browser.

The way to contribute is just as usual:

  • Fork this repository (and make sure you're still relatively in sync with it if you forked a while ago).
  • Create a branch for your changes: git checkout -b topic.
  • Make your changes.
  • Run ./wpt lint as described above.
  • Commit locally and push that to your repo.
  • Create a pull request based on the above.

Issues with web-platform-tests

If you spot an issue with a test and are not comfortable providing a pull request per above to fix it, please file a new issue. Thank you!