summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/https-upgrades
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/https-upgrades')
-rw-r--r--testing/web-platform/tests/https-upgrades/README19
-rw-r--r--testing/web-platform/tests/https-upgrades/resources/pass-with-referrer.html13
-rw-r--r--testing/web-platform/tests/https-upgrades/resources/pass.html10
-rw-r--r--testing/web-platform/tests/https-upgrades/tentative/fallback.sub.html24
-rw-r--r--testing/web-platform/tests/https-upgrades/tentative/http-redirecting-to-http-redirecting-to-http.https.sub.html30
-rw-r--r--testing/web-platform/tests/https-upgrades/tentative/http-redirecting-to-http.https.sub.html29
-rw-r--r--testing/web-platform/tests/https-upgrades/tentative/http-redirecting-to-https.https.sub.html29
-rw-r--r--testing/web-platform/tests/https-upgrades/tentative/referrer.https.sub.html29
-rw-r--r--testing/web-platform/tests/https-upgrades/tentative/upgrade.https.sub.html24
9 files changed, 207 insertions, 0 deletions
diff --git a/testing/web-platform/tests/https-upgrades/README b/testing/web-platform/tests/https-upgrades/README
new file mode 100644
index 0000000000..e213900f3a
--- /dev/null
+++ b/testing/web-platform/tests/https-upgrades/README
@@ -0,0 +1,19 @@
+This directory tests conformance to HTTPS Upgrading feature of Fetch spec.
+HTTPS Upgrading automatically upgrades main frame HTTP navigations to HTTPS and
+falls back to the original HTTP URL if the upgraded HTTPS URL isn't available.
+
+In practice, HTTPS Upgrading won't work properly with URLs with non-default
+ports. This is because the upgrade logic can't guess the HTTPS port and has to
+use the same non-default port number for the upgraded HTTPS URL as the HTTP URL.
+In other words, upgrading http://example.com:8123 to https://example.com:8123
+won't work because the server can't serve both http and https on the same port.
+
+The tests in this directory rely on this fact:
+- If HTTPS Upgrading is enabled, http://{{host}}:{{https-port}} will be upgraded
+ to https://{{host}}:{{https-port}} and load properly.
+- Otherwise, http://{{host}}:{{https-port}} will remain unchanged and won't
+ load, since the server serves http URLs on {{http-port}} instead.
+
+Therefore, the simplest way to run these tests is through
+[wpt.live](http://wpt.live/https-upgrades) which serves the files over default
+ports.
diff --git a/testing/web-platform/tests/https-upgrades/resources/pass-with-referrer.html b/testing/web-platform/tests/https-upgrades/resources/pass-with-referrer.html
new file mode 100644
index 0000000000..be978c16dc
--- /dev/null
+++ b/testing/web-platform/tests/https-upgrades/resources/pass-with-referrer.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<html>
+ <body>
+ <script>
+ window.onload = (event) => {
+ window.opener.postMessage({
+ 'pass': true,
+ 'referrer': document.referrer},
+ '*');
+ };
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/https-upgrades/resources/pass.html b/testing/web-platform/tests/https-upgrades/resources/pass.html
new file mode 100644
index 0000000000..5c7ca343e9
--- /dev/null
+++ b/testing/web-platform/tests/https-upgrades/resources/pass.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+ <body>
+ <script>
+ window.onload = (event) => {
+ window.opener.postMessage('pass', '*');
+ };
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/https-upgrades/tentative/fallback.sub.html b/testing/web-platform/tests/https-upgrades/tentative/fallback.sub.html
new file mode 100644
index 0000000000..8fdf0dc836
--- /dev/null
+++ b/testing/web-platform/tests/https-upgrades/tentative/fallback.sub.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>HTTPS Upgrades: Fallback.</title>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="/common/get-host-info.sub.js"></script>
+
+ </head>
+ <body>
+ <script>
+ setup({ single_test: true });
+ // If HTTPS upgrades are enabled, this will fail to load since this test is http only,
+ // and should load properly once a fallback is triggered.
+ var url = new URL("http://{{host}}:{{ports[http][0]}}/https-upgrades/resources/pass.html")
+ window.onmessage = function(event) {
+ if (event.data === "pass") {
+ done();
+ }
+ }
+ win = window.open(url)
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/https-upgrades/tentative/http-redirecting-to-http-redirecting-to-http.https.sub.html b/testing/web-platform/tests/https-upgrades/tentative/http-redirecting-to-http-redirecting-to-http.https.sub.html
new file mode 100644
index 0000000000..96892c95a9
--- /dev/null
+++ b/testing/web-platform/tests/https-upgrades/tentative/http-redirecting-to-http-redirecting-to-http.https.sub.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>HTTPS Upgrades: HTTP URL redirecting to HTTP URL redirecting to HTTP URL</title>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="/common/get-host-info.sub.js"></script>
+
+ </head>
+ <body>
+ <script>
+ setup({ single_test: true });
+ // Loads an HTTP URL that redirects to an HTTP URL that redirects to
+ // another HTTP URL. HTTPS upgrading should upgrade all URLs to HTTPS.
+ //
+ // HTTPS upgrading doesn't change custom ports, so this will load
+ // correctly if an HTTPS upgrade is performed, and will fail to load
+ // otherwise (since the port will be wrong for http).
+ var final_url = "http://{{host}}:{{ports[https][0]}}/https-upgrades/resources/pass.html";
+ var middle_url = "http://{{host}}:{{ports[https][0]}}/fetch/api/resources/redirect.py?location=" + final_url;
+ var url = new URL("http://{{host}}:{{ports[https][0]}}/fetch/api/resources/redirect.py?location=" + middle_url);
+ window.onmessage = function(event) {
+ if (event.data === "pass") {
+ done();
+ }
+ }
+ win = window.open(url)
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/https-upgrades/tentative/http-redirecting-to-http.https.sub.html b/testing/web-platform/tests/https-upgrades/tentative/http-redirecting-to-http.https.sub.html
new file mode 100644
index 0000000000..24d50a71bc
--- /dev/null
+++ b/testing/web-platform/tests/https-upgrades/tentative/http-redirecting-to-http.https.sub.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>HTTPS Upgrades: HTTP URL redirecting to HTTP</title>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="/common/get-host-info.sub.js"></script>
+
+ </head>
+ <body>
+ <script>
+ setup({ single_test: true });
+ // Loads an HTTP URL that redirects to another HTTP URL. HTTPS upgrading
+ // should upgrade both the initial URL and the redirected URL to HTTPS.
+ //
+ // HTTPS upgrading doesn't change custom ports, so this will load
+ // correctly if an HTTPS upgrade is performed, and will fail to load
+ // otherwise (since the port will be wrong for http).
+ var final_url = "http://{{host}}:{{ports[https][0]}}/https-upgrades/resources/pass.html";
+ var url = new URL("http://{{host}}:{{ports[https][0]}}/fetch/api/resources/redirect.py?location=" + final_url);
+ window.onmessage = function(event) {
+ if (event.data === "pass") {
+ done();
+ }
+ }
+ win = window.open(url)
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/https-upgrades/tentative/http-redirecting-to-https.https.sub.html b/testing/web-platform/tests/https-upgrades/tentative/http-redirecting-to-https.https.sub.html
new file mode 100644
index 0000000000..13a7f1698f
--- /dev/null
+++ b/testing/web-platform/tests/https-upgrades/tentative/http-redirecting-to-https.https.sub.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>HTTPS Upgrades: HTTP URL redirecting to HTTPS</title>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="/common/get-host-info.sub.js"></script>
+
+ </head>
+ <body>
+ <script>
+ setup({ single_test: true });
+ // Loads an HTTP URL that redirects to an HTTPS URL. HTTPS upgrading
+ // should upgrade the initial URL.
+ //
+ // HTTPS upgrading doesn't change custom ports, so this will load
+ // correctly if an HTTPS upgrade is performed, and will fail to load
+ // otherwise (since the port will be wrong for http).
+ var final_url = "https://{{host}}:{{ports[https][0]}}/https-upgrades/resources/pass.html";
+ var url = new URL("http://{{host}}:{{ports[https][0]}}/fetch/api/resources/redirect.py?location=" + final_url);
+ window.onmessage = function(event) {
+ if (event.data === "pass") {
+ done();
+ }
+ }
+ win = window.open(url)
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/https-upgrades/tentative/referrer.https.sub.html b/testing/web-platform/tests/https-upgrades/tentative/referrer.https.sub.html
new file mode 100644
index 0000000000..3cd83ba561
--- /dev/null
+++ b/testing/web-platform/tests/https-upgrades/tentative/referrer.https.sub.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>HTTPS Upgrades: Upgrade.</title>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="/common/get-host-info.sub.js"></script>
+
+ <meta name="referrer" content="no-referrer-when-downgrade" />
+
+ </head>
+ <body>
+ <script>
+ setup({ single_test: true });
+ // When the referrer policy is no-referrer-when-downgrade, HTTPS upgrades should not drop
+ // the referrer upon navigating to an HTTP URL if the upgrade is successful.
+
+ // HTTPS upgrades don't change custom ports, so this will load correctly if an HTTPS upgrade is performed,
+ // and will fail to load otherwise (since the port will be wrong for http).
+ var url = new URL("http://{{host}}:{{ports[https][0]}}/https-upgrades/resources/pass-with-referrer.html")
+ window.onmessage = function(event) {
+ if (event.data['pass'] && event.data['referrer'] == document.location.href) {
+ done();
+ }
+ }
+ win = window.open(url)
+ </script>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/https-upgrades/tentative/upgrade.https.sub.html b/testing/web-platform/tests/https-upgrades/tentative/upgrade.https.sub.html
new file mode 100644
index 0000000000..71a1fe1dde
--- /dev/null
+++ b/testing/web-platform/tests/https-upgrades/tentative/upgrade.https.sub.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>HTTPS Upgrades: Upgrade.</title>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="/common/get-host-info.sub.js"></script>
+
+ </head>
+ <body>
+ <script>
+ setup({ single_test: true });
+ // HTTPS upgrades don't change custom ports, so this will load correctly if an HTTPS upgrade is performed,
+ // and will fail to load otherwise (since the port will be wrong for http).
+ var url = new URL("http://{{host}}:{{ports[https][0]}}/https-upgrades/resources/pass.html")
+ window.onmessage = function(event) {
+ if (event.data === "pass") {
+ done();
+ }
+ }
+ win = window.open(url)
+ </script>
+ </body>
+</html>