Commit b2e38b8f authored by Aaron Tagliaboschi's avatar Aaron Tagliaboschi Committed by moz-wptsync-bot
Browse files

Bug 1720239 [wpt PR 29646] - Turn Critical-CH restarts into internal redirects, a=testonly

Automatic update from web-platform-tests
Turn Critical-CH restarts into internal redirects

This fixes a number of issues, including crashes. Unfortunately, this
will not fix issues with ACCEPT_CH, which is having a very similar
crasher problem.

The behaviour is now as follows: if a Critical-CH restart is detected,
the Accept-CH preferences are stored as they would be and the
ThrottlingURLLoader changes the response to a synthetic redirect. This
is registered and takes the response through the normal navigation
redirect codepath (which adds the client hints that were stored) and
allows extensions, service workers, and other interceptors the chance to
handle the new request. The one-redirect limit was also removed and now
counts towards the network/navigation redirect limits. Coincidentally,
this also runs through the devtools, which makes both the initial and
new requests both visible in the Network tab as an internal redirect
and regular request.

The crashing code is very much NOT fixed by this (see crbug.com/1217589)
but rather is side-stepped (instead of restarting the request outright,
there's now an internal redirect, which also makes more sense
semantically)

Also (somewhat coincidentally) fixed an issue with the
client hint/service worker WPTs, in that the tests were not waiting for
the load event to finish
(see the changes in
//third_party/blink/web_tests/external/wpt/client-hints/service-workers/resources/util.js)

Bug: 1217589, 1228536, 1176879
Change-Id: I8401c67818cdd6cf16a75422b2ba48fe429dc961
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2983659


Commit-Queue: Aaron Tagliaboschi <aarontag@chromium.org>
Reviewed-by: default avatarTakashi Toyoshima <toyoshim@chromium.org>
Reviewed-by: default avatarYoav Weiss <yoavweiss@chromium.org>
Cr-Commit-Position: refs/heads/master@{#904079}

--

wpt-commits: 74d5d9577ee54ead71cc051a1467b9eedc341cfb
wpt-pr: 29646
parent 247f8835
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
import sys

def main(request, response):
    """
    Simple handler that sets a response header based on which client hint
    request headers were received.
    """

    response.headers.append(b"Content-Type", b"text/html; charset=UTF-8")
    response.headers.append(b"Access-Control-Allow-Origin", b"*")
    response.headers.append(b"Access-Control-Allow-Headers", b"*")
    response.headers.append(b"Access-Control-Expose-Headers", b"*")

    response.headers.append(b"Cache-Control", b"no-store")

    response.headers.append(b"Accept-CH", b"device-memory");
    response.headers.append(b"Critical-CH", b"device-memory");

    result = "FAIL"

    if b"device-memory" in request.headers:
      result = "PASS"

    response.content = result
+1 −0
Original line number Diff line number Diff line
BAR
+2 −0
Original line number Diff line number Diff line
Accept-CH: device-memory
Critical-CH: device-memory
+6 −0
Original line number Diff line number Diff line
self.addEventListener('fetch', (event) => {
  result="FAIL";
  if(event.request.headers.has("device-memory"))
    result="PASS";
  event.respondWith(new Response(result));
});
+2 −0
Original line number Diff line number Diff line
self.addEventListener('activate', () => self.registration.navigationPreload.enable());
self.addEventListener('fetch', (event) => event.respondWith(event.preloadResponse));
Loading