Skip to content

Commit

Permalink
Bug 1945614 [wpt PR 50456] - Revise filtering for Content-Encoding in…
Browse files Browse the repository at this point in the history
… ResourceTiming, a=testonly

Automatic update from web-platform-tests
Revise filtering for Content-Encoding in ResourceTiming

The value from the http header can be of multiple codings, or not
properly formatted.

Per discussion on w3c/resource-timing#381,
multiple codings should be transformed to "multiple"; "identity" is
not allowed in response header; and the coding value should be
formatted if it's not in http header.

Bug: 327941462
Change-Id: I9048423c5ad562d8001562324cb35f72ef8ac5da
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6215331
Reviewed-by: Noam Rosenthal <[email protected]>
Reviewed-by: Yoav Weiss (@Shopify) <[email protected]>
Commit-Queue: Guohui Deng <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1415037}

--

wpt-commits: 1691f567df269bca146cb8d25c43d644b2b42c63
wpt-pr: 50456
  • Loading branch information
Guohui Deng authored and moz-wptsync-bot committed Feb 5, 2025
1 parent bbf9030 commit 8a0ccc0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,16 @@
run_same_origin_test("/resource-timing/resources/foo.text.zst", "zstd");
run_same_origin_test("/resource-timing/resources/compressed-js.py?content_encoding=deflate", "deflate");
run_same_origin_test("/resource-timing/resources/compressed-js.py?content_encoding=gzip", "gzip");
run_same_origin_test("/resource-timing/resources/compressed-js.py?content_encoding=identity", "identity");
// Unrecognized content encoding value should be transformed to "unknown".
run_same_origin_test("/resource-timing/resources/compressed-js.py?content_encoding=unrecognizedname", "unknown");

// "identity" is not allowed in response header and should be transformed to "unknown".
run_same_origin_test("/resource-timing/resources/compressed-js.py?content_encoding=identity", "unknown");
// Mult-encodinging and formatting tests.
run_same_origin_test("/resource-timing/resources/content-encoding-headers.py?content_encoding=gzip, deflate,Apple", "multiple");
run_same_origin_test("/resource-timing/resources/content-encoding-headers.py?content_encoding=gzip, ", "multiple");
run_same_origin_test("/resource-timing/resources/content-encoding-headers.py?content_encoding=gZip ", "gzip");
// Empty value test.
run_same_origin_test("/resource-timing/resources/content-encoding-headers.py?content_encoding=", "");

const run_cross_origin_test = (path) => {
const url = new URL(path, REMOTE_ORIGIN);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import os.path

# Return arbitory content-encoding header value.

def read(file):
path = os.path.join(os.path.dirname(__file__), file)
return open(path, u"rb").read()

def main(request, response):
response.headers.set(b"Content-Type", b"text/javascript")
response.content = read(u"./dummy.js")

if b'content_encoding' in request.GET:
content_encoding = request.GET.first(b"content_encoding")
response.headers.set(b"Content-Encoding", content_encoding)

0 comments on commit 8a0ccc0

Please sign in to comment.