diff --git a/python/tidy/servo_tidy/tidy.py b/python/tidy/servo_tidy/tidy.py index 5baca6749ab..6ec263b2678 100644 --- a/python/tidy/servo_tidy/tidy.py +++ b/python/tidy/servo_tidy/tidy.py @@ -54,6 +54,7 @@ ignored_dirs = [ os.path.join(".", "tests", "wpt", "harness"), os.path.join(".", "tests", "wpt", "update"), os.path.join(".", "tests", "wpt", "web-platform-tests"), + os.path.join(".", "tests", "wpt", "mozilla", "tests", "mozilla", "referrer-policy"), os.path.join(".", "tests", "wpt", "sync"), os.path.join(".", "tests", "wpt", "sync_css"), os.path.join(".", "python", "mach"), diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index fe297365b13..784c0ba7451 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -6670,6 +6670,186 @@ "url": "/_mozilla/mozilla/range_deleteContents.html" } ], + "mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/insecure-protocol.keep-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/insecure-protocol.keep-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/insecure-protocol.keep-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/insecure-protocol.no-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/insecure-protocol.no-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/insecure-protocol.no-redirect.http.html" + } + ], + "mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/insecure-protocol.swap-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/insecure-protocol.swap-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/insecure-protocol.swap-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/insecure-protocol.keep-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/insecure-protocol.keep-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/insecure-protocol.keep-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/insecure-protocol.no-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/insecure-protocol.no-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/insecure-protocol.no-redirect.http.html" + } + ], + "mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/insecure-protocol.swap-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/insecure-protocol.swap-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/insecure-protocol.swap-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/iframe-tag/generic.no-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/iframe-tag/generic.no-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/iframe-tag/generic.no-redirect.http.html" + } + ], + "mozilla/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/no-referrer/meta-referrer/cross-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/iframe-tag/generic.no-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/iframe-tag/generic.no-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/iframe-tag/generic.no-redirect.http.html" + } + ], + "mozilla/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/no-referrer/meta-referrer/same-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/generic.no-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/generic.no-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/generic.no-redirect.http.html" + } + ], + "mozilla/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/generic.no-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/generic.no-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/generic.no-redirect.http.html" + } + ], + "mozilla/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.keep-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.keep-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.keep-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.no-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.no-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.no-redirect.http.html" + } + ], + "mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.swap-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.swap-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.swap-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/same-origin-insecure.keep-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/same-origin-insecure.keep-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/same-origin-insecure.keep-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/same-origin-insecure.no-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/same-origin-insecure.no-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/same-origin-insecure.no-redirect.http.html" + } + ], + "mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/same-origin-insecure.swap-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/same-origin-insecure.swap-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/same-origin-insecure.swap-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/generic.no-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/generic.no-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/generic.no-redirect.http.html" + } + ], + "mozilla/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html" + } + ], + "mozilla/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/generic.no-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/generic.no-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/generic.no-redirect.http.html" + } + ], + "mozilla/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html": [ + { + "path": "mozilla/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html", + "url": "/_mozilla/mozilla/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html" + } + ], "mozilla/response-data-brotli.htm": [ { "path": "mozilla/response-data-brotli.htm", diff --git a/tests/wpt/mozilla/meta/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/insecure-protocol.keep-origin-redirect.http.html.ini b/tests/wpt/mozilla/meta/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/insecure-protocol.keep-origin-redirect.http.html.ini new file mode 100644 index 00000000000..bdddc5d4ea8 --- /dev/null +++ b/tests/wpt/mozilla/meta/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/insecure-protocol.keep-origin-redirect.http.html.ini @@ -0,0 +1,5 @@ +[insecure-protocol.keep-origin-redirect.http.html] + type: testharness + [The referrer URL is stripped-referrer when a\n document served over http requires an http\n sub-resource via iframe-tag using the meta-referrer\n delivery method with keep-origin-redirect and when\n the target request is cross-origin.] + expected: FAIL + diff --git a/tests/wpt/mozilla/meta/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/insecure-protocol.no-redirect.http.html.ini b/tests/wpt/mozilla/meta/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/insecure-protocol.no-redirect.http.html.ini new file mode 100644 index 00000000000..d3c2e501366 --- /dev/null +++ b/tests/wpt/mozilla/meta/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/insecure-protocol.no-redirect.http.html.ini @@ -0,0 +1,5 @@ +[insecure-protocol.no-redirect.http.html] + type: testharness + [The referrer URL is stripped-referrer when a\n document served over http requires an http\n sub-resource via iframe-tag using the meta-referrer\n delivery method with no-redirect and when\n the target request is cross-origin.] + expected: FAIL + diff --git a/tests/wpt/mozilla/meta/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/insecure-protocol.swap-origin-redirect.http.html.ini b/tests/wpt/mozilla/meta/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/insecure-protocol.swap-origin-redirect.http.html.ini new file mode 100644 index 00000000000..0ce5bcfb640 --- /dev/null +++ b/tests/wpt/mozilla/meta/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/cross-origin/http-http/iframe-tag/insecure-protocol.swap-origin-redirect.http.html.ini @@ -0,0 +1,5 @@ +[insecure-protocol.swap-origin-redirect.http.html] + type: testharness + [The referrer URL is stripped-referrer when a\n document served over http requires an http\n sub-resource via iframe-tag using the meta-referrer\n delivery method with swap-origin-redirect and when\n the target request is cross-origin.] + expected: FAIL + diff --git a/tests/wpt/mozilla/meta/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/insecure-protocol.keep-origin-redirect.http.html.ini b/tests/wpt/mozilla/meta/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/insecure-protocol.keep-origin-redirect.http.html.ini new file mode 100644 index 00000000000..e3ca3e23da3 --- /dev/null +++ b/tests/wpt/mozilla/meta/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/insecure-protocol.keep-origin-redirect.http.html.ini @@ -0,0 +1,5 @@ +[insecure-protocol.keep-origin-redirect.http.html] + type: testharness + [The referrer URL is stripped-referrer when a\n document served over http requires an http\n sub-resource via iframe-tag using the meta-referrer\n delivery method with keep-origin-redirect and when\n the target request is same-origin.] + expected: FAIL + diff --git a/tests/wpt/mozilla/meta/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/insecure-protocol.no-redirect.http.html.ini b/tests/wpt/mozilla/meta/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/insecure-protocol.no-redirect.http.html.ini new file mode 100644 index 00000000000..aa8825ca986 --- /dev/null +++ b/tests/wpt/mozilla/meta/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/insecure-protocol.no-redirect.http.html.ini @@ -0,0 +1,5 @@ +[insecure-protocol.no-redirect.http.html] + type: testharness + [The referrer URL is stripped-referrer when a\n document served over http requires an http\n sub-resource via iframe-tag using the meta-referrer\n delivery method with no-redirect and when\n the target request is same-origin.] + expected: FAIL + diff --git a/tests/wpt/mozilla/meta/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/insecure-protocol.swap-origin-redirect.http.html.ini b/tests/wpt/mozilla/meta/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/insecure-protocol.swap-origin-redirect.http.html.ini new file mode 100644 index 00000000000..49a62d07e1b --- /dev/null +++ b/tests/wpt/mozilla/meta/mozilla/referrer-policy/no-referrer-when-downgrade/meta-referrer/same-origin/http-http/iframe-tag/insecure-protocol.swap-origin-redirect.http.html.ini @@ -0,0 +1,5 @@ +[insecure-protocol.swap-origin-redirect.http.html] + type: testharness + [The referrer URL is stripped-referrer when a\n document served over http requires an http\n sub-resource via iframe-tag using the meta-referrer\n delivery method with swap-origin-redirect and when\n the target request is same-origin.] + expected: FAIL + diff --git a/tests/wpt/mozilla/meta/mozilla/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html.ini b/tests/wpt/mozilla/meta/mozilla/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html.ini new file mode 100644 index 00000000000..bdbbe6c0d5b --- /dev/null +++ b/tests/wpt/mozilla/meta/mozilla/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html.ini @@ -0,0 +1,5 @@ +[generic.keep-origin-redirect.http.html] + type: testharness + [The referrer URL is origin when a\n document served over http requires an http\n sub-resource via iframe-tag using the meta-referrer\n delivery method with keep-origin-redirect and when\n the target request is cross-origin.] + expected: FAIL + diff --git a/tests/wpt/mozilla/meta/mozilla/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/generic.no-redirect.http.html.ini b/tests/wpt/mozilla/meta/mozilla/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/generic.no-redirect.http.html.ini new file mode 100644 index 00000000000..5220091d82c --- /dev/null +++ b/tests/wpt/mozilla/meta/mozilla/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/generic.no-redirect.http.html.ini @@ -0,0 +1,5 @@ +[generic.no-redirect.http.html] + type: testharness + [The referrer URL is origin when a\n document served over http requires an http\n sub-resource via iframe-tag using the meta-referrer\n delivery method with no-redirect and when\n the target request is cross-origin.] + expected: FAIL + diff --git a/tests/wpt/mozilla/meta/mozilla/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html.ini b/tests/wpt/mozilla/meta/mozilla/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html.ini new file mode 100644 index 00000000000..a66d26b054d --- /dev/null +++ b/tests/wpt/mozilla/meta/mozilla/referrer-policy/origin-only/meta-referrer/cross-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html.ini @@ -0,0 +1,5 @@ +[generic.swap-origin-redirect.http.html] + type: testharness + [The referrer URL is origin when a\n document served over http requires an http\n sub-resource via iframe-tag using the meta-referrer\n delivery method with swap-origin-redirect and when\n the target request is cross-origin.] + expected: FAIL + diff --git a/tests/wpt/mozilla/meta/mozilla/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html.ini b/tests/wpt/mozilla/meta/mozilla/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html.ini new file mode 100644 index 00000000000..32662c3a6a8 --- /dev/null +++ b/tests/wpt/mozilla/meta/mozilla/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html.ini @@ -0,0 +1,5 @@ +[generic.keep-origin-redirect.http.html] + type: testharness + [The referrer URL is origin when a\n document served over http requires an http\n sub-resource via iframe-tag using the meta-referrer\n delivery method with keep-origin-redirect and when\n the target request is same-origin.] + expected: FAIL + diff --git a/tests/wpt/mozilla/meta/mozilla/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/generic.no-redirect.http.html.ini b/tests/wpt/mozilla/meta/mozilla/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/generic.no-redirect.http.html.ini new file mode 100644 index 00000000000..7c94f552be2 --- /dev/null +++ b/tests/wpt/mozilla/meta/mozilla/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/generic.no-redirect.http.html.ini @@ -0,0 +1,5 @@ +[generic.no-redirect.http.html] + type: testharness + [The referrer URL is origin when a\n document served over http requires an http\n sub-resource via iframe-tag using the meta-referrer\n delivery method with no-redirect and when\n the target request is same-origin.] + expected: FAIL + diff --git a/tests/wpt/mozilla/meta/mozilla/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html.ini b/tests/wpt/mozilla/meta/mozilla/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html.ini new file mode 100644 index 00000000000..3fced6fb37a --- /dev/null +++ b/tests/wpt/mozilla/meta/mozilla/referrer-policy/origin-only/meta-referrer/same-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html.ini @@ -0,0 +1,5 @@ +[generic.swap-origin-redirect.http.html] + type: testharness + [The referrer URL is origin when a\n document served over http requires an http\n sub-resource via iframe-tag using the meta-referrer\n delivery method with swap-origin-redirect and when\n the target request is same-origin.] + expected: FAIL + diff --git a/tests/wpt/mozilla/meta/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.keep-origin-redirect.http.html.ini b/tests/wpt/mozilla/meta/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.keep-origin-redirect.http.html.ini new file mode 100644 index 00000000000..11bd327b08c --- /dev/null +++ b/tests/wpt/mozilla/meta/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.keep-origin-redirect.http.html.ini @@ -0,0 +1,5 @@ +[cross-origin.keep-origin-redirect.http.html] + type: testharness + [The referrer URL is origin when a\n document served over http requires an http\n sub-resource via iframe-tag using the meta-referrer\n delivery method with keep-origin-redirect and when\n the target request is cross-origin.] + expected: FAIL + diff --git a/tests/wpt/mozilla/meta/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.no-redirect.http.html.ini b/tests/wpt/mozilla/meta/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.no-redirect.http.html.ini new file mode 100644 index 00000000000..812d83a253e --- /dev/null +++ b/tests/wpt/mozilla/meta/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.no-redirect.http.html.ini @@ -0,0 +1,5 @@ +[cross-origin.no-redirect.http.html] + type: testharness + [The referrer URL is origin when a\n document served over http requires an http\n sub-resource via iframe-tag using the meta-referrer\n delivery method with no-redirect and when\n the target request is cross-origin.] + expected: FAIL + diff --git a/tests/wpt/mozilla/meta/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.swap-origin-redirect.http.html.ini b/tests/wpt/mozilla/meta/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.swap-origin-redirect.http.html.ini new file mode 100644 index 00000000000..bc15e3df6d7 --- /dev/null +++ b/tests/wpt/mozilla/meta/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/cross-origin/http-http/iframe-tag/cross-origin.swap-origin-redirect.http.html.ini @@ -0,0 +1,5 @@ +[cross-origin.swap-origin-redirect.http.html] + type: testharness + [The referrer URL is origin when a\n document served over http requires an http\n sub-resource via iframe-tag using the meta-referrer\n delivery method with swap-origin-redirect and when\n the target request is cross-origin.] + expected: FAIL + diff --git a/tests/wpt/mozilla/meta/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/same-origin-insecure.keep-origin-redirect.http.html.ini b/tests/wpt/mozilla/meta/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/same-origin-insecure.keep-origin-redirect.http.html.ini new file mode 100644 index 00000000000..95f762e65cf --- /dev/null +++ b/tests/wpt/mozilla/meta/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/same-origin-insecure.keep-origin-redirect.http.html.ini @@ -0,0 +1,5 @@ +[same-origin-insecure.keep-origin-redirect.http.html] + type: testharness + [The referrer URL is stripped-referrer when a\n document served over http requires an http\n sub-resource via iframe-tag using the meta-referrer\n delivery method with keep-origin-redirect and when\n the target request is same-origin.] + expected: FAIL + diff --git a/tests/wpt/mozilla/meta/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/same-origin-insecure.no-redirect.http.html.ini b/tests/wpt/mozilla/meta/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/same-origin-insecure.no-redirect.http.html.ini new file mode 100644 index 00000000000..d781230d47b --- /dev/null +++ b/tests/wpt/mozilla/meta/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/same-origin-insecure.no-redirect.http.html.ini @@ -0,0 +1,5 @@ +[same-origin-insecure.no-redirect.http.html] + type: testharness + [The referrer URL is stripped-referrer when a\n document served over http requires an http\n sub-resource via iframe-tag using the meta-referrer\n delivery method with no-redirect and when\n the target request is same-origin.] + expected: FAIL + diff --git a/tests/wpt/mozilla/meta/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/same-origin-insecure.swap-origin-redirect.http.html.ini b/tests/wpt/mozilla/meta/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/same-origin-insecure.swap-origin-redirect.http.html.ini new file mode 100644 index 00000000000..00252cc5fff --- /dev/null +++ b/tests/wpt/mozilla/meta/mozilla/referrer-policy/origin-when-cross-origin/meta-referrer/same-origin/http-http/iframe-tag/same-origin-insecure.swap-origin-redirect.http.html.ini @@ -0,0 +1,5 @@ +[same-origin-insecure.swap-origin-redirect.http.html] + type: testharness + [The referrer URL is origin when a\n document served over http requires an http\n sub-resource via iframe-tag using the meta-referrer\n delivery method with swap-origin-redirect and when\n the target request is same-origin.] + expected: FAIL + diff --git a/tests/wpt/mozilla/meta/mozilla/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html.ini b/tests/wpt/mozilla/meta/mozilla/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html.ini new file mode 100644 index 00000000000..db2031336f8 --- /dev/null +++ b/tests/wpt/mozilla/meta/mozilla/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html.ini @@ -0,0 +1,5 @@ +[generic.keep-origin-redirect.http.html] + type: testharness + [The referrer URL is stripped-referrer when a\n document served over http requires an http\n sub-resource via iframe-tag using the meta-referrer\n delivery method with keep-origin-redirect and when\n the target request is cross-origin.] + expected: FAIL + diff --git a/tests/wpt/mozilla/meta/mozilla/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/generic.no-redirect.http.html.ini b/tests/wpt/mozilla/meta/mozilla/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/generic.no-redirect.http.html.ini new file mode 100644 index 00000000000..3a813138802 --- /dev/null +++ b/tests/wpt/mozilla/meta/mozilla/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/generic.no-redirect.http.html.ini @@ -0,0 +1,5 @@ +[generic.no-redirect.http.html] + type: testharness + [The referrer URL is stripped-referrer when a\n document served over http requires an http\n sub-resource via iframe-tag using the meta-referrer\n delivery method with no-redirect and when\n the target request is cross-origin.] + expected: FAIL + diff --git a/tests/wpt/mozilla/meta/mozilla/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html.ini b/tests/wpt/mozilla/meta/mozilla/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html.ini new file mode 100644 index 00000000000..dd0f1831b18 --- /dev/null +++ b/tests/wpt/mozilla/meta/mozilla/referrer-policy/unsafe-url/meta-referrer/cross-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html.ini @@ -0,0 +1,5 @@ +[generic.swap-origin-redirect.http.html] + type: testharness + [The referrer URL is stripped-referrer when a\n document served over http requires an http\n sub-resource via iframe-tag using the meta-referrer\n delivery method with swap-origin-redirect and when\n the target request is cross-origin.] + expected: FAIL + diff --git a/tests/wpt/mozilla/meta/mozilla/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html.ini b/tests/wpt/mozilla/meta/mozilla/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html.ini new file mode 100644 index 00000000000..0293c6bebd7 --- /dev/null +++ b/tests/wpt/mozilla/meta/mozilla/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/generic.keep-origin-redirect.http.html.ini @@ -0,0 +1,5 @@ +[generic.keep-origin-redirect.http.html] + type: testharness + [The referrer URL is stripped-referrer when a\n document served over http requires an http\n sub-resource via iframe-tag using the meta-referrer\n delivery method with keep-origin-redirect and when\n the target request is same-origin.] + expected: FAIL + diff --git a/tests/wpt/mozilla/meta/mozilla/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/generic.no-redirect.http.html.ini b/tests/wpt/mozilla/meta/mozilla/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/generic.no-redirect.http.html.ini new file mode 100644 index 00000000000..9240c8f42e3 --- /dev/null +++ b/tests/wpt/mozilla/meta/mozilla/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/generic.no-redirect.http.html.ini @@ -0,0 +1,5 @@ +[generic.no-redirect.http.html] + type: testharness + [The referrer URL is stripped-referrer when a\n document served over http requires an http\n sub-resource via iframe-tag using the meta-referrer\n delivery method with no-redirect and when\n the target request is same-origin.] + expected: FAIL + diff --git a/tests/wpt/mozilla/meta/mozilla/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html.ini b/tests/wpt/mozilla/meta/mozilla/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html.ini new file mode 100644 index 00000000000..56b7cd590bb --- /dev/null +++ b/tests/wpt/mozilla/meta/mozilla/referrer-policy/unsafe-url/meta-referrer/same-origin/http-http/iframe-tag/generic.swap-origin-redirect.http.html.ini @@ -0,0 +1,5 @@ +[generic.swap-origin-redirect.http.html] + type: testharness + [The referrer URL is stripped-referrer when a\n document served over http requires an http\n sub-resource via iframe-tag using the meta-referrer\n delivery method with swap-origin-redirect and when\n the target request is same-origin.] + expected: FAIL + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/OWNERS b/tests/wpt/mozilla/tests/mozilla/referrer-policy/OWNERS new file mode 100644 index 00000000000..db2d613c226 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/OWNERS @@ -0,0 +1 @@ +@kristijanburnik diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/README.md b/tests/wpt/mozilla/tests/mozilla/referrer-policy/README.md new file mode 100644 index 00000000000..fc84ce8d1cb --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/README.md @@ -0,0 +1,245 @@ +# Referrer-Policy Web Platform Tests + +The Referrer-Policy tests are designed for testing browser implementations and conformance to the [W3 Referrer-Policy Specification](http://w3c.github.io/webappsec/specs/referrer-policy/). + +## Project structure + +The project contains tools, templates and a seed (```spec.src.json```) for generating tests. The main assertion logic resides in JS files in the root of the ```./generic/``` directory. + +This is the overview of the project structure: + +``` +. +└── generic + ├── subresource - documents being served as sub-resources (python scripts) + ├── subresource-test - sanity checking tests for resource invocation + ├── template - the test files template used for generating the tests + └── tools - for generating and maintaining the test suite +└── (genereated_tests_for_a_specification_1) +└── (genereated_tests_for_a_specification_2) +└── ... +└── (genereated_tests_for_a_specification_N) +``` + +## The spec JSON + +The ```spec.src.json``` defines all the test scenarios for the referrer policy. + +Invoking ```./generic/tools/generate.py``` will parse the spec JSON and determine which tests to generate (or skip) while using templates. + + +The spec can be validated by running ```./generic/tools/spec_validator.py```. This is specially important when you're making changes to ```spec.src.json```. Make sure it's a valid JSON (no comments or trailing commas). The validator should be informative and very specific on any issues. + +For details about the spec JSON, see **Overview of the spec JSON** below. + + +## Generating and running the tests + +The repository already contains generated tests, so if you're making changes, +see the **Removing all generated tests** section below, on how to remove them before you start generating tests which include your changes. + +Start from the command line: + +```bash + +# Chdir into the tests directory. +cd ~/web-platform-tests/referrer-policy + +# Generate the test resources. +./generic/tools/generate.py + +# Add all generated tests to the repo. +git add * && git commit -m "Add generated tests" + +# Regenerate the manifest. +../manifest + +``` + +Navigate to [http://web-platform.test:8000/tools/runner/index.html](http://web-platform.test:8000/tools/runner/index.html). + +Run tests under path: ```/referrer-policy```. + +Click start. + + +## Options for generating tests + +The generator script ```./generic/tools/generate.py``` has two targets: ```release``` and ```debug```. + +* Using **release** for the target will produce tests using a template for optimizing size and performance. The release template is intended for the official web-platform-tests and possibly other test suites. No sanity checking is done in release mode. Use this option whenever you're checking into web-platform-tests. + +* When generating for ```debug```, the produced tests will contain more verbosity and sanity checks. Use this target to identify problems with the test suite when making changes locally. Make sure you don't check in tests generated with the debug target. + +Note that **release** is the default target when invoking ```generate.py```. + + +## Removing all generated tests + +```bash +# Chdir into the tests directory. +cd ~/web-platform-tests/referrer-policy + +# Remove all generated tests. +./generic/tools/clean.py + +# Remove all generated tests to the repo. +git add * && git commit -m "Remove generated tests" + +# Regenerate the manifest. +../manifest +``` + +**Important:** +The ```./generic/tools/clean.py``` utility will only work if there is a valid ```spec.src.json``` and previously generated directories match the specification requirement names. So make sure you run ```clean.py``` before you alter the specification section of the spec JSON. + + +## Updating the tests + +The main test logic lives in ```./generic/referrer-policy-test-case.js``` with helper functions defined in ```./generic/common.js``` so you should probably start there. + +For updating the test suite you will most likely do **a subset** of the following: + +* Add a new sub-resource python script to ```./generic/subresource/```, + and update the reference to it in ```spec.src.json```. + +* Add a sanity check test for a sub-resource to ```./generic/subresource-test/```. + +* Implement new or update existing assertions in ```./generic/referrer-policy-test-case.js```. + +* Exclude or add some tests by updating ```spec.src.json``` test expansions. + +* Update the template files living in ```./generic/template/```. + +* Implement a new delivery method via HTTP headers or as part of the test template in ```./generic/tools/generate.py``` + +* Update the spec schema by editing ```spec.src.json``` while updating the + ```./generic/tools/spec_validator.py``` and ```./generic/tools/generate.py``` + and making sure both still work after the change (by running them). + +* Regenerate the tests and MANIFEST.json + + +## Updating the spec and regenerating + +When updating the ```spec.src.json```, e.g. by adding a test expansion pattern to the ```excluded_tests``` section or when removing an expansion in the ```specification``` section, make sure to remove all previously generated files which would still get picked up by ```MANIFEST.json``` in the web-platform-tests root. As long as you don't change the specification requirements' names or remove them, you can easily regenerate the tests via command line: + +```bash + +# Chdir into the tests directory. +cd ~/web-platform-tests/referrer-policy + +# Regenerate the test resources. +./generic/tools/regenerate + +# Add all the tests to the repo. +git add * && git commit -m "Update generated tests" + +# Regenerate the manifest. +../manifest + + +``` + + +## Overview of the spec JSON + +**Main sections:** + +* **specification** + + Top level requirements with description fields and a ```test_expansion``` rule. + This is closely mimicking the [Referrer Policy specification](http://w3c.github.io/webappsec/specs/referrer-policy/) structure. + +* **excluded_tests** + + List of ```test_expansion``` patterns expanding into selections which get skipped when generating the tests (aka. blacklisting/suppressing) + +* **referrer_policy_schema** + + The schema to validate fields which define the ```referrer_policy``` elsewhere in the JSON. + A value for a referrer_policy can only be one specified in the referrer_policy_schema. + +* **test_expansion_schema** + + The schema used to check if a ```test_expansion``` is valid. + Each test expansion can only contain fields defined by this schema. + +* **subresource_path** + + A 1:1 mapping of a **subresource type** to the URL path of the sub-resource. + When adding a new sub-resource, a path to an existing file for it also must be specified. + + +### Test Expansion Patterns + +Each field in a test expansion can be in one of the following formats: + +* Single match: ```"value"``` + +* Match any of: ```["value1", "value2", ...]``` + +* Match all: ```"*"``` + +#### Example: test expansion in a requirement specification + +The following example shows how to restrict the expansion of ```referrer_url``` to ```origin``` and allow rest of the arrangement to expand (permute) to all possible values. The name field will be the prefix of a generated HTML file name for the test. + +```json + { + "name": "origin-only", + "title": "Referrer Policy is set to 'origin-only'", + "description": "Check that all sub-resources in all cases get only the origin portion of the referrer URL.", + "specification_url": "https://w3c.github.io/webappsec/specs/referrer-policy/#referrer-policy-state-origin", + "referrer_policy": "origin", + "test_expansion": [ + { + "name": "generic", + "expansion": "default", + "source_protocol": "*", + "target_protocol": "*", + "delivery_method": "*", + "redirection": "*", + "origin": "*", + "subresource": "*", + "referrer_url": "origin" + } + ] + } +``` + +**NOTE:** An expansion is always constructive (inclusive), there isn't a negation operator for explicit exclusion. Be aware that using an empty list ```[]``` matches (expands into) exactly nothing. Tests which are to be excluded should be defined in the ```excluded_tests``` section instead. + +A single test expansion pattern, be it a requirement or a suppressed pattern, gets expanded into a list of **selections** as follows: + +* Expand each field's pattern (single, any of, or all) to list of allowed values (defined by the ```test_expansion_schema```) + +* Permute - Recursively enumerate all **selections** accross all fields + +Be aware that if there is more than one pattern expanding into a same selection (which also shares the same ```name``` field), the pattern appearing later in the spec JSON will overwrite a previously generated selection. To make sure this is not undetected when generating, set the value of the ```expansion``` field to ```default``` for an expansion appearing earlier and ```override``` for the one appearing later. + +A **selection** is a single **test instance** (scenario) with explicit values, for example: + +```javascript +var scenario = { + "referrer_policy": "origin-when-crossorigin", + "delivery_method": "meta-referrer", + "redirection": "no-redirect", + "origin": "cross-origin", + "source_protocol": "http", + "target_protocol": "http", + "subresource": "iframe-tag", + "subresource_path": "/_mozilla/mozilla/referrer-policy/generic/subresource/document.py", + "referrer_url": "origin" +}; +``` + +Essentially, this is what gets generated and defines a single test. The scenario is then evaluated by the ```ReferrerPolicyTestCase``` in JS. For the rest of the arranging part, see the ```./generic/template/``` directory and examine ```./generic/tools/generate.py``` to see how the values for the templates are produced. + + +Taking the spec JSON, the generator follows this algorithm: + +* Expand all ```excluded_tests``` to create a blacklist of selections + +* For each specification requirement: Expand the ```test_expansion``` pattern into selections and check each against the blacklist, if not marked as suppresed, generate the test resources for the selection + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/common.js b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/common.js new file mode 100644 index 00000000000..c4f6bbb8dad --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/common.js @@ -0,0 +1,225 @@ +// NOTE: This method only strips the fragment and is not in accordance to the +// recommended draft specification: +// https://w3c.github.io/webappsec/specs/referrer-policy/#null +// TODO(kristijanburnik): Implement this helper as defined by spec once added +// scenarios for URLs containing username/password/etc. +function stripUrlForUseAsReferrer(url) { + return url.replace(/#.*$/, ""); +} + +function parseUrlQueryString(queryString) { + var queries = queryString.replace(/^\?/, "").split("&"); + var params = {}; + + for (var i in queries) { + var kvp = queries[i].split("="); + params[kvp[0]] = kvp[1]; + } + + return params; +}; + +function appendIframeToBody(url, attributes) { + var iframe = document.createElement("iframe"); + iframe.src = url; + // Extend element with attributes. (E.g. "referrer_policy" or "rel") + if (attributes) { + for (var attr in attributes) { + iframe[attr] = attributes[attr]; + } + } + document.body.appendChild(iframe); + + return iframe; +} + +function loadImage(src, callback, attributes) { + var image = new Image(); + image.crossOrigin = "Anonymous"; + image.onload = function() { + callback(image); + } + image.src = src; + // Extend element with attributes. (E.g. "referrer_policy" or "rel") + if (attributes) { + for (var attr in attributes) { + image[attr] = attributes[attr]; + } + } + document.body.appendChild(image) +} + +function decodeImageData(rgba) { + var rgb = new Uint8ClampedArray(rgba.length); + + // RGBA -> RGB. + var rgb_length = 0; + for (var i = 0; i < rgba.length; ++i) { + // Skip alpha component. + if (i % 4 == 3) + continue; + + // Zero is the string terminator. + if (rgba[i] == 0) + break; + + rgb[rgb_length++] = rgba[i]; + } + + // Remove trailing nulls from data. + rgb = rgb.subarray(0, rgb_length); + var string_data = (new TextDecoder("ascii")).decode(rgb); + + return JSON.parse(string_data); +} + +function decodeImage(url, callback, referrer_policy) { + loadImage(url, function(img) { + var canvas = document.createElement("canvas"); + var context = canvas.getContext('2d'); + context.drawImage(img, 0, 0); + var imgData = context.getImageData(0, 0, img.clientWidth, img.clientHeight); + callback(decodeImageData(imgData.data)) + }, referrer_policy); +} + +function normalizePort(targetPort) { + var defaultPorts = [80, 443]; + var isDefaultPortForProtocol = (defaultPorts.indexOf(targetPort) >= 0); + + return (targetPort == "" || isDefaultPortForProtocol) ? + "" : ":" + targetPort; +} + +function wrapResult(url, server_data) { + return { + location: url, + referrer: server_data.headers.referer, + headers: server_data.headers + } +} + +function queryIframe(url, callback, referrer_policy) { + var x = document.createElement('script'); + x.src = '/common/utils.js'; + x.onerror = function() { console.log('whoops') }; + x.onload = function() { doQuery() }; + document.getElementsByTagName("head")[0].appendChild(x); + + function doQuery() { + var id = token(); + var iframe = appendIframeToBody(url + "&id=" + id, referrer_policy); + iframe.addEventListener("load", function listener() { + var xhr = new XMLHttpRequest(); + xhr.open('GET', '/_mozilla/mozilla/referrer-policy/generic/subresource/stash.py?id=' + id, false); + xhr.onreadystatechange = function(e) { + if (this.readyState == 4 && this.status == 200) { + var server_data = JSON.parse(this.responseText); + callback(server_data, url); + } + }; + xhr.send(); + iframe.removeEventListener("load", listener); + }); + } +} + +function queryImage(url, callback, referrer_policy) { + decodeImage(url, function(server_data) { + callback(wrapResult(url, server_data), url); + }, referrer_policy) +} + +function queryXhr(url, callback) { + var xhr = new XMLHttpRequest(); + xhr.open('GET', url, true); + xhr.onreadystatechange = function(e) { + if (this.readyState == 4 && this.status == 200) { + var server_data = JSON.parse(this.responseText); + callback(wrapResult(url, server_data), url); + } + }; + xhr.send(); +} + +function queryWorker(url, callback) { + var worker = new Worker(url); + worker.onmessage = function(event) { + var server_data = event.data; + callback(wrapResult(url, server_data), url); + }; +} + +function queryFetch(url, callback) { + fetch(url).then(function(response) { + response.json().then(function(server_data) { + callback(wrapResult(url, server_data), url); + }); + } + ); +} + +function queryNavigable(element, url, callback, attributes) { + var navigable = element + navigable.href = url; + navigable.target = "helper-iframe"; + + var helperIframe = document.createElement("iframe") + helperIframe.name = "helper-iframe" + document.body.appendChild(helperIframe) + + // Extend element with attributes. (E.g. "referrer_policy" or "rel") + if (attributes) { + for (var attr in attributes) { + navigable[attr] = attributes[attr]; + } + } + + var listener = function(event) { + if (event.source != helperIframe.contentWindow) + return; + + callback(event.data, url); + window.removeEventListener("message", listener); + } + window.addEventListener("message", listener); + + navigable.click(); +} + +function queryLink(url, callback, referrer_policy) { + var a = document.createElement("a"); + a.innerHTML = "Link to subresource"; + document.body.appendChild(a); + queryNavigable(a, url, callback, referrer_policy) +} + +function queryAreaLink(url, callback, referrer_policy) { + var area = document.createElement("area"); + // TODO(kristijanburnik): Append to map and add image. + document.body.appendChild(area); + queryNavigable(area, url, callback, referrer_policy) +} + +function queryScript(url, callback) { + var script = document.createElement("script"); + script.src = url; + + var listener = function(event) { + var server_data = event.data; + callback(wrapResult(url, server_data), url); + window.removeEventListener("message", listener); + } + window.addEventListener("message", listener); + + document.body.appendChild(script); +} + + // SanityChecker does nothing in release mode. +function SanityChecker() {} +SanityChecker.prototype.checkScenario = function() {}; +SanityChecker.prototype.checkSubresourceResult = function() {}; + +// TODO(kristijanburnik): document.origin is supported since Chrome 41, +// other browsers still don't support it. Remove once they do. +document.origin = document.origin || (location.protocol + "//" + location.host); diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/referrer-policy-test-case.js b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/referrer-policy-test-case.js new file mode 100644 index 00000000000..8e011be374f --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/referrer-policy-test-case.js @@ -0,0 +1,126 @@ +function ReferrerPolicyTestCase(scenario, testDescription, sanityChecker) { + // Pass and skip rest of the test if browser does not support fetch. + if (scenario.subresource == "fetch-request" && !window.fetch) { + // TODO(kristijanburnik): This should be refactored. + return { + start: function() { + test(function() { assert_true(true); }, + "[ReferrerPolicyTestCase] Skipping test: Fetch is not supported."); + } + }; + } + + // This check is A NOOP in release. + sanityChecker.checkScenario(scenario); + + var subresourceInvoker = { + "a-tag": queryLink, + "area-tag": queryAreaLink, + "fetch-request": queryFetch, + "iframe-tag": queryIframe, + "img-tag": queryImage, + "script-tag": queryScript, + "worker-request": queryWorker, + "xhr-request": queryXhr + }; + + var referrerUrlResolver = { + "omitted": function() { + return undefined; + }, + "origin": function() { + return document.origin + "/"; + }, + "stripped-referrer": function() { + return stripUrlForUseAsReferrer(location.toString()); + } + }; + + var t = { + _scenario: scenario, + _testDescription: testDescription, + _subresourceUrl: null, + _expectedReferrerUrl: null, + _constructSubresourceUrl: function() { + // TODO(kristijanburnik): We should assert that these two domains are + // different. E.g. If someone runs the tets over www, this would fail. + var domainForOrigin = { + "cross-origin":"{{domains[www1]}}", + "same-origin": location.hostname + }; + + // Values obtained and replaced by the wptserve pipeline: + // http://wptserve.readthedocs.org/en/latest/pipes.html#built-in-pipes + var portForProtocol = { + "http": parseInt("{{ports[http][0]}}"), + "https": parseInt("{{ports[https][0]}}") + } + + var targetPort = portForProtocol[t._scenario.target_protocol]; + + t._subresourceUrl = t._scenario.target_protocol + "://" + + domainForOrigin[t._scenario.origin] + + normalizePort(targetPort) + + t._scenario["subresource_path"] + + "?redirection=" + t._scenario["redirection"] + + "&cache_destroyer=" + (new Date()).getTime(); + }, + + _constructExpectedReferrerUrl: function() { + t._expectedReferrerUrl = referrerUrlResolver[t._scenario.referrer_url](); + }, + + _invokeSubresource: function(callback) { + var invoker = subresourceInvoker[t._scenario.subresource]; + + // Depending on the delivery method, extend the subresource element with + // these attributes. + var elementAttributesForDeliveryMethod = { + "attr-referrer": {referrerpolicy: t._scenario.referrer_policy}, + "rel-noreferrer": {rel: "noreferrer"} + }; + + var delivery_method = t._scenario.delivery_method; + + if (delivery_method in elementAttributesForDeliveryMethod) { + invoker(t._subresourceUrl, + callback, + elementAttributesForDeliveryMethod[delivery_method]); + } else { + invoker(t._subresourceUrl, callback); + } + + }, + + start: function() { + t._constructSubresourceUrl(); + t._constructExpectedReferrerUrl(); + + var test = async_test(t._testDescription); + + t._invokeSubresource(function(result) { + // Check if the result is in valid format. NOOP in release. + sanityChecker.checkSubresourceResult( + test, t._scenario, t._subresourceUrl, result); + + // Check the reported URL. + test.step(function() { + // TODO - can uncomment when Document::Referrer is implemented + // assert_equals(result.referrer, + // t._expectedReferrerUrl, + // "Reported Referrer URL is '" + + // t._scenario.referrer_url + "'."); + assert_equals(result.headers.referer, + t._expectedReferrerUrl, + "Reported Referrer URL from HTTP header is '" + + t._expectedReferrerUrl + "'"); + }, "Reported Referrer URL is as expected: " + t._scenario.referrer_url); + + test.done(); + }) + + } + } + + return t; +} diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/sanity-checker.js b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/sanity-checker.js new file mode 100644 index 00000000000..e0714885ffc --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/sanity-checker.js @@ -0,0 +1,52 @@ +// The SanityChecker is used in debug mode to identify problems with the +// structure of the testsuite. In release mode it is mocked out to do nothing. + +function SanityChecker() {} + +SanityChecker.prototype.checkScenario = function(scenario) { + // Check if scenario is valid. + // TODO(kristijanburnik): Move to a sanity-checks.js for debug mode only. + test(function() { + + // We extend the exsiting test_expansion_schema not to kill performance by + // copying. + var expectedFields = SPEC_JSON["test_expansion_schema"]; + expectedFields["referrer_policy"] = SPEC_JSON["referrer_policy_schema"]; + + assert_own_property(scenario, "subresource_path", + "Scenario has the path to the subresource."); + + for (var field in expectedFields) { + assert_own_property(scenario, field, + "The scenario contains field " + field) + assert_in_array(scenario[field], expectedFields[field], + "Scenario's " + field + " is one of: " + + expectedFields[field].join(", ")) + "." + } + + // Check if the protocol is matched. + assert_equals(scenario["source_protocol"] + ":", location.protocol, + "Protocol of the test page should match the scenario.") + + }, "[ReferrerPolicyTestCase] The test scenario is valid."); +} + +SanityChecker.prototype.checkSubresourceResult = function(test, + scenario, + subresourceUrl, + result) { + test.step(function() { + assert_equals(Object.keys(result).length, 3); + assert_own_property(result, "location"); + assert_own_property(result, "referrer"); + assert_own_property(result, "headers"); + + // Skip location check for scripts. + if (scenario.subresource == "script-tag") + return; + + // Sanity check: location of sub-resource matches reported location. + assert_equals(result.location, subresourceUrl, + "Subresource reported location."); + }, "Running a valid test scenario."); +}; diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/__init__.py b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/__init__.py new file mode 100755 index 00000000000..e69de29bb2d diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/document.py b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/document.py new file mode 100644 index 00000000000..0c627780dd8 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/document.py @@ -0,0 +1,12 @@ +import os, json, sys +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) + +import mozresource; subresource = mozresource + +def generate_payload(server_data): + return subresource.get_template("document.html.template") % server_data + +def main(request, response): + subresource.respond(request, + response, + payload_generator = generate_payload) diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/image.py b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/image.py new file mode 100644 index 00000000000..31dd61d9b86 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/image.py @@ -0,0 +1,100 @@ +import os, sys, array, json, math, cStringIO +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +import mozresource; subresource = mozresource + +class Image: + """This class partially implements the interface of the PIL.Image.Image. + One day in the future WPT might support the PIL module or another imaging + library, so this hacky BMP implementation will no longer be required. + """ + def __init__(self, width, height): + self.width = width + self.height = height + self.img = bytearray([0 for i in range(3 * width * height)]) + + @staticmethod + def new(mode, size, color=0): + return Image(size[0], size[1]) + + def _int_to_bytes(self, number): + packed_bytes = [0, 0, 0, 0] + for i in range(4): + packed_bytes[i] = number & 0xFF + number >>= 8 + + return packed_bytes + + def putdata(self, color_data): + for y in range(self.height): + for x in range(self.width): + i = x + y * self.width + if i > len(color_data) - 1: + return + + self.img[i * 3: i * 3 + 3] = color_data[i][::-1] + + def save(self, f, type): + assert type == "BMP" + # 54 bytes of preambule + image color data. + filesize = 54 + 3 * self.width * self.height; + # 14 bytes of header. + bmpfileheader = bytearray(['B', 'M'] + self._int_to_bytes(filesize) + + [0, 0, 0, 0, 54, 0, 0, 0]) + # 40 bytes of info. + bmpinfoheader = bytearray([40, 0, 0, 0] + + self._int_to_bytes(self.width) + + self._int_to_bytes(self.height) + + [1, 0, 24] + (25 * [0])) + + padlength = (4 - (self.width * 3) % 4) % 4 + bmppad = bytearray([0, 0, 0]); + padding = bmppad[0 : padlength] + + f.write(bmpfileheader) + f.write(bmpinfoheader) + + for i in range(self.height): + offset = self.width * (self.height - i - 1) * 3 + f.write(self.img[offset : offset + 3 * self.width]) + f.write(padding) + +def encode_string_as_bmp_image(string_data): + data_bytes = array.array("B", string_data) + num_bytes = len(data_bytes) + + # Convert data bytes to color data (RGB). + color_data = [] + num_components = 3 + rgb = [0] * num_components + i = 0 + for byte in data_bytes: + component_index = i % num_components + rgb[component_index] = byte + if component_index == (num_components - 1) or i == (num_bytes - 1): + color_data.append(tuple(rgb)) + rgb = [0] * num_components + i += 1 + + # Render image. + num_pixels = len(color_data) + sqrt = int(math.ceil(math.sqrt(num_pixels))) + img = Image.new("RGB", (sqrt, sqrt), "black") + img.putdata(color_data) + + # Flush image to string. + f = cStringIO.StringIO() + img.save(f, "BMP") + f.seek(0) + + return f.read() + +def generate_payload(server_data): + data = ('{"headers": %(headers)s}') % server_data + return encode_string_as_bmp_image(data) + +def main(request, response): + subresource.respond(request, + response, + payload_generator = generate_payload, + content_type = "image/bmp", + access_control_allow_origin = "*") diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/mozresource.py b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/mozresource.py new file mode 100644 index 00000000000..ca688deebea --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/mozresource.py @@ -0,0 +1,95 @@ +import os, sys, json, urlparse, urllib + +def get_template(template_basename): + script_directory = os.path.dirname(os.path.abspath(__file__)) + template_directory = os.path.abspath(os.path.join(script_directory, + "..", + "template")) + template_filename = os.path.join(template_directory, template_basename); + + with open(template_filename) as f: + return f.read() + +# TODO(kristijanburnik): subdomain_prefix is a hardcoded value aligned with +# referrer-policy-test-case.js. The prefix should be configured in one place. +def get_swapped_origin_netloc(netloc, subdomain_prefix = "www1."): + if netloc.startswith(subdomain_prefix): + return netloc[len(subdomain_prefix):] + else: + return subdomain_prefix + netloc + +def create_redirect_url(request, cross_origin = False): + parsed = urlparse.urlsplit(request.url) + destination_netloc = parsed.netloc + if cross_origin: + destination_netloc = get_swapped_origin_netloc(parsed.netloc) + + query = filter(lambda x: x.startswith('id='), parsed.query.split('&')) + destination_url = urlparse.urlunsplit(urlparse.SplitResult( + scheme = parsed.scheme, + netloc = destination_netloc, + path = parsed.path, + query = query[0] if query else None, + fragment = None)) + + return destination_url + + +def redirect(url, response): + response.add_required_headers = False + response.writer.write_status(301) + response.writer.write_header("access-control-allow-origin", "*") + response.writer.write_header("location", url) + response.writer.end_headers() + response.writer.write("") + + +def preprocess_redirection(request, response): + if "redirection" not in request.GET: + return False + + redirection = request.GET["redirection"] + + if redirection == "no-redirect": + return False + elif redirection == "keep-origin-redirect": + redirect_url = create_redirect_url(request, cross_origin = False) + elif redirection == "swap-origin-redirect": + redirect_url = create_redirect_url(request, cross_origin = True) + else: + raise ValueError("Invalid redirection type '%s'" % redirection) + + redirect(redirect_url, response) + return True + + +def __noop(request, response): + return "" + + +def respond(request, + response, + status_code = 200, + content_type = "text/html", + payload_generator = __noop, + cache_control = "no-cache; must-revalidate", + access_control_allow_origin = "*"): + if preprocess_redirection(request, response): + return + + response.add_required_headers = False + response.writer.write_status(status_code) + + if access_control_allow_origin != None: + response.writer.write_header("access-control-allow-origin", + access_control_allow_origin) + response.writer.write_header("content-type", content_type) + response.writer.write_header("cache-control", cache_control) + response.writer.end_headers() + + server_data = {"headers": json.dumps(request.headers, indent = 4)} + + payload = payload_generator(server_data) + response.writer.write(payload) + + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/script.py b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/script.py new file mode 100644 index 00000000000..907236ccc05 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/script.py @@ -0,0 +1,13 @@ +import os, sys, json +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +import mozresource; subresource = mozresource + +def generate_payload(server_data): + return subresource.get_template("script.js.template") % server_data + +def main(request, response): + subresource.respond(request, + response, + payload_generator = generate_payload, + content_type = "application/javascript") + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/stash.py b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/stash.py new file mode 100644 index 00000000000..0fecca158bb --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/stash.py @@ -0,0 +1,6 @@ +def main(request, response): + print request.GET['id'] + if request.method == 'POST': + request.server.stash.put(request.GET["id"], request.body) + return '' + return request.server.stash.take(request.GET["id"]) diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/worker.py b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/worker.py new file mode 100644 index 00000000000..2d2067bde7d --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/worker.py @@ -0,0 +1,12 @@ +import os, sys, json +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +import mozresource; subresource = mozresource + +def generate_payload(server_data): + return subresource.get_template("worker.js.template") % server_data + +def main(request, response): + subresource.respond(request, + response, + payload_generator = generate_payload, + content_type = "application/javascript") diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/xhr.py b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/xhr.py new file mode 100755 index 00000000000..3ec8fdb082b --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/subresource/xhr.py @@ -0,0 +1,15 @@ +import os, sys, json +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) +import mozresource; subresource = mozresource + +def generate_payload(server_data): + data = ('{"headers": %(headers)s}') % server_data + return data + +def main(request, response): + subresource.respond(request, + response, + payload_generator = generate_payload, + access_control_allow_origin = "*", + content_type = "application/json") + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/template/disclaimer.template b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/template/disclaimer.template new file mode 100644 index 00000000000..66c43ed6f21 --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/template/disclaimer.template @@ -0,0 +1 @@ + diff --git a/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/template/document.html.template b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/template/document.html.template new file mode 100644 index 00000000000..7be7fcc2abf --- /dev/null +++ b/tests/wpt/mozilla/tests/mozilla/referrer-policy/generic/template/document.html.template @@ -0,0 +1,32 @@ + + +
++ +
+ +See specification + details for this test.
+ +Delivery method | +%(delivery_method)s | +
---|---|
Redirection | +%(redirection)s | +
Origin transition | +%(origin)s | +
Protocol transition | +from %(source_protocol)s to %(target_protocol)s | +
Subresource type | +%(subresource)s | +
Expected result | +Referrer URL should be %(referrer_url)s | +