summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/referrer-policy/css-integration/image
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/referrer-policy/css-integration/image')
-rw-r--r--testing/web-platform/tests/referrer-policy/css-integration/image/external-import-stylesheet.html51
-rw-r--r--testing/web-platform/tests/referrer-policy/css-integration/image/external-stylesheet.html45
-rw-r--r--testing/web-platform/tests/referrer-policy/css-integration/image/inline-style-with-differentorigin-base-tag.tentative.html45
-rw-r--r--testing/web-platform/tests/referrer-policy/css-integration/image/inline-style.html38
-rw-r--r--testing/web-platform/tests/referrer-policy/css-integration/image/internal-import-stylesheet.html42
-rw-r--r--testing/web-platform/tests/referrer-policy/css-integration/image/internal-stylesheet.html40
-rw-r--r--testing/web-platform/tests/referrer-policy/css-integration/image/presentation-attribute.html35
-rw-r--r--testing/web-platform/tests/referrer-policy/css-integration/image/processing-instruction.html41
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>