Change Feature-Policy header semantics

This change implements the algorithmic changes for a recent change
to the Feature/Permissions policy spec:
https://github.com/w3c/webappsec-permissions-policy/pull/378

With this change, the Feature-Policy or Permissions-Policy headers by
themselves cannot be used to delegate powerful features to cross-origin
iframes; the allow attribute must be used as well. To allow this to
still be ergonomic, the default value for the header for powerful
features is effectively '*', so that delegation is allowed by the header
implicitly. The header can now be used effectively to completely block
access to a feature, as any origins not present in the header allowlist
cannot be granted the feature through the allow attribute.

This also removes some code which previously only existed to track the
cases where this change would affect the output of an IsFeatureEnabled
call.

Several tests will have been modified or rewritten prior to landing
this change; this CL depends on the following (though they are all
independent, so they are not chained together):
 - https://crrev.com/c/2424633
 - https://crrev.com/c/2424634
 - https://crrev.com/c/2424635
 - https://crrev.com/c/2424654
 - https://crrev.com/c/2424655
 - https://crrev.com/c/2424657
 - https://crrev.com/c/2425003
 - https://crrev.com/c/2425004
(See Patchset 8 for a version with the changes from all of those CLs
included.)

This CL, while large, can best be understood as the union of the
following changes:

 - Algorithm changes, including the removal of previous "what-if" code
   and metrics:
    feature_policy.cc
    feature_policy.h
    execution_context.cc

 - Unit tests to cover those changes:
    feature_policy_unittest.cc
    render_frame_host_feature_policy_unittest.cc

 - Update WPT test expectations to account for the change in behaviour
   when only the header is used:
    3p/b/web_tests/external/wpt/feature-policy/feature-policy-*
    3p/b/web_tests/external/wpt/permissions-policy/permissions-policy-*

 - Update Blink web tests for fullscreen and payment request to validate
    that both are now working correctly with the new header semantics:
    3p/b/web_tests/http/tests/feature-policy/fullscreen*
    3p/b/web_tests/http/tests/feature-policy/payment*

 - Update Blink web tests for the iframe policy JS interface because of
   new test expectations when features are allowed/disallowed by header:
    3p/b/renderer/core/feature_policy/policy_test.cc
    3p/b/web_tests/http/tests/feature-policy/policy_iframes.php

Bug: 1095641, 937131
Change-Id: Iecbb0950c27a4565998ee5192590d6691a03b4a3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2363169
Reviewed-by: Yoav Weiss <yoavweiss@chromium.org>
Reviewed-by: Charlie Hu <chenleihu@google.com>
Reviewed-by: Ken Buchanan <kenrb@chromium.org>
Commit-Queue: Ian Clelland <iclelland@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826408}
17 files changed
tree: 34212dfd0211740913f141a113b495b45ddf6dc1
  1. .github/
  2. .well-known/
  3. accelerometer/
  4. accname/
  5. acid/
  6. ambient-light/
  7. animation-worklet/
  8. annotation-model/
  9. annotation-protocol/
  10. annotation-vocab/
  11. apng/
  12. appmanifest/
  13. audio-output/
  14. background-fetch/
  15. BackgroundSync/
  16. badging/
  17. battery-status/
  18. beacon/
  19. bluetooth/
  20. clear-site-data/
  21. client-hints/
  22. clipboard-apis/
  23. common/
  24. compat/
  25. compression/
  26. conformance-checkers/
  27. console/
  28. contacts/
  29. content-dpr/
  30. content-index/
  31. content-security-policy/
  32. contenteditable/
  33. cookie-store/
  34. cookies/
  35. core-aam/
  36. cors/
  37. cors-rfc1918/
  38. credential-management/
  39. css/
  40. custom-elements/
  41. custom-state-pseudo-class/
  42. delegated-ink/
  43. density-size-correction/
  44. deprecation-reporting/
  45. device-memory/
  46. docs/
  47. document-policy/
  48. dom/
  49. domparsing/
  50. domxpath/
  51. dpub-aam/
  52. dpub-aria/
  53. editing/
  54. element-timing/
  55. encoding/
  56. encoding-detection/
  57. encrypted-media/
  58. entries-api/
  59. event-timing/
  60. eventsource/
  61. feature-policy/
  62. fetch/
  63. FileAPI/
  64. focus/
  65. font-access/
  66. fonts/
  67. forced-colors-mode/
  68. fullscreen/
  69. gamepad/
  70. generic-sensor/
  71. geolocation-API/
  72. geolocation-sensor/
  73. graphics-aam/
  74. gyroscope/
  75. hr-time/
  76. html/
  77. html-longdesc/
  78. html-media-capture/
  79. idle-detection/
  80. imagebitmap-renderingcontext/
  81. images/
  82. import-maps/
  83. IndexedDB/
  84. inert/
  85. infrastructure/
  86. input-device-capabilities/
  87. input-events/
  88. installedapp/
  89. interfaces/
  90. intersection-observer/
  91. intervention-reporting/
  92. is-input-pending/
  93. js/
  94. js-self-profiling/
  95. keyboard-lock/
  96. keyboard-map/
  97. largest-contentful-paint/
  98. layout-instability/
  99. lifecycle/
  100. loading/
  101. longtask-timing/
  102. magnetometer/
  103. mathml/
  104. measure-memory/
  105. media/
  106. media-capabilities/
  107. media-feeds/
  108. media-playback-quality/
  109. media-source/
  110. mediacapture-depth/
  111. mediacapture-fromelement/
  112. mediacapture-image/
  113. mediacapture-record/
  114. mediacapture-streams/
  115. mediasession/
  116. merchant-validation/
  117. mimesniff/
  118. mixed-content/
  119. mst-content-hint/
  120. native-file-system/
  121. native-io/
  122. navigation-timing/
  123. netinfo/
  124. network-error-logging/
  125. notifications/
  126. old-tests/
  127. orientation-event/
  128. orientation-sensor/
  129. origin-isolation/
  130. origin-policy/
  131. page-lifecycle/
  132. page-visibility/
  133. paint-timing/
  134. payment-handler/
  135. payment-method-basic-card/
  136. payment-method-id/
  137. payment-request/
  138. performance-timeline/
  139. periodic-background-sync/
  140. permissions/
  141. permissions-policy/
  142. permissions-request/
  143. permissions-revoke/
  144. picture-in-picture/
  145. pointerevents/
  146. pointerlock/
  147. portals/
  148. preload/
  149. presentation-api/
  150. priority-hints/
  151. proximity/
  152. push-api/
  153. quirks/
  154. raw-sockets/
  155. referrer-policy/
  156. remote-playback/
  157. reporting/
  158. requestidlecallback/
  159. resize-observer/
  160. resource-timing/
  161. resources/
  162. sanitizer-api/
  163. savedata/
  164. screen-capture/
  165. screen-orientation/
  166. screen-wake-lock/
  167. screen_enumeration/
  168. scroll-animations/
  169. scroll-to-text-fragment/
  170. secure-contexts/
  171. secure-payment-confirmation/
  172. selection/
  173. serial/
  174. server-timing/
  175. service-workers/
  176. shadow-dom/
  177. shape-detection/
  178. signed-exchange/
  179. speech-api/
  180. storage/
  181. storage-access-api/
  182. streams/
  183. subresource-integrity/
  184. svg/
  185. svg-aam/
  186. timing-entrytypes-registry/
  187. tools/
  188. touch-events/
  189. trust-tokens/
  190. trusted-types/
  191. ua-client-hints/
  192. uievents/
  193. upgrade-insecure-requests/
  194. url/
  195. user-timing/
  196. vibration/
  197. video-rvfc/
  198. visual-viewport/
  199. wai-aria/
  200. wasm/
  201. web-animations/
  202. web-bundle/
  203. web-locks/
  204. web-nfc/
  205. web-otp/
  206. web-share/
  207. webaudio/
  208. webauthn/
  209. webcodecs/
  210. WebCryptoAPI/
  211. webdriver/
  212. webgl/
  213. webgpu/
  214. webhid/
  215. WebIDL/
  216. webmessaging/
  217. webmidi/
  218. webrtc/
  219. webrtc-extensions/
  220. webrtc-identity/
  221. webrtc-insertable-streams/
  222. webrtc-priority/
  223. webrtc-stats/
  224. webrtc-svc/
  225. websockets/
  226. webstorage/
  227. webtransport/
  228. webusb/
  229. webvr/
  230. webvtt/
  231. webxr/
  232. window-segments/
  233. workers/
  234. worklets/
  235. x-frame-options/
  236. xhr/
  237. xslt/
  238. .azure-pipelines.yml
  239. .codecov.yml
  240. .gitattributes
  241. .gitignore
  242. .mailmap
  243. .pyup.yml
  244. .taskcluster.yml
  245. CODE_OF_CONDUCT.md
  246. CODEOWNERS
  247. CONTRIBUTING.md
  248. LICENSE.md
  249. lint.ignore
  250. README.md
  251. testharness_runner.html
  252. update-built-tests.sh
  253. wpt
  254. 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 IRC chat room named #testing on irc.w3.org; includes participants located around the world, but busiest during the European working day; all discussion is archived here
  • 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 http://w3c-test.org/.

Pull requests are automatically mirrored except those that modify sensitive resources (such as .py). The latter require someone with merge access to comment with “LGTM” or “w3c-test:mirror” to indicate the pull request has been checked.

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!