diff --git a/testing/web-platform/meta/MANIFEST.json b/testing/web-platform/meta/MANIFEST.json index 5d752dc6fdc8..c899a750037d 100644 --- a/testing/web-platform/meta/MANIFEST.json +++ b/testing/web-platform/meta/MANIFEST.json @@ -277642,6 +277642,31 @@ {} ] ], + "fetch/sec-metadata/README.md": [ + [ + {} + ] + ], + "fetch/sec-metadata/resources/echo-as-json.py": [ + [ + {} + ] + ], + "fetch/sec-metadata/resources/echo-as-script.py": [ + [ + {} + ] + ], + "fetch/sec-metadata/resources/helper.js": [ + [ + {} + ] + ], + "fetch/sec-metadata/resources/post-to-owner.py": [ + [ + {} + ] + ], "fetch/security/support/embedded-credential-window.sub.html": [ [ {} @@ -334285,6 +334310,38 @@ {} ] ], + "fetch/sec-metadata/fetch.tentative.https.sub.html": [ + [ + "/fetch/sec-metadata/fetch.tentative.https.sub.html", + {} + ] + ], + "fetch/sec-metadata/iframe.tentative.https.sub.html": [ + [ + "/fetch/sec-metadata/iframe.tentative.https.sub.html", + {} + ] + ], + "fetch/sec-metadata/img.tentative.https.sub.html": [ + [ + "/fetch/sec-metadata/img.tentative.https.sub.html", + {} + ] + ], + "fetch/sec-metadata/script.tentative.https.sub.html": [ + [ + "/fetch/sec-metadata/script.tentative.https.sub.html", + {} + ] + ], + "fetch/sec-metadata/window-open.tentative.https.sub.html": [ + [ + "/fetch/sec-metadata/window-open.tentative.https.sub.html", + { + "testdriver": true + } + ] + ], "fetch/security/dangling-markup-mitigation-data-url.tentative.sub.html": [ [ "/fetch/security/dangling-markup-mitigation-data-url.tentative.sub.html", @@ -565068,6 +565125,46 @@ "a9e0f5b9b70917aabbff3ad5dd03a5d5dccfa9f0", "testharness" ], + "fetch/sec-metadata/README.md": [ + "75d58b35c1e5572d02dd3ad90ac65301e35c4bc7", + "support" + ], + "fetch/sec-metadata/fetch.tentative.https.sub.html": [ + "6ce26d3683b78ca74a20b14ccca077cf375d742b", + "testharness" + ], + "fetch/sec-metadata/iframe.tentative.https.sub.html": [ + "0308cd613a3099bf04469fba6273f46db991d49c", + "testharness" + ], + "fetch/sec-metadata/img.tentative.https.sub.html": [ + "63a6c8a45102527079acb81d1c57d5dc49c07e4b", + "testharness" + ], + "fetch/sec-metadata/resources/echo-as-json.py": [ + "bbe86e17580229158500722115a1347ca8fa2abb", + "support" + ], + "fetch/sec-metadata/resources/echo-as-script.py": [ + "f3de57b64101ddcff326bbef8132a905d31356ce", + "support" + ], + "fetch/sec-metadata/resources/helper.js": [ + "64d204e36b6ab3b7268d6fd8e0694081222b98ee", + "support" + ], + "fetch/sec-metadata/resources/post-to-owner.py": [ + "2f57a1ddf411864ad2b1ba75f95453d9ed54e3f6", + "support" + ], + "fetch/sec-metadata/script.tentative.https.sub.html": [ + "147291288dacf51942cadc8a85f7842c3bf19b34", + "testharness" + ], + "fetch/sec-metadata/window-open.tentative.https.sub.html": [ + "116c597fb1909f7c4a67c8ada3bfeb6c011d7b04", + "testharness" + ], "fetch/security/dangling-markup-mitigation-data-url.tentative.sub.html": [ "1059b1c0907444bd416889f99d766a566ba9bde3", "testharness" diff --git a/testing/web-platform/tests/fetch/sec-metadata/README.md b/testing/web-platform/tests/fetch/sec-metadata/README.md new file mode 100644 index 000000000000..c460aa1ecb94 --- /dev/null +++ b/testing/web-platform/tests/fetch/sec-metadata/README.md @@ -0,0 +1,11 @@ +`Sec-Metadata` Tests +==================== + +This directory contains tests related to the `Sec-Metadata` proposal: + +: Explainer +:: +: "Spec" +:: + +Note: All of this is tentative, and will change (rapidly). diff --git a/testing/web-platform/tests/fetch/sec-metadata/fetch.tentative.https.sub.html b/testing/web-platform/tests/fetch/sec-metadata/fetch.tentative.https.sub.html new file mode 100644 index 000000000000..1128218b4e8c --- /dev/null +++ b/testing/web-platform/tests/fetch/sec-metadata/fetch.tentative.https.sub.html @@ -0,0 +1,44 @@ + + + + + diff --git a/testing/web-platform/tests/fetch/sec-metadata/iframe.tentative.https.sub.html b/testing/web-platform/tests/fetch/sec-metadata/iframe.tentative.https.sub.html new file mode 100644 index 000000000000..5b56c62ad713 --- /dev/null +++ b/testing/web-platform/tests/fetch/sec-metadata/iframe.tentative.https.sub.html @@ -0,0 +1,63 @@ + + + + + + diff --git a/testing/web-platform/tests/fetch/sec-metadata/img.tentative.https.sub.html b/testing/web-platform/tests/fetch/sec-metadata/img.tentative.https.sub.html new file mode 100644 index 000000000000..9d17462ea463 --- /dev/null +++ b/testing/web-platform/tests/fetch/sec-metadata/img.tentative.https.sub.html @@ -0,0 +1,54 @@ + + + + + + + diff --git a/testing/web-platform/tests/fetch/sec-metadata/resources/echo-as-json.py b/testing/web-platform/tests/fetch/sec-metadata/resources/echo-as-json.py new file mode 100644 index 000000000000..a45bb6865461 --- /dev/null +++ b/testing/web-platform/tests/fetch/sec-metadata/resources/echo-as-json.py @@ -0,0 +1,12 @@ +import json + +def main(request, response): + headers = [("Content-Type", "application/json"), + ("Access-Control-Allow-Credentials", "true")] + + if "origin" in request.headers: + headers.append(("Access-Control-Allow-Origin", request.headers["origin"])) + + + body = json.dumps({ "header": request.headers["sec-metadata"] }) + return headers, body diff --git a/testing/web-platform/tests/fetch/sec-metadata/resources/echo-as-script.py b/testing/web-platform/tests/fetch/sec-metadata/resources/echo-as-script.py new file mode 100644 index 000000000000..c503822d5c60 --- /dev/null +++ b/testing/web-platform/tests/fetch/sec-metadata/resources/echo-as-script.py @@ -0,0 +1,8 @@ +import json + +def main(request, response): + headers = [("Content-Type", "text/javascript")] + + body = "var header = %s;" % json.dumps(request.headers["sec-metadata"]); + + return headers, body diff --git a/testing/web-platform/tests/fetch/sec-metadata/resources/helper.js b/testing/web-platform/tests/fetch/sec-metadata/resources/helper.js new file mode 100644 index 000000000000..5754b5009e3c --- /dev/null +++ b/testing/web-platform/tests/fetch/sec-metadata/resources/helper.js @@ -0,0 +1,16 @@ +function parse_metadata(value) { + let result = {}; + value.split(',').forEach(item => { + let parsed = item.trim().split('='); + result[parsed[0]] = parsed[1]; + }); + return result; +} + +function assert_header_equals(value, expected) { + let result = parse_metadata(value); + assert_equals(result.cause, expected.cause, "cause"); + assert_equals(result.destination, expected.destination, "destination"); + assert_equals(result.target, expected.target, "target"); + assert_equals(result.site, expected.site, "site"); +} diff --git a/testing/web-platform/tests/fetch/sec-metadata/resources/post-to-owner.py b/testing/web-platform/tests/fetch/sec-metadata/resources/post-to-owner.py new file mode 100644 index 000000000000..fe08cd1cbcaa --- /dev/null +++ b/testing/web-platform/tests/fetch/sec-metadata/resources/post-to-owner.py @@ -0,0 +1,16 @@ +import json + +def main(request, response): + headers = [("Content-Type", "text/html")] + + body = """ + + + """ % json.dumps(request.headers["sec-metadata"]) + return headers, body diff --git a/testing/web-platform/tests/fetch/sec-metadata/script.tentative.https.sub.html b/testing/web-platform/tests/fetch/sec-metadata/script.tentative.https.sub.html new file mode 100644 index 000000000000..1916f670c332 --- /dev/null +++ b/testing/web-platform/tests/fetch/sec-metadata/script.tentative.https.sub.html @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + diff --git a/testing/web-platform/tests/fetch/sec-metadata/window-open.tentative.https.sub.html b/testing/web-platform/tests/fetch/sec-metadata/window-open.tentative.https.sub.html new file mode 100644 index 000000000000..1f9df663f1da --- /dev/null +++ b/testing/web-platform/tests/fetch/sec-metadata/window-open.tentative.https.sub.html @@ -0,0 +1,127 @@ + + + + + + + +