Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Revise filtering for Content-Encoding in ResourceTiming #50456

Merged
merged 1 commit into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions resource-timing/content-encoding.https.html
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
15 changes: 15 additions & 0 deletions resource-timing/resources/content-encoding-headers.py
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)