Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Update WPT #3954

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,373 @@
<!DOCTYPE html>
<!--
This test was procedurally generated. Please do not modify it directly.
Sources:
- fetch/metadata/tools/fetch-metadata.conf.yml
- fetch/metadata/tools/templates/script-json-module-import-static.sub.html
-->
<html lang="en">
<meta charset="utf-8">
<title>HTTP headers on request for static ECMAScript module import</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/fetch/metadata/resources/helper.sub.js"></script>
<body>
<script>
'use strict';

function induceRequest(url) {
const script = document.createElement('script');
script.setAttribute('type', 'module');
script.setAttribute(
'src',
'/fetch/metadata/resources/es-json-module.sub.js?moduleId=' + encodeURIComponent(url)
);

return new Promise((resolve, reject) => {
script.onload = resolve;
script.onerror = () => reject('Failed to load script');
document.body.appendChild(script);
})
.then(() => script.remove());
}

promise_test(() => {
const key = '{{uuid()}}';

return induceRequest(
makeRequestURL(
key,
['httpsOrigin'],
{
mime: 'application/json',
body: '{}'
}
)
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['same-origin']);
});
}, 'sec-fetch-site - Same origin');

promise_test(() => {
const key = '{{uuid()}}';

return induceRequest(
makeRequestURL(
key,
['httpsCrossSite'],
{
mime: 'application/json',
body: '{}'
}
)
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['cross-site']);
});
}, 'sec-fetch-site - Cross-site');

promise_test(() => {
const key = '{{uuid()}}';

return induceRequest(
makeRequestURL(
key,
['httpsSameSite'],
{
mime: 'application/json',
body: '{}'
}
)
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['same-site']);
});
}, 'sec-fetch-site - Same site');

promise_test(() => {
const key = '{{uuid()}}';

return induceRequest(
makeRequestURL(
key,
['httpsOrigin', 'httpsCrossSite', 'httpsOrigin'],
{
mime: 'application/json',
body: '{}'
}
)
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['cross-site']);
});
}, 'sec-fetch-site - Same-Origin -> Cross-Site -> Same-Origin redirect');

promise_test(() => {
const key = '{{uuid()}}';

return induceRequest(
makeRequestURL(
key,
['httpsOrigin', 'httpsSameSite', 'httpsOrigin'],
{
mime: 'application/json',
body: '{}'
}
)
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['same-site']);
});
}, 'sec-fetch-site - Same-Origin -> Same-Site -> Same-Origin redirect');

promise_test(() => {
const key = '{{uuid()}}';

return induceRequest(
makeRequestURL(
key,
['httpsCrossSite', 'httpsOrigin'],
{
mime: 'application/json',
body: '{}'
}
)
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['cross-site']);
});
}, 'sec-fetch-site - Cross-Site -> Same Origin');

promise_test(() => {
const key = '{{uuid()}}';

return induceRequest(
makeRequestURL(
key,
['httpsCrossSite', 'httpsSameSite'],
{
mime: 'application/json',
body: '{}'
}
)
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['cross-site']);
});
}, 'sec-fetch-site - Cross-Site -> Same-Site');

promise_test(() => {
const key = '{{uuid()}}';

return induceRequest(
makeRequestURL(
key,
['httpsCrossSite', 'httpsCrossSite'],
{
mime: 'application/json',
body: '{}'
}
)
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['cross-site']);
});
}, 'sec-fetch-site - Cross-Site -> Cross-Site');

promise_test(() => {
const key = '{{uuid()}}';

return induceRequest(
makeRequestURL(
key,
['httpsOrigin', 'httpsOrigin'],
{
mime: 'application/json',
body: '{}'
}
)
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['same-origin']);
});
}, 'sec-fetch-site - Same-Origin -> Same Origin');

promise_test(() => {
const key = '{{uuid()}}';

return induceRequest(
makeRequestURL(
key,
['httpsOrigin', 'httpsSameSite'],
{
mime: 'application/json',
body: '{}'
}
)
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['same-site']);
});
}, 'sec-fetch-site - Same-Origin -> Same-Site');

promise_test(() => {
const key = '{{uuid()}}';

return induceRequest(
makeRequestURL(
key,
['httpsOrigin', 'httpsCrossSite'],
{
mime: 'application/json',
body: '{}'
}
)
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['cross-site']);
});
}, 'sec-fetch-site - Same-Origin -> Cross-Site');

promise_test(() => {
const key = '{{uuid()}}';

return induceRequest(
makeRequestURL(
key,
['httpsSameSite', 'httpsOrigin'],
{
mime: 'application/json',
body: '{}'
}
)
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['same-site']);
});
}, 'sec-fetch-site - Same-Site -> Same Origin');

promise_test(() => {
const key = '{{uuid()}}';

return induceRequest(
makeRequestURL(
key,
['httpsSameSite', 'httpsSameSite'],
{
mime: 'application/json',
body: '{}'
}
)
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['same-site']);
});
}, 'sec-fetch-site - Same-Site -> Same-Site');

promise_test(() => {
const key = '{{uuid()}}';

return induceRequest(
makeRequestURL(
key,
['httpsSameSite', 'httpsCrossSite'],
{
mime: 'application/json',
body: '{}'
}
)
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['cross-site']);
});
}, 'sec-fetch-site - Same-Site -> Cross-Site');

promise_test(() => {
const key = '{{uuid()}}';

return induceRequest(
makeRequestURL(
key,
[],
{
mime: 'application/json',
body: '{}'
}
)
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-mode');
assert_array_equals(headers['sec-fetch-mode'], ['cors']);
});
}, 'sec-fetch-mode');

promise_test(() => {
const key = '{{uuid()}}';

return induceRequest(
makeRequestURL(
key,
[],
{
mime: 'application/json',
body: '{}'
}
)
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-dest');
assert_array_equals(headers['sec-fetch-dest'], ['json']);
});
}, 'sec-fetch-dest');

promise_test(() => {
const key = '{{uuid()}}';

return induceRequest(
makeRequestURL(
key,
[],
{
mime: 'application/json',
body: '{}'
}
)
)
.then(() => retrieve(key))
.then((headers) => {
assert_not_own_property(headers, 'sec-fetch-user');
});
}, 'sec-fetch-user');
</script>
</html>
Loading