Bug 1490505 [wpt PR 12957] - [csp] Remove cookies following test completion, a=testonly

Automatic update from web-platform-testsMerge pull request #12957 from bocoup/csp-cleanup

[csp] Remove cookies following test completion

Approved by @andypaicu in
https://github.com/web-platform-tests/wpt/pull/12957
--

wpt-commits: 660a69402170f880e9cd17d9c8a5998b47d446bf
wpt-pr: 12957
This commit is contained in:
jugglinmike 2018-10-09 04:14:09 +00:00 коммит произвёл moz-wptsync-bot
Родитель 626095399a
Коммит 28a063eadc
2 изменённых файлов: 22 добавлений и 12 удалений

Просмотреть файл

@ -10,19 +10,25 @@
</head>
<body>
<script>
var test = async_test("Image should not load");
fetch(
"/cookies/resources/set-cookie.py?name=cspViolationReportCookie1&path=" + encodeURIComponent("{{domains[www1]}}:{{ports[http][0]}}/"),
{mode: 'no-cors', credentials: 'include'})
.then(() => {
// This image will generate a CSP violation report.
const img = new Image();
img.onerror = test.step_func_done();
img.onload = test.unreached_func("Should not have loaded the image");
promise_test(function(test) {
const path = encodeURIComponent("{{domains[www1]}}:{{ports[http][0]}}/");
return fetch(
"/cookies/resources/set-cookie.py?name=cspViolationReportCookie1&path=" + path,
{mode: 'no-cors', credentials: 'include'})
.then(() => {
test.add_cleanup(() => {
return fetch("/cookies/resources/set.py?cspViolationReportCookie1=; path=" + path + "; expires=Thu, 01 Jan 1970 00:00:01 GMT");
});
img.src = "../support/fail.png";
document.body.appendChild(img);
});
// This image will generate a CSP violation report.
const img = new Image();
img.onerror = test.step_func_done();
img.onload = test.unreached_func("Should not have loaded the image");
img.src = "../support/fail.png";
document.body.appendChild(img);
});
}, "Image should not load");
</script>
<script async defer src='../support/checkReport.sub.js?reportField=violated-directive&reportValue=img-src%20%27none%27&noCookies=true'></script>

Просмотреть файл

@ -15,6 +15,10 @@
"/cookies/resources/set-cookie.py?name=cspViolationReportCookie2&path=" + encodeURIComponent("/"),
{mode: 'no-cors', credentials: 'include'})
.then(() => {
test.add_cleanup(() => {
document.cookie = "cspViolationReportCookie2=; path=/; expires=Thu, 01 Jan 1970 00:00:01 GMT";
});
// This image will generate a CSP violation report.
const img = new Image();
img.onerror = test.step_func_done();