summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/http
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/http')
-rw-r--r--testing/web-platform/tests/http/basic-auth-cache-test-ref.html6
-rw-r--r--testing/web-platform/tests/http/basic-auth-cache-test.html27
-rw-r--r--testing/web-platform/tests/http/content_length.html13
-rw-r--r--testing/web-platform/tests/http/content_length.html.headers1
-rw-r--r--testing/web-platform/tests/http/resources/securedimage.py17
5 files changed, 64 insertions, 0 deletions
diff --git a/testing/web-platform/tests/http/basic-auth-cache-test-ref.html b/testing/web-platform/tests/http/basic-auth-cache-test-ref.html
new file mode 100644
index 000000000..905facdc8
--- /dev/null
+++ b/testing/web-platform/tests/http/basic-auth-cache-test-ref.html
@@ -0,0 +1,6 @@
+<!doctype html>
+<html>
+ <meta charset="utf-8">
+ <img src="/images/green.png">
+ <img src="/images/green.png">
+</html>
diff --git a/testing/web-platform/tests/http/basic-auth-cache-test.html b/testing/web-platform/tests/http/basic-auth-cache-test.html
new file mode 100644
index 000000000..0d3895b80
--- /dev/null
+++ b/testing/web-platform/tests/http/basic-auth-cache-test.html
@@ -0,0 +1,27 @@
+<!doctype html>
+<html id="doc" class="reftest-wait">
+ <meta charset="utf-8">
+ <link rel="match" href="basic-auth-cache-test-ref.html">
+
+ <img id="auth" onload="loadNoAuth()">
+ <img id="noauth" onload="removeWait()">
+
+
+ <script type="text/javascript">
+ function loadAuth() {
+ var authUrl = 'http://testuser:testpass@' + window.location.host + '/http/resources/securedimage.py';
+ document.getElementById('auth').src = authUrl;
+ }
+
+ function loadNoAuth() {
+ var noAuthUrl = 'http://' + window.location.host + '/http/resources/securedimage.py';
+ document.getElementById('noauth').src = noAuthUrl;
+ }
+
+ function removeWait() {
+ document.getElementById('doc').className = "";
+ }
+
+ window.onload = loadAuth;
+ </script>
+</html>
diff --git a/testing/web-platform/tests/http/content_length.html b/testing/web-platform/tests/http/content_length.html
new file mode 100644
index 000000000..af8ea44ee
--- /dev/null
+++ b/testing/web-platform/tests/http/content_length.html
@@ -0,0 +1,13 @@
+<!DOCTYPE html>
+<!-- CAUTION: if updating this test also update the expected content-length in the .headers file -->
+<title>Content-Length Test</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+onload = function() {
+ assert_equals(document.body.textContent, "PASS");
+ done();
+}
+</script>
+<body>PASS
+but FAIL if this is in the body. \ No newline at end of file
diff --git a/testing/web-platform/tests/http/content_length.html.headers b/testing/web-platform/tests/http/content_length.html.headers
new file mode 100644
index 000000000..385ea556d
--- /dev/null
+++ b/testing/web-platform/tests/http/content_length.html.headers
@@ -0,0 +1 @@
+Content-Length: 373
diff --git a/testing/web-platform/tests/http/resources/securedimage.py b/testing/web-platform/tests/http/resources/securedimage.py
new file mode 100644
index 000000000..311b0c525
--- /dev/null
+++ b/testing/web-platform/tests/http/resources/securedimage.py
@@ -0,0 +1,17 @@
+# -*- coding: utf-8 -
+
+def main(request, response):
+ image_url = str.replace(request.url, "http/resources/securedimage.py", "images/green.png")
+
+ if "authorization" not in request.headers:
+ response.status = 401
+ response.headers.set("WWW-Authenticate", "Basic")
+ return response
+ else:
+ auth = request.headers.get("Authorization")
+ if auth != "Basic dGVzdHVzZXI6dGVzdHBhc3M=":
+ response.set_error(403, "Invalid username or password - " + auth)
+ return response
+
+ response.status = 301
+ response.headers.set("Location", image_url)