Source code
Revision control
Copy as Markdown
Other Tools
<!DOCTYPE html>
<script src="/common/dispatcher/dispatcher.js" nonce="abc"></script>
<script src="utils.sub.js" nonce="abc"></script>
<script nonce="abc">
// For a given string `str` that is escaped by WPT's `.sub.html` or
// `pipe=sub(html)` functionality, return the original unescaped string.
//
// Concretely, for `str` as the result of `html.escape(x, quote=True)`,
// return the original unescaped string `x`.
// See `/tools/wptserve/wptserve/pipes.py` and
//
function reverse_html_escape(str) {
str = str.replaceAll('<', '<');
str = str.replaceAll('>', '>');
str = str.replaceAll('"', '"');
str = str.replaceAll(''', "'");
str = str.replaceAll('&', '&');
return str;
}
// (accessed via iterable),
// - The keys are lower-cased header names, and
// - The entries are removed when the corresponding headers are non-existent.
window.requestHeaders = {
"purpose": "{{header_or_default(Purpose, NONEXISTENT)}}",
"sec-purpose": "{{header_or_default(Sec-Purpose, NONEXISTENT)}}",
"referer": "{{header_or_default(Referer, NONEXISTENT)}}",
"sec-fetch-dest": "{{header_or_default(Sec-Fetch-Dest, NONEXISTENT)}}",
"sec-fetch-mode": "{{header_or_default(Sec-Fetch-Mode, NONEXISTENT)}}",
// Convert to the raw string to avoid backslashes from being processed as
// escape sequences.
// TODO(crbug.com/404573971): Remove `header_or_default` to reflect
// `__no_tags__` properly.
sec_speculation_tags:
String.raw`{{header_or_default(Sec-Speculation-Tags, __no_tags__)}}`,
};
Object.keys(requestHeaders).forEach(key => {
if (requestHeaders[key] === "NONEXISTENT") {
delete requestHeaders[key];
} else {
requestHeaders[key] = reverse_html_escape(requestHeaders[key]);
}
});
// The fetch request's URL sent to the server.
window.requestUrl = reverse_html_escape(
"{{location[server]}}{{location[path]}}{{location[query]}}");
const uuid = new URLSearchParams(location.search).get('uuid');
window.executor = new Executor(uuid);
</script>