diff options
Diffstat (limited to 'testing/web-platform/tests/referrer-policy/generic/iframe-src-change.html')
-rw-r--r-- | testing/web-platform/tests/referrer-policy/generic/iframe-src-change.html | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/testing/web-platform/tests/referrer-policy/generic/iframe-src-change.html b/testing/web-platform/tests/referrer-policy/generic/iframe-src-change.html new file mode 100644 index 0000000000..15202a76a1 --- /dev/null +++ b/testing/web-platform/tests/referrer-policy/generic/iframe-src-change.html @@ -0,0 +1,37 @@ +<!DOCTYPE html> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<body> +<script> +function nextMessage() { + return new Promise((resolve, reject) => { + window.addEventListener('message', e => resolve(e.data), {once: true}); + }); +} + +promise_test(async () => { + let iframe = document.createElement('iframe'); + iframe.setAttribute('src', '/common/security-features/subresource/document.py?first') + iframe.setAttribute('referrerpolicy', 'no-referrer'); + document.body.appendChild(iframe); + + try { + { + let {referrer: documentReferrer, headers: {referer: httpReferrer}} = await nextMessage(); + assert_equals(httpReferrer, undefined, 'expected no HTTP Referer header on initial load'); + assert_equals(documentReferrer, undefined, 'expected no document.referrer on initial load'); + } + + iframe.setAttribute('src', '/common/security-features/subresource/document.py?second'); + + { + let {referrer: documentReferrer, headers: {referer: httpReferrer}} = await nextMessage(); + assert_equals(httpReferrer, undefined, 'expected no HTTP Referer header on src change'); + assert_equals(documentReferrer, undefined, 'expected no document.referrer on src change'); + } + } finally { + iframe.remove(); + } +}, "Checks that referrerpolicy is respected when an iframe's src changes."); +</script> +</body> |