Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

<!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>