Fetch: Track protocol information in Response.

This CL plumbs three protocol related fields through the fetch API
Response internal representation:

1) The |alpn_negotiated_protocol| which is set for TLS negotiated
protocols like H2.
2) The |connection_info| enumeration which includes information on
older protocols like H1.
3) The |was_fetched_via_spdy| boolean which is set for H2.

The first two values, |alpn_negotiated_protocol| and |connection_info|,
are collectively used to populate the
`PerformanceResourceTiming.nextHopProtocol` value.  They are also both
used to populate the correct protocol information in the devtools network
panel.

The |was_fetched_via_spdy| boolean is used to populate the deprecated
`navigator.chrome.loadTimes().wasFetchedViaSpdy` property.

Without this plumbing the resulting exposed values will generally be
wrong if the page loaded via a service worker with a FetchEvent handler.
For example, `PerformanceResourceTiming.nextHopeProtocol` is always the
empty string for resources loaded via a service worker that does a
pass-through or cached load.

This CL also plumbs these values through the cache_storage layer.  While
that may seem unintuitive at first, since the data is coming from disk,
it matches the behavior when loading from http cache.  Generally the
values represent the protocol used to originally load the response and
are persisted in the cache.

I believe this also matches the cache_storage spec where Response
objects are effectively held in an array without any serialization
or deserialization where data would be lost:

https://w3c.github.io/ServiceWorker/#cache-objects

Although the spec is not currently clear if the protocol information
lives on the response object, its not clear where else it could be
stored.  This should become clearer once the Resource Timing spec is
integrated with the fetch spec in:

https://github.com/w3c/resource-timing/issues/39

This CL includes an automated WPT test for the
`PerformanceResourceTiming.nextHopProtocol` value since we can verify
that its populated with "http/1.1" instead of the empty string.
Unfortunately it was not possible to writes for the other attributes
since we do not currently have the ability to test against an http2
server.  Both `wasFetchedViaSpdy` and the devtools output effectively
need an http2 server to observe differences.  These parts of the CL were
manually tested.

Bug: 1069813
Change-Id: I84819ef5a53e9246f9e383e56b6d7e5901a7a243
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2143860
Reviewed-by: Jeremy Roman <jbroman@chromium.org>
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Ben Kelly <wanderview@chromium.org>
Cr-Commit-Position: refs/heads/master@{#770192}
2 files changed
tree: 53b988d79b34030c1122f1ca4a91cfea8211b9bb
  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. credential-management/
  38. css/
  39. custom-elements/
  40. delegated-ink/
  41. device-memory/
  42. docs/
  43. document-policy/
  44. dom/
  45. domparsing/
  46. domxpath/
  47. dpub-aam/
  48. dpub-aria/
  49. editing/
  50. element-timing/
  51. encoding/
  52. encoding-detection/
  53. encrypted-media/
  54. entries-api/
  55. event-timing/
  56. eventsource/
  57. feature-policy/
  58. fetch/
  59. FileAPI/
  60. fonts/
  61. forced-colors-mode/
  62. fullscreen/
  63. gamepad/
  64. generic-sensor/
  65. geolocation-API/
  66. geolocation-sensor/
  67. graphics-aam/
  68. gyroscope/
  69. hr-time/
  70. html/
  71. html-longdesc/
  72. html-media-capture/
  73. idle-detection/
  74. imagebitmap-renderingcontext/
  75. images/
  76. import-maps/
  77. IndexedDB/
  78. inert/
  79. infrastructure/
  80. input-device-capabilities/
  81. input-events/
  82. installedapp/
  83. interfaces/
  84. intersection-observer/
  85. js/
  86. js-self-profiling/
  87. keyboard-lock/
  88. keyboard-map/
  89. largest-contentful-paint/
  90. layout-instability/
  91. lifecycle/
  92. loading/
  93. longtask-timing/
  94. magnetometer/
  95. mathml/
  96. measure-memory/
  97. media/
  98. media-capabilities/
  99. media-playback-quality/
  100. media-source/
  101. mediacapture-depth/
  102. mediacapture-fromelement/
  103. mediacapture-image/
  104. mediacapture-record/
  105. mediacapture-streams/
  106. mediasession/
  107. mimesniff/
  108. mixed-content/
  109. mst-content-hint/
  110. native-file-system/
  111. native-io/
  112. navigation-timing/
  113. netinfo/
  114. network-error-logging/
  115. notifications/
  116. old-tests/
  117. orientation-event/
  118. orientation-sensor/
  119. origin-isolation/
  120. origin-policy/
  121. page-lifecycle/
  122. page-visibility/
  123. paint-timing/
  124. payment-handler/
  125. payment-method-basic-card/
  126. payment-method-id/
  127. payment-request/
  128. performance-timeline/
  129. periodic-background-sync/
  130. permissions/
  131. permissions-request/
  132. permissions-revoke/
  133. picture-in-picture/
  134. pointerevents/
  135. pointerlock/
  136. portals/
  137. preload/
  138. presentation-api/
  139. priority-hints/
  140. proximity/
  141. push-api/
  142. quirks/
  143. referrer-policy/
  144. remote-playback/
  145. reporting/
  146. requestidlecallback/
  147. resize-observer/
  148. resource-timing/
  149. resources/
  150. screen-capture/
  151. screen-orientation/
  152. screen-wake-lock/
  153. screen_enumeration/
  154. scroll-animations/
  155. scroll-to-text-fragment/
  156. secure-contexts/
  157. selection/
  158. serial/
  159. server-timing/
  160. service-workers/
  161. shadow-dom/
  162. shape-detection/
  163. signed-exchange/
  164. speech-api/
  165. storage/
  166. storage-access-api/
  167. streams/
  168. subresource-integrity/
  169. svg/
  170. svg-aam/
  171. timing-entrytypes-registry/
  172. tools/
  173. touch-events/
  174. trust-tokens/
  175. trusted-types/
  176. uievents/
  177. upgrade-insecure-requests/
  178. url/
  179. user-timing/
  180. vibration/
  181. video-rvfc/
  182. visual-viewport/
  183. wai-aria/
  184. wasm/
  185. web-animations/
  186. web-bundle/
  187. web-locks/
  188. web-nfc/
  189. web-share/
  190. webaudio/
  191. webauthn/
  192. WebCryptoAPI/
  193. webdriver/
  194. webgl/
  195. webgpu/
  196. WebIDL/
  197. webmessaging/
  198. webmidi/
  199. webrtc/
  200. webrtc-extensions/
  201. webrtc-identity/
  202. webrtc-insertable-streams/
  203. webrtc-priority/
  204. webrtc-quic/
  205. webrtc-stats/
  206. webrtc-svc/
  207. websockets/
  208. webstorage/
  209. webtransport/
  210. webusb/
  211. webvr/
  212. webvtt/
  213. webxr/
  214. workers/
  215. worklets/
  216. x-frame-options/
  217. xhr/
  218. xslt/
  219. .azure-pipelines.yml
  220. .codecov.yml
  221. .gitattributes
  222. .gitignore
  223. .mailmap
  224. .pyup.yml
  225. .taskcluster.yml
  226. CODEOWNERS
  227. CONTRIBUTING.md
  228. LICENSE.md
  229. lint.ignore
  230. README.md
  231. testharness_runner.html
  232. update-built-tests.sh
  233. wpt
  234. 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.

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.

Branches

In the vast majority of cases the only upstream branch that you should need to care about is master. If you see other branches in the repository, you can generally safely ignore them.

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!