diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/html/semantics/links/downloading-resources | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/html/semantics/links/downloading-resources')
21 files changed, 456 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/semantics/links/downloading-resources/header-origin-no-referrer-when-downgrade.html b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-origin-no-referrer-when-downgrade.html new file mode 100644 index 0000000000..466868dd7b --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-origin-no-referrer-when-downgrade.html @@ -0,0 +1,20 @@ +<!doctype html> +<html> + <head> + <meta charset="utf-8"> + <title>Ping attribute Origin Header No Referrer When Downgrade Policy</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <meta name='referrer' content='no-referrer-when-downgrade'> + </head> + <body> + <a id="a" href="#"> + <script src="/common/utils.js"></script> + <script src="/common/get-host-info.sub.js"></script> + <script src="/resources/chromium/enable-hyperlink-auditing.js"></script> + <script src="header-origin.js"></script> + <script> + testOriginHeader(self.location.origin); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/links/downloading-resources/header-origin-no-referrer.html b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-origin-no-referrer.html new file mode 100644 index 0000000000..cd7a1804f3 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-origin-no-referrer.html @@ -0,0 +1,20 @@ +<!doctype html> +<html> + <head> + <meta charset="utf-8"> + <title>Ping attribute Origin Header No Referrer Policy</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <meta name='referrer' content='no-referrer'> + </head> + <body> + <a id="a" href="#"> + <script src="/common/utils.js"></script> + <script src="/common/get-host-info.sub.js"></script> + <script src="/resources/chromium/enable-hyperlink-auditing.js"></script> + <script src="header-origin.js"></script> + <script> + testOriginHeader("null"); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/links/downloading-resources/header-origin-origin-when-cross-origin.html b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-origin-origin-when-cross-origin.html new file mode 100644 index 0000000000..98115aa653 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-origin-origin-when-cross-origin.html @@ -0,0 +1,20 @@ +<!doctype html> +<html> + <head> + <meta charset="utf-8"> + <title>Ping attribute Origin Header Origin When Cross Origin Policy</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <meta name='referrer' content='origin-when-cross-origin'> + </head> + <body> + <a id="a" href="#"> + <script src="/common/utils.js"></script> + <script src="/common/get-host-info.sub.js"></script> + <script src="/resources/chromium/enable-hyperlink-auditing.js"></script> + <script src="header-origin.js"></script> + <script> + testOriginHeader(self.location.origin); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/links/downloading-resources/header-origin-origin.html b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-origin-origin.html new file mode 100644 index 0000000000..194ca9d4ad --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-origin-origin.html @@ -0,0 +1,20 @@ +<!doctype html> +<html> + <head> + <meta charset="utf-8"> + <title>Ping attribute Origin Header Origin Policy</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <meta name='referrer' content='origin'> + </head> + <body> + <a id="a" href="#"> + <script src="/common/utils.js"></script> + <script src="/common/get-host-info.sub.js"></script> + <script src="/resources/chromium/enable-hyperlink-auditing.js"></script> + <script src="header-origin.js"></script> + <script> + testOriginHeader(self.location.origin); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/links/downloading-resources/header-origin-same-origin.html b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-origin-same-origin.html new file mode 100644 index 0000000000..eb86708d5b --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-origin-same-origin.html @@ -0,0 +1,20 @@ +<!doctype html> +<html> + <head> + <meta charset="utf-8"> + <title>Ping attribute Origin Header Same Origin Policy</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <meta name='referrer' content='same-origin'> + </head> + <body> + <a id="a" href="#"> + <script src="/common/utils.js"></script> + <script src="/common/get-host-info.sub.js"></script> + <script src="/resources/chromium/enable-hyperlink-auditing.js"></script> + <script src="header-origin.js"></script> + <script> + testOriginHeader(self.location.origin); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/links/downloading-resources/header-origin-strict-origin-when-cross-origin.html b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-origin-strict-origin-when-cross-origin.html new file mode 100644 index 0000000000..f6514ff2ae --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-origin-strict-origin-when-cross-origin.html @@ -0,0 +1,20 @@ +<!doctype html> +<html> + <head> + <meta charset="utf-8"> + <title>Ping attribute Origin Header Strict Origin When Cross Origin Policy</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <meta name='referrer' content='strict-origin-when-cross-origin'> + </head> + <body> + <a id="a" href="#"> + <script src="/common/utils.js"></script> + <script src="/common/get-host-info.sub.js"></script> + <script src="/resources/chromium/enable-hyperlink-auditing.js"></script> + <script src="header-origin.js"></script> + <script> + testOriginHeader(self.location.origin); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/links/downloading-resources/header-origin-strict-origin.html b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-origin-strict-origin.html new file mode 100644 index 0000000000..4aa311e833 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-origin-strict-origin.html @@ -0,0 +1,20 @@ +<!doctype html> +<html> + <head> + <meta charset="utf-8"> + <title>Ping attribute Origin Header Strict Origin Policy</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <meta name='referrer' content='strict-origin'> + </head> + <body> + <a id="a" href="#"> + <script src="/common/utils.js"></script> + <script src="/common/get-host-info.sub.js"></script> + <script src="/resources/chromium/enable-hyperlink-auditing.js"></script> + <script src="header-origin.js"></script> + <script> + testOriginHeader(self.location.origin); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/links/downloading-resources/header-origin-unsafe-url.html b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-origin-unsafe-url.html new file mode 100644 index 0000000000..59742404fe --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-origin-unsafe-url.html @@ -0,0 +1,20 @@ +<!doctype html> +<html> + <head> + <meta charset="utf-8"> + <title>Ping attribute Origin Header Unsafe Url Policy</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <meta name='referrer' content='unsafe-url'> + </head> + <body> + <a id="a" href="#"> + <script src="/common/utils.js"></script> + <script src="/common/get-host-info.sub.js"></script> + <script src="/resources/chromium/enable-hyperlink-auditing.js"></script> + <script src="header-origin.js"></script> + <script> + testOriginHeader(self.location.origin); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/links/downloading-resources/header-origin.html b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-origin.html new file mode 100644 index 0000000000..189e2e66d4 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-origin.html @@ -0,0 +1,19 @@ +<!doctype html> +<html> + <head> + <meta charset="utf-8"> + <title>Ping attribute Origin no Referrer Policy</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + </head> + <body> + <a id="a" href="#"> + <script src="/common/utils.js"></script> + <script src="/common/get-host-info.sub.js"></script> + <script src="/resources/chromium/enable-hyperlink-auditing.js"></script> + <script src="header-origin.js"></script> + <script> + testOriginHeader(self.location.origin); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/links/downloading-resources/header-origin.js b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-origin.js new file mode 100644 index 0000000000..acc62ef93b --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-origin.js @@ -0,0 +1,40 @@ +const RESOURCES_DIR = "/html/semantics/links/downloading-resources/resources/"; + +function testOriginHeader(expectedOrigin) { + var id = self.token(); + let testUrl = RESOURCES_DIR + "inspect-header.py?header=origin&cmd=put&id=" + id; + + promise_test(function(test) { + const anchor = document.getElementById("a"); + anchor.setAttribute("ping", testUrl); + anchor.click(); + return pollResult(id) .then(result => { + assert_equals(result, expectedOrigin, "Correct origin header result"); + }); + }, "Test origin header " + RESOURCES_DIR); +} + +// Sending a ping is an asynchronous and non-blocking request to a web server. +// We may have to create a poll loop to get result from server +function pollResult(id) { + let checkUrl = RESOURCES_DIR + "inspect-header.py?header=origin&cmd=get&id=" + id; + + return new Promise(resolve => { + function checkResult() { + fetch(checkUrl).then( + function(response) { + assert_equals(response.status, 200, "Inspect header response's status is 200"); + let result = response.headers.get("x-request-origin"); + + if (result != undefined) { + resolve(result); + } else { + step_timeout(checkResult.bind(this), 100); + } + }); + } + + checkResult(); + }); + +} diff --git a/testing/web-platform/tests/html/semantics/links/downloading-resources/header-referrer-no-referrer-when-downgrade.html b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-referrer-no-referrer-when-downgrade.html new file mode 100644 index 0000000000..96c19d1d0e --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-referrer-no-referrer-when-downgrade.html @@ -0,0 +1,20 @@ +<!doctype html> +<html> + <head> + <meta charset="utf-8"> + <title>Ping attribute Referrer Header No Referrer When Downgrade Policy</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <meta name='referrer' content='no-referrer-when-downgrade'> + </head> + <body> + <a id="a" href="#"> + <script src="/common/utils.js"></script> + <script src="/common/get-host-info.sub.js"></script> + <script src="/resources/chromium/enable-hyperlink-auditing.js"></script> + <script src="header-referrer.js"></script> + <script> + testReferrerHeader(""); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/links/downloading-resources/header-referrer-no-referrer.html b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-referrer-no-referrer.html new file mode 100644 index 0000000000..065063075c --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-referrer-no-referrer.html @@ -0,0 +1,20 @@ +<!doctype html> +<html> + <head> + <meta charset="utf-8"> + <title>Ping attribute Referrer Header No Referrer Policy</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <meta name='referrer' content='no-referrer'> + </head> + <body> + <a id="a" href="#"> + <script src="/common/utils.js"></script> + <script src="/common/get-host-info.sub.js"></script> + <script src="/resources/chromium/enable-hyperlink-auditing.js"></script> + <script src="header-referrer.js"></script> + <script> + testReferrerHeader(""); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/links/downloading-resources/header-referrer-origin-when-cross-origin.html b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-referrer-origin-when-cross-origin.html new file mode 100644 index 0000000000..f0394261a1 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-referrer-origin-when-cross-origin.html @@ -0,0 +1,20 @@ +<!doctype html> +<html> + <head> + <meta charset="utf-8"> + <title>Ping attribute Referrer Header Origin When Cross Origin Policy</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <meta name='referrer' content='origin-when-cross-origin'> + </head> + <body> + <a id="a" href="#"> + <script src="/common/utils.js"></script> + <script src="/common/get-host-info.sub.js"></script> + <script src="/resources/chromium/enable-hyperlink-auditing.js"></script> + <script src="header-referrer.js"></script> + <script> + testReferrerHeader(""); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/links/downloading-resources/header-referrer-origin.html b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-referrer-origin.html new file mode 100644 index 0000000000..bef435581c --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-referrer-origin.html @@ -0,0 +1,20 @@ +<!doctype html> +<html> + <head> + <meta charset="utf-8"> + <title>Ping attribute Referrer Header Origin Policy</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <meta name='referrer' content='origin'> + </head> + <body> + <a id="a" href="#"> + <script src="/common/utils.js"></script> + <script src="/common/get-host-info.sub.js"></script> + <script src="/resources/chromium/enable-hyperlink-auditing.js"></script> + <script src="header-referrer.js"></script> + <script> + testReferrerHeader(""); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/links/downloading-resources/header-referrer-same-origin.html b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-referrer-same-origin.html new file mode 100644 index 0000000000..19b2d022af --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-referrer-same-origin.html @@ -0,0 +1,20 @@ +<!doctype html> +<html> + <head> + <meta charset="utf-8"> + <title>Ping attribute Referrer Header Same Origin Policy</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <meta name='referrer' content='same-origin'> + </head> + <body> + <a id="a" href="#"> + <script src="/common/utils.js"></script> + <script src="/common/get-host-info.sub.js"></script> + <script src="/resources/chromium/enable-hyperlink-auditing.js"></script> + <script src="header-referrer.js"></script> + <script> + testReferrerHeader(""); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/links/downloading-resources/header-referrer-strict-origin-when-cross-origin.html b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-referrer-strict-origin-when-cross-origin.html new file mode 100644 index 0000000000..95132eee5c --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-referrer-strict-origin-when-cross-origin.html @@ -0,0 +1,20 @@ +<!doctype html> +<html> + <head> + <meta charset="utf-8"> + <title>Ping attribute Referrer Header Strict Origin When Cross Origin Policy</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <meta name='referrer' content='strict-origin-when-cross-origin'> + </head> + <body> + <a id="a" href="#"> + <script src="/common/utils.js"></script> + <script src="/common/get-host-info.sub.js"></script> + <script src="/resources/chromium/enable-hyperlink-auditing.js"></script> + <script src="header-referrer.js"></script> + <script> + testReferrerHeader(""); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/links/downloading-resources/header-referrer-strict-origin.html b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-referrer-strict-origin.html new file mode 100644 index 0000000000..e2678e8de8 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-referrer-strict-origin.html @@ -0,0 +1,20 @@ +<!doctype html> +<html> + <head> + <meta charset="utf-8"> + <title>Ping attribute Referrer Header Strict Origin Policy</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <meta name='referrer' content='strict-origin'> + </head> + <body> + <a id="a" href="#"> + <script src="/common/utils.js"></script> + <script src="/common/get-host-info.sub.js"></script> + <script src="/resources/chromium/enable-hyperlink-auditing.js"></script> + <script src="header-referrer.js"></script> + <script> + testReferrerHeader(""); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/links/downloading-resources/header-referrer-unsafe-url.html b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-referrer-unsafe-url.html new file mode 100644 index 0000000000..cc3d1dde86 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-referrer-unsafe-url.html @@ -0,0 +1,20 @@ +<!doctype html> +<html> + <head> + <meta charset="utf-8"> + <title>Ping attribute Referrer Header Unsafe Url Policy</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + <meta name='referrer' content='unsafe-url'> + </head> + <body> + <a id="a" href="#"> + <script src="/common/utils.js"></script> + <script src="/common/get-host-info.sub.js"></script> + <script src="/resources/chromium/enable-hyperlink-auditing.js"></script> + <script src="header-referrer.js"></script> + <script> + testReferrerHeader(""); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/links/downloading-resources/header-referrer.html b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-referrer.html new file mode 100644 index 0000000000..5e2d136443 --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-referrer.html @@ -0,0 +1,19 @@ +<!doctype html> +<html> + <head> + <meta charset="utf-8"> + <title>Ping attribute no Referrer Header given</title> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + </head> + <body> + <a id="a" href="#"> + <script src="/common/utils.js"></script> + <script src="/common/get-host-info.sub.js"></script> + <script src="/resources/chromium/enable-hyperlink-auditing.js"></script> + <script src="header-referrer.js"></script> + <script> + testReferrerHeader(""); + </script> + </body> +</html> diff --git a/testing/web-platform/tests/html/semantics/links/downloading-resources/header-referrer.js b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-referrer.js new file mode 100644 index 0000000000..818649fbff --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/downloading-resources/header-referrer.js @@ -0,0 +1,40 @@ +const RESOURCES_DIR = "/html/semantics/links/downloading-resources/resources/"; + +function testReferrerHeader(expectedReferrer) { + let id = self.token(); + let testUrl = RESOURCES_DIR + "inspect-header.py?header=referer&cmd=put&id=" + id; + + promise_test(function(test) { + const anchor = document.getElementById("a"); + anchor.setAttribute("ping", testUrl); + anchor.click(); + return pollResult(id) .then(result => { + assert_equals(result, expectedReferrer, "Correct referrer header result"); + }); + }, "Test referer header " + RESOURCES_DIR); +} + +// Sending a ping is an asynchronous and non-blocking request to a web server. +// We may have to create a poll loop to get result from server +function pollResult(id) { + let checkUrl = RESOURCES_DIR + "inspect-header.py?header=referer&cmd=get&id=" + id; + + return new Promise(resolve => { + function checkResult() { + fetch(checkUrl).then( + function(response) { + assert_equals(response.status, 200, "Inspect header response's status is 200"); + let result = response.headers.get("x-request-referer"); + + if (result != undefined) { + resolve(result); + } else { + step_timeout(checkResult.bind(this), 100); + } + }); + } + + checkResult(); + }); + +} diff --git a/testing/web-platform/tests/html/semantics/links/downloading-resources/resources/inspect-header.py b/testing/web-platform/tests/html/semantics/links/downloading-resources/resources/inspect-header.py new file mode 100644 index 0000000000..2c68e475ff --- /dev/null +++ b/testing/web-platform/tests/html/semantics/links/downloading-resources/resources/inspect-header.py @@ -0,0 +1,18 @@ +def main(request, response): + headers = [(b"Content-Type", b"text/plain")] + command = request.GET.first(b"cmd").lower() + test_id = request.GET.first(b"id") + header = request.GET.first(b"header") + if command == b"put": + request.server.stash.put(test_id, request.headers.get(header, b"")) + + elif command == b"get": + stashed_header = request.server.stash.take(test_id) + if stashed_header is not None: + headers.append((b"x-request-" + header, stashed_header)) + + else: + response.set_error(400, u"Bad Command") + return b"ERROR: Bad Command!" + + return headers, b"" |