Skip to content

Commit

Permalink
Import wpt@61d372914a4a23c86022f4abafc4d819247d1788
Browse files Browse the repository at this point in the history
Using wpt-import in Chromium d1311be.
With Chromium commits locally applied on WPT:
50840fb "Ignore the second and subsequent Early Hints responses"


Note to sheriffs: This CL imports external tests and adds
expectations for those tests; if this CL is large and causes
a few new failures, please fix the failures by adding new
lines to TestExpectations rather than reverting. See:
https://chromium.googlesource.com/chromium/src/+/main/docs/testing/web_platform_tests.md

Directory owners for changes in this CL:
igrigorik@chromium.org, yoavweiss@chromium.org:
  external/wpt/preload

NOAUTOREVERT=true

No-Export: true
Cq-Include-Trybots: luci.chromium.try:linux-wpt-identity-fyi-rel,linux-wpt-input-fyi-rel,linux-blink-rel
Change-Id: If91f77966929e3bfcb7f71bb8930618365494ce1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3540480
Auto-Submit: WPT Autoroller <wpt-autoroller@chops-service-accounts.iam.gserviceaccount.com>
Reviewed-by: Weizhong Xia <weizhong@google.com>
Commit-Queue: Weizhong Xia <weizhong@google.com>
Cr-Commit-Position: refs/heads/main@{#983404}
  • Loading branch information
Chromium WPT Sync authored and Chromium LUCI CQ committed Mar 21, 2022
1 parent 01d1d52 commit 9cf7c10
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 1 deletion.
2 changes: 1 addition & 1 deletion third_party/blink/web_tests/external/Version
@@ -1 +1 @@
Version: b6fd9afc6cdfdbcc306503d7b689006fd461923b
Version: 61d372914a4a23c86022f4abafc4d819247d1788
57 changes: 57 additions & 0 deletions third_party/blink/web_tests/external/WPT_BASE_MANIFEST_8.json
Expand Up @@ -307733,6 +307733,14 @@
"59f67be3cf929d89ecc6ec8598ee7276b1648fa3",
[]
],
"multiple-early-hints-responses.h2.py": [
"70f2476016cf4715d7ec36b8ac136e6f6b4c3676",
[]
],
"multiple-early-hints-responses.html": [
"3be2852348ba800662fa2caf626654b2f40b5902",
[]
],
"preload-initiator-type.html": [
"0fdeb2b9037be8785880f71045a9facbc85fb394",
[]
Expand Down Expand Up @@ -312117,6 +312125,10 @@
"906de0c95aeb58e24d1b7e779f1ed99de40d7af1",
[]
],
"link-header-preload-non-html-expected.txt": [
"9e7a1306db01759f0cbf99ef887f3632aa1c698b",
[]
],
"link-header-preload-nonce.html.headers": [
"a54b69378e9cc785ee02ec4a37694f90c366403b",
[]
Expand Down Expand Up @@ -312190,6 +312202,10 @@
"360e6686bfb65ed33d811d15e1ba7183a736d552",
[]
],
"echo-preload-header.py": [
"5cfb9e8c259a05d0b4646c49bea449b4244ae3b9",
[]
],
"echo-with-cors.py": [
"06d30c303c601ccabcfc1e3810c965dc45016538",
[]
Expand Down Expand Up @@ -473999,6 +474015,24 @@
}
]
],
"multiple-early-hints-responses.h2.window.js": [
"24230c07f503a2145ddccc575526426e9dd40e51",
[
"loading/early-hints/multiple-early-hints-responses.h2.window.html",
{
"script_metadata": [
[
"script",
"/common/utils.js"
],
[
"script",
"resources/early-hints-helpers.sub.js"
]
]
}
]
],
"preload-initiator-type.h2.window.js": [
"959aacef4978b935b44fec694d5f3ca3cb074485",
[
Expand Down Expand Up @@ -485101,6 +485135,20 @@
{}
]
],
"fcp-document-opacity-image.html": [
"7f211324761b4f63995ee00f40c0af0a7dc27488",
[
null,
{}
]
],
"fcp-document-opacity-text.html": [
"12384d5585ec9769606fc3e646ce17077b455188",
[
null,
{}
]
],
"fcp-gradient.html": [
"c1e147472ff076cb2aa72b7dfc45cd6d3a00ed34",
[
Expand Down Expand Up @@ -489012,6 +489060,15 @@
{}
]
],
"link-header-preload-non-html.html": [
"c990e610d9c1f7305b85111e59d36b96352a8a03",
[
null,
{
"timeout": "long"
}
]
],
"link-header-preload-nonce.html": [
"74ea87042b4546beff6b5180aa38685ac01bd084",
[
Expand Down
@@ -0,0 +1,8 @@
This is a testharness.js-based test.
PASS XHTML documents should respect preload Link headers
PASS plain text documents should respect preload Link headers
PASS image documents should respect preload Link headers
FAIL media documents should respect preload Link headers assert_equals: verify that request was issued exactly once expected 1 but got 2
PASS invalid image documents should respect preload Link headers
Harness: the test ran to completion.

@@ -0,0 +1,59 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Makes sure that Link headers preload resources in non-HTML documents</title>
<meta name="timeout" content="long">
<script src="resources/dummy.js?link-header-preload2"></script>
<script src="/common/utils.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/preload/resources/preload_helper.js"></script>
<body>
<script>

function test_document_type(options, desc) {
promise_test(async t => {
const id = token();
const preloadLink = `/html/semantics/document-metadata/the-link-element/stylesheet.py?id=${id}`;
const params = new URLSearchParams();
for (const opt in options)
params.set(opt, options[opt]);
params.set('link', `<${preloadLink}>;rel=preload;as=style`);

const docURL = getAbsoluteURL(`./resources/echo-preload-header.py?${params.toString()}`);
const iframe = document.createElement('iframe');
t.add_cleanup(() => iframe.remove());
iframe.src = docURL;
document.body.appendChild(iframe);
await new Promise(resolve => iframe.addEventListener('load', resolve));
const timeout = 5000;
const interval = 25;
let count = 0;
const before = performance.now();

while (performance.now() < before + timeout) {
// count=true returns the number of times the resource was accessed
const res = await fetch(preloadLink + '&count=true');

// If count is positive, the resource was accessed.
count = Number(await res.text());
if (count > 0)
break;

await new Promise(resolve => t.step_timeout(resolve, interval));
}

assert_equals(count, 1, "verify that request was issued exactly once");
}, `${desc} documents should respect preload Link headers`);
}

test_document_type({
type: 'application/xml',
content: `<?xml version="1.0" encoding="utf-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
</html>`}, "XHTML");
test_document_type({content: 'Hello', type: 'text/plain'}, 'plain text');
test_document_type({file: 'square.png', type: 'image/png'}, 'image');
test_document_type({file: 'white.mp4', type: 'video/mp4'}, 'media');
test_document_type({content: 'dummy', type: 'image/png'}, 'invalid image');
</script>
</body>
@@ -0,0 +1,16 @@
import os
from wptserve.utils import isomorphic_encode

def main(request, response):
response.headers.set(b"Content-Type", request.GET.first(b"type"))
link = request.GET.first(b"link")
response.headers.set(b"Access-Control-Allow-Origin", b"*")
response.headers.set(b"Access-Control-Allow-Credentials", b"true")
if link is not None:
response.headers.set(b"Link", link)

if b"file" in request.GET:
path = os.path.join(os.path.dirname(isomorphic_encode(__file__)), request.GET.first(b"file"));
response.content = open(path, mode=u'rb').read();
else:
return request.GET.first(b"content")
@@ -0,0 +1,8 @@
This is a testharness.js-based test.
PASS XHTML documents should respect preload Link headers
PASS plain text documents should respect preload Link headers
PASS image documents should respect preload Link headers
FAIL media documents should respect preload Link headers assert_equals: verify that request was issued exactly once expected 1 but got 2
PASS invalid image documents should respect preload Link headers
Harness: the test ran to completion.

0 comments on commit 9cf7c10

Please sign in to comment.