Automatic update from web-platform-tests Mark html/semantics/links/hyperlink-auditing/headers.optional.html as slow. Bug: 40884324 Change-Id: If96772942d6980f8fcdd940118107bbd847e07f5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7274645 Commit-Queue: Joey Arhar <jarhar@chromium.org> Reviewed-by: Joey Arhar <jarhar@chromium.org> Auto-Submit: David Baron <dbaron@chromium.org> Cr-Commit-Position: refs/heads/main@{#1560840} -- wpt-commits: c00aa4d31bcaf70b98d4483ca371e19c191a1b63 wpt-pr: 56872
57 lines
1.5 KiB
HTML
57 lines
1.5 KiB
HTML
<!DOCTYPE html>
|
|
<meta charset="utf-8">
|
|
<meta name=timeout content=long>
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<script src="/common/utils.js"></script>
|
|
|
|
<iframe id="i" src="/common/blank.html"></iframe>
|
|
|
|
<!-- Test is optional because hyperlink auditing is optional. -->
|
|
|
|
<script>
|
|
promise_test(async t => {
|
|
await new Promise(resolve => window.onload = resolve);
|
|
|
|
const id = token();
|
|
|
|
const el = document.createElement("a");
|
|
el.ping = new URL(`resources/stash-headers.py?id=${id}`, location.href); // this will be a POST
|
|
el.href = "/common/blank.html?1";
|
|
|
|
i.contentDocument.body.append(el);
|
|
el.click();
|
|
|
|
let headers;
|
|
await pollForConditionFunc(t, async () => {
|
|
const res = await fetch(el.ping); // this will be a GET
|
|
const json = await res.json();
|
|
|
|
if (json !== "no headers yet") {
|
|
headers = json;
|
|
return true;
|
|
}
|
|
return false;
|
|
});
|
|
|
|
assert_equals(headers["content-type"], "text/ping", "content-type");
|
|
assert_equals(headers["ping-from"], i.src, "ping-from");
|
|
assert_equals(headers["ping-to"], el.href, "ping-to");
|
|
});
|
|
|
|
async function pollForConditionFunc(t, func, timeout = 3000, interval = 100) {
|
|
let remaining = Math.ceil(timeout / interval);
|
|
|
|
while (remaining > 0) {
|
|
--remaining;
|
|
await new Promise(resolve => t.step_timeout(resolve, interval));
|
|
|
|
if (await func()) {
|
|
return;
|
|
}
|
|
}
|
|
|
|
assert_true(false, "Condition never became true");
|
|
}
|
|
</script>
|