Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /fetch/metadata/generated/element-img.https.sub.html - WPT Dashboard Interop Dashboard
<!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/element-img.sub.html
-->
<html lang="en">
<meta charset="utf-8">
<title>HTTP headers on request for HTML "img" element source</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, sourceAttr, attributes) {
const image = document.createElement('img');
for (const [ name, value ] of Object.entries(attributes)) {
image.setAttribute(name, value);
}
return new Promise((resolve) => {
image.setAttribute(sourceAttr, url);
image.onload = image.onerror = resolve;
});
}
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, ['httpsOrigin']),
'src',
{}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['same-origin']);
});
}, 'sec-fetch-site - src - Same origin, no attributes');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, ['httpsOrigin']),
'srcset',
{}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['same-origin']);
});
}, 'sec-fetch-site - srcset - Same origin, no attributes');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, ['httpsCrossSite']),
'src',
{}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['cross-site']);
});
}, 'sec-fetch-site - src - Cross-site, no attributes');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, ['httpsCrossSite']),
'srcset',
{}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['cross-site']);
});
}, 'sec-fetch-site - srcset - Cross-site, no attributes');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, ['httpsSameSite']),
'src',
{}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['same-site']);
});
}, 'sec-fetch-site - src - Same site, no attributes');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, ['httpsSameSite']),
'srcset',
{}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['same-site']);
});
}, 'sec-fetch-site - srcset - Same site, no attributes');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, ['httpsOrigin', 'httpsCrossSite', 'httpsOrigin']),
'src',
{}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['cross-site']);
});
}, 'sec-fetch-site - src - Same-Origin -> Cross-Site -> Same-Origin redirect, no attributes');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, ['httpsOrigin', 'httpsCrossSite', 'httpsOrigin']),
'srcset',
{}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['cross-site']);
});
}, 'sec-fetch-site - srcset - Same-Origin -> Cross-Site -> Same-Origin redirect, no attributes');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, ['httpsOrigin', 'httpsSameSite', 'httpsOrigin']),
'src',
{}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['same-site']);
});
}, 'sec-fetch-site - src - Same-Origin -> Same-Site -> Same-Origin redirect, no attributes');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, ['httpsOrigin', 'httpsSameSite', 'httpsOrigin']),
'srcset',
{}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['same-site']);
});
}, 'sec-fetch-site - srcset - Same-Origin -> Same-Site -> Same-Origin redirect, no attributes');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, ['httpsCrossSite', 'httpsOrigin']),
'src',
{}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['cross-site']);
});
}, 'sec-fetch-site - src - Cross-Site -> Same Origin, no attributes');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, ['httpsCrossSite', 'httpsOrigin']),
'srcset',
{}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['cross-site']);
});
}, 'sec-fetch-site - srcset - Cross-Site -> Same Origin, no attributes');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, ['httpsCrossSite', 'httpsSameSite']),
'src',
{}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['cross-site']);
});
}, 'sec-fetch-site - src - Cross-Site -> Same-Site, no attributes');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, ['httpsCrossSite', 'httpsSameSite']),
'srcset',
{}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['cross-site']);
});
}, 'sec-fetch-site - srcset - Cross-Site -> Same-Site, no attributes');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, ['httpsCrossSite', 'httpsCrossSite']),
'src',
{}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['cross-site']);
});
}, 'sec-fetch-site - src - Cross-Site -> Cross-Site, no attributes');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, ['httpsCrossSite', 'httpsCrossSite']),
'srcset',
{}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['cross-site']);
});
}, 'sec-fetch-site - srcset - Cross-Site -> Cross-Site, no attributes');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, ['httpsOrigin', 'httpsOrigin']),
'src',
{}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['same-origin']);
});
}, 'sec-fetch-site - src - Same-Origin -> Same Origin, no attributes');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, ['httpsOrigin', 'httpsOrigin']),
'srcset',
{}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['same-origin']);
});
}, 'sec-fetch-site - srcset - Same-Origin -> Same Origin, no attributes');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, ['httpsOrigin', 'httpsSameSite']),
'src',
{}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['same-site']);
});
}, 'sec-fetch-site - src - Same-Origin -> Same-Site, no attributes');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, ['httpsOrigin', 'httpsSameSite']),
'srcset',
{}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['same-site']);
});
}, 'sec-fetch-site - srcset - Same-Origin -> Same-Site, no attributes');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, ['httpsOrigin', 'httpsCrossSite']),
'src',
{}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['cross-site']);
});
}, 'sec-fetch-site - src - Same-Origin -> Cross-Site, no attributes');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, ['httpsOrigin', 'httpsCrossSite']),
'srcset',
{}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['cross-site']);
});
}, 'sec-fetch-site - srcset - Same-Origin -> Cross-Site, no attributes');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, ['httpsSameSite', 'httpsOrigin']),
'src',
{}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['same-site']);
});
}, 'sec-fetch-site - src - Same-Site -> Same Origin, no attributes');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, ['httpsSameSite', 'httpsOrigin']),
'srcset',
{}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['same-site']);
});
}, 'sec-fetch-site - srcset - Same-Site -> Same Origin, no attributes');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, ['httpsSameSite', 'httpsSameSite']),
'src',
{}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['same-site']);
});
}, 'sec-fetch-site - src - Same-Site -> Same-Site, no attributes');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, ['httpsSameSite', 'httpsSameSite']),
'srcset',
{}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['same-site']);
});
}, 'sec-fetch-site - srcset - Same-Site -> Same-Site, no attributes');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, ['httpsSameSite', 'httpsCrossSite']),
'src',
{}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['cross-site']);
});
}, 'sec-fetch-site - src - Same-Site -> Cross-Site, no attributes');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, ['httpsSameSite', 'httpsCrossSite']),
'srcset',
{}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['cross-site']);
});
}, 'sec-fetch-site - srcset - Same-Site -> Cross-Site, no attributes');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, ['httpsOrigin', 'httpOrigin', 'httpsOrigin']),
'src',
{}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-site');
assert_array_equals(headers['sec-fetch-site'], ['cross-site']);
});
}, 'sec-fetch-site - src - HTTPS downgrade-upgrade, no attributes');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, []),
'src',
{}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-mode');
assert_array_equals(headers['sec-fetch-mode'], ['no-cors']);
});
}, 'sec-fetch-mode - src - no attributes');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, []),
'src',
{"crossorigin": ""}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-mode');
assert_array_equals(headers['sec-fetch-mode'], ['cors']);
});
}, 'sec-fetch-mode - src - attributes: crossorigin');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, []),
'src',
{"crossorigin": "anonymous"}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-mode');
assert_array_equals(headers['sec-fetch-mode'], ['cors']);
});
}, 'sec-fetch-mode - src - attributes: crossorigin=anonymous');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, []),
'src',
{"crossorigin": "use-credentials"}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-mode');
assert_array_equals(headers['sec-fetch-mode'], ['cors']);
});
}, 'sec-fetch-mode - src - attributes: crossorigin=use-credentials');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, []),
'srcset',
{}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-mode');
assert_array_equals(headers['sec-fetch-mode'], ['no-cors']);
});
}, 'sec-fetch-mode - srcset - no attributes');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, []),
'srcset',
{"crossorigin": ""}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-mode');
assert_array_equals(headers['sec-fetch-mode'], ['cors']);
});
}, 'sec-fetch-mode - srcset - attributes: crossorigin');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, []),
'srcset',
{"crossorigin": "anonymous"}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-mode');
assert_array_equals(headers['sec-fetch-mode'], ['cors']);
});
}, 'sec-fetch-mode - srcset - attributes: crossorigin=anonymous');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, []),
'srcset',
{"crossorigin": "use-credentials"}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-mode');
assert_array_equals(headers['sec-fetch-mode'], ['cors']);
});
}, 'sec-fetch-mode - srcset - attributes: crossorigin=use-credentials');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, []),
'src',
{}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-dest');
assert_array_equals(headers['sec-fetch-dest'], ['image']);
});
}, 'sec-fetch-dest - src - no attributes');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, []),
'srcset',
{}
)
.then(() => retrieve(key))
.then((headers) => {
assert_own_property(headers, 'sec-fetch-dest');
assert_array_equals(headers['sec-fetch-dest'], ['image']);
});
}, 'sec-fetch-dest - srcset - no attributes');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, []),
'src',
{}
)
.then(() => retrieve(key))
.then((headers) => {
assert_not_own_property(headers, 'sec-fetch-user');
});
}, 'sec-fetch-user - src - no attributes');
promise_test(() => {
const key = '{{uuid()}}';
return induceRequest(
makeRequestURL(key, []),
'srcset',
{}
)
.then(() => retrieve(key))
.then((headers) => {
assert_not_own_property(headers, 'sec-fetch-user');
});
}, 'sec-fetch-user - srcset - no attributes');
</script>
</body>
</html>