diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/referrer-policy/css-integration/image | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/referrer-policy/css-integration/image')
8 files changed, 337 insertions, 0 deletions
diff --git a/testing/web-platform/tests/referrer-policy/css-integration/image/external-import-stylesheet.html b/testing/web-platform/tests/referrer-policy/css-integration/image/external-import-stylesheet.html new file mode 100644 index 0000000000..15aae6f824 --- /dev/null +++ b/testing/web-platform/tests/referrer-policy/css-integration/image/external-import-stylesheet.html @@ -0,0 +1,51 @@ +<!DOCTYPE html> +<html> + <head> + <title>CSS integration - image from imported stylesheet (external)</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/utils.js"></script> + <!-- Common global functions for referrer-policy tests. --> + <script src="/common/security-features/resources/common.sub.js"></script> + <meta name="referrer" content="never"> + </head> + <body> + <p>Check that resources from imported stylesheets (loaded from external + stylesheets) are loaded with the referrer and referrer policy from the + external stylesheet.</p> + + <div class="styled"></div> + + <script> + promise_test(function(css_test) { + var id = token(); + var css_url = location.protocol + "//www1." + location.hostname + ":" + location.port + + "/common/security-features/subresource/stylesheet.py?id=" + id + + "&import-rule" + "&type=image"; + var url_prefix = location.protocol + "//" + location.hostname + ":" + location.port; + var css_referrer = url_prefix + + "/common/security-features/subresource/stylesheet.py?id=" + id + + "&type=image"; + var img_url = url_prefix + "/common/security-features/subresource/image.py" + + "?id=" + id + "&report-headers"; + + return new Promise(resolve => { + var link = document.createElement("link"); + link.href = css_url; + link.rel = "stylesheet"; + link.onload = resolve; + document.head.appendChild(link); + }) + .then(() => timeoutPromise(css_test, 1000)) + .then(() => requestViaXhr(img_url)) + .then(function(message) { + assert_own_property(message, "headers"); + assert_own_property(message, "referrer"); + assert_equals(message.referrer, css_referrer); + }); + }, "Image from imported stylesheet (external)."); + </script> + + <div id="log"></div> + </body> +</html> diff --git a/testing/web-platform/tests/referrer-policy/css-integration/image/external-stylesheet.html b/testing/web-platform/tests/referrer-policy/css-integration/image/external-stylesheet.html new file mode 100644 index 0000000000..eed146dac0 --- /dev/null +++ b/testing/web-platform/tests/referrer-policy/css-integration/image/external-stylesheet.html @@ -0,0 +1,45 @@ +<!DOCTYPE html> +<html> + <head> + <title>CSS integration - image from external stylesheet</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/utils.js"></script> + <!-- Common global functions for referrer-policy tests. --> + <script src="/common/security-features/resources/common.sub.js"></script> + <meta name="referrer" content="never"> + </head> + <body> + <p>Check that resources from external stylesheets are loaded with + the referrer and referrer policy from the external stylesheet.</p> + + <div class="styled"></div> + + <script> + promise_test(function(css_test) { + var id = token(); + var url_prefix = location.protocol + "//www1." + location.hostname + ":" + location.port; + var css_url = url_prefix + "/common/security-features/subresource/stylesheet.py?id=" + id; + var img_url = url_prefix + "/common/security-features/subresource/image.py" + + "?id=" + id + "&report-headers"; + + return new Promise(resolve => { + var link = document.createElement("link"); + link.href = css_url; + link.rel = "stylesheet"; + link.onload = resolve; + document.head.appendChild(link); + }) + .then(() => timeoutPromise(css_test, 1000)) + .then(() => requestViaXhr(img_url)) + .then(function(message) { + assert_own_property(message, "headers"); + assert_own_property(message, "referrer"); + assert_equals(message.referrer, css_url); + }); + }, "Image from external stylesheet."); + </script> + + <div id="log"></div> + </body> +</html> diff --git a/testing/web-platform/tests/referrer-policy/css-integration/image/inline-style-with-differentorigin-base-tag.tentative.html b/testing/web-platform/tests/referrer-policy/css-integration/image/inline-style-with-differentorigin-base-tag.tentative.html new file mode 100644 index 0000000000..091afd832a --- /dev/null +++ b/testing/web-platform/tests/referrer-policy/css-integration/image/inline-style-with-differentorigin-base-tag.tentative.html @@ -0,0 +1,45 @@ +<!DOCTYPE html> +<title>CSS integration - image from inline style from document with base tag</title> +<link rel="help" href="https://crbug.com/1158645" /> + +<head> + <meta name="referrer" content="origin"> +</head> + +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/utils.js"></script> +<!-- Common global functions for referrer-policy tests. --> +<script src="/common/security-features/resources/common.sub.js"></script> + +<!-- This has to follow the <script> tags, or it will make the js files fail to load. --> +<base href="http://other-site.example" /> + +<p>Check that resources from inline styles are loaded with + the referrer and referrer policy from the document and, in + particular, not with the different base URL set in the base tag.</p> + +<div class="styled"></div> + +<script> + 'use strict'; + promise_test(function(css_test) { + var id = token(); + var css_url = location.protocol + "//www1." + location.hostname + ":" + location.port + "/common/security-features/subresource/image.py" + "?id=" + id; + var img_url = css_url + "&report-headers"; + + var div = document.querySelector("div.styled"); + div.style = "content:url(" + css_url + ")"; + return timeoutPromise(css_test, 1000) + .then(() => requestViaXhr(img_url)) + .then(function(message) { + assert_own_property(message, "headers"); + assert_own_property(message, "referrer"); + assert_equals(message.referrer, location.origin + "/"); + }); + }, "Image from inline styles."); +</script> + +<div id="log"></div> + +</html> diff --git a/testing/web-platform/tests/referrer-policy/css-integration/image/inline-style.html b/testing/web-platform/tests/referrer-policy/css-integration/image/inline-style.html new file mode 100644 index 0000000000..1e94b3df2c --- /dev/null +++ b/testing/web-platform/tests/referrer-policy/css-integration/image/inline-style.html @@ -0,0 +1,38 @@ +<!DOCTYPE html> +<html> + <head> + <title>CSS integration - image from inline style</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/utils.js"></script> + <!-- Common global functions for referrer-policy tests. --> + <script src="/common/security-features/resources/common.sub.js"></script> + <meta name="referrer" content="origin"> + </head> + <body> + <p>Check that resources from inline styles are loaded with + the referrer and referrer policy from the document.</p> + + <div class="styled"></div> + + <script> + promise_test(function(css_test) { + var id = token(); + var css_url = location.protocol + "//www1." + location.hostname + ":" + location.port + "/common/security-features/subresource/image.py" + "?id=" + id; + var img_url = css_url + "&report-headers"; + + var div = document.querySelector("div.styled"); + div.style = "content:url(" + css_url + ")"; + return timeoutPromise(css_test, 1000) + .then(() => requestViaXhr(img_url)) + .then(function(message) { + assert_own_property(message, "headers"); + assert_own_property(message, "referrer"); + assert_equals(message.referrer, location.origin + "/"); + }); + }, "Image from inline styles."); + </script> + + <div id="log"></div> + </body> +</html> diff --git a/testing/web-platform/tests/referrer-policy/css-integration/image/internal-import-stylesheet.html b/testing/web-platform/tests/referrer-policy/css-integration/image/internal-import-stylesheet.html new file mode 100644 index 0000000000..75ca554381 --- /dev/null +++ b/testing/web-platform/tests/referrer-policy/css-integration/image/internal-import-stylesheet.html @@ -0,0 +1,42 @@ +<!DOCTYPE html> +<html> + <head> + <title>CSS integration - image from imported stylesheet (internal)</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/utils.js"></script> + <!-- Common global functions for referrer-policy tests. --> + <script src="/common/security-features/resources/common.sub.js"></script> + <meta name="referrer" content="origin"> + </head> + <body> + <p>Check that resources from stylesheets (imported from internal + stylesheets) are loaded with the referrer and referrer policy from the + document.</p> + + <div class="styled"></div> + + <script> + promise_test(function(css_test) { + var id = token(); + var url_prefix = location.protocol + "//www1." + location.hostname + ":" + location.port + "/common/security-features/subresource/"; + var css_url = url_prefix + "stylesheet.py?id=" + id; + var img_url = url_prefix + "image.py?report-headers&id=" + id; + + var style = document.createElement("style"); + style.type = 'text/css'; + style.appendChild(document.createTextNode("@import url('" + css_url + "');")); + document.head.appendChild(style); + return timeoutPromise(css_test, 1000) + .then(() => requestViaXhr(img_url)) + .then(function(message) { + assert_own_property(message, "headers"); + assert_own_property(message, "referrer"); + assert_equals(message.referrer, css_url); + }); + }, "Image from imported stylesheet (internal)."); + </script> + + <div id="log"></div> + </body> +</html> diff --git a/testing/web-platform/tests/referrer-policy/css-integration/image/internal-stylesheet.html b/testing/web-platform/tests/referrer-policy/css-integration/image/internal-stylesheet.html new file mode 100644 index 0000000000..caef85329f --- /dev/null +++ b/testing/web-platform/tests/referrer-policy/css-integration/image/internal-stylesheet.html @@ -0,0 +1,40 @@ +<!DOCTYPE html> +<html> + <head> + <title>CSS integration - image from internal stylesheet</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/utils.js"></script> + <!-- Common global functions for referrer-policy tests. --> + <script src="/common/security-features/resources/common.sub.js"></script> + <meta name="referrer" content="origin"> + </head> + <body> + <p>Check that resources from internal stylesheets are loaded with + the referrer and referrer policy from the document.</p> + + <div class="styled"></div> + + <script> + promise_test(function(css_test) { + var id = token(); + var css_url = location.protocol + "//www1." + location.hostname + ":" + location.port + "/common/security-features/subresource/image.py" + "?id=" + id; + var img_url = css_url + "&report-headers"; + + var style = document.createElement("style"); + style.type = 'text/css'; + style.appendChild(document.createTextNode("div.styled::before { content:url(" + css_url + ")}")); + document.head.appendChild(style); + return timeoutPromise(css_test, 1000) + .then(() => requestViaXhr(img_url)) + .then(function(message) { + assert_own_property(message, "headers"); + assert_own_property(message, "referrer"); + assert_equals(message.referrer, location.origin + "/"); + }); + }, "Image from internal stylesheet."); + </script> + + <div id="log"></div> + </body> +</html> diff --git a/testing/web-platform/tests/referrer-policy/css-integration/image/presentation-attribute.html b/testing/web-platform/tests/referrer-policy/css-integration/image/presentation-attribute.html new file mode 100644 index 0000000000..df5593b218 --- /dev/null +++ b/testing/web-platform/tests/referrer-policy/css-integration/image/presentation-attribute.html @@ -0,0 +1,35 @@ +<!DOCTYPE html> +<html> + <head> + <title>CSS integration - image from presentation attribute</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/utils.js"></script> + <!-- Common global functions for referrer-policy tests. --> + <script src="/common/security-features/resources/common.sub.js"></script> + <meta name="referrer" content="origin"> + </head> + <body> + <p>Check that resources from presentation attributes are loaded with + the referrer and referrer policy from the document.</p> + + <script> + promise_test(function(css_test) { + var id = token(); + var css_url = location.protocol + "//www1." + location.hostname + ":" + location.port + "/common/security-features/subresource/image.py" + "?id=" + id; + var img_url = css_url + "&report-headers"; + + document.body.background = css_url; + return timeoutPromise(css_test, 1000) + .then(() => requestViaXhr(img_url)) + .then(function(message) { + assert_own_property(message, "headers"); + assert_own_property(message, "referrer"); + assert_equals(message.referrer, location.origin + "/"); + }); + }, "Image from presentation attributes."); + </script> + + <div id="log"></div> + </body> +</html> diff --git a/testing/web-platform/tests/referrer-policy/css-integration/image/processing-instruction.html b/testing/web-platform/tests/referrer-policy/css-integration/image/processing-instruction.html new file mode 100644 index 0000000000..5d88fcbb6d --- /dev/null +++ b/testing/web-platform/tests/referrer-policy/css-integration/image/processing-instruction.html @@ -0,0 +1,41 @@ +<!DOCTYPE html> +<html> + <head> + <title>CSS integration - image from external stylesheet inserted via a ProcessingInstruction</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <script src="/common/utils.js"></script> + <!-- Common global functions for referrer-policy tests. --> + <script src="/common/security-features/resources/common.sub.js"></script> + <meta name="referrer" content="never"> + </head> + <body> + <p>Check that resources from external stylesheets (referenced from a + ProcessingInstruction) are loaded with the referrer and referrer policy + from the external stylesheet.</p> + + <div class="styled"></div> + + <script> + promise_test(function(css_test) { + var id = token(); + var url_prefix = location.protocol + "//www1." + location.hostname + ":" + location.port; + var css_url = url_prefix + "/common/security-features/subresource/stylesheet.py?id=" + id; + var img_url = url_prefix + "/common/security-features/subresource/image.py" + + "?id=" + id + "&report-headers"; + + var processingInstruction = document.createProcessingInstruction("xml-stylesheet", "href=\"" + css_url + "\" type=\"text/css\""); + document.insertBefore(processingInstruction, document.firstChild); + return timeoutPromise(css_test, 1000) + .then(() => requestViaXhr(img_url)) + .then(function(message) { + assert_own_property(message, "headers"); + assert_own_property(message, "referrer"); + assert_equals(message.referrer, css_url); + }); + }, "Image from external stylesheet (from ProcessingInstruction)."); + </script> + + <div id="log"></div> + </body> +</html> |