Update web-platform-tests to revision be5419e845d39089ba6dc338c1bd0fa279108317

This commit is contained in:
Josh Matthews 2018-01-04 13:44:24 -05:00
parent aa199307c8
commit 2b6f573eb5
3440 changed files with 109438 additions and 41750 deletions

View file

@ -0,0 +1,2 @@
@inikulin
@mikewest

View file

@ -0,0 +1,2 @@
This directory contains tests for
[Leave Secure Cookies Alone](https://tools.ietf.org/html/draft-ietf-httpbis-cookie-alone-01).

View file

@ -0,0 +1,13 @@
<!DOCTYPE html>
<head>
<meta http-equiv="set-cookie" content="meta-set-cookie=1">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
test(t => {
assert_equals(document.cookie.indexOf('meta-set-cookie'), -1);
}, "Cookie is not set from `<meta>`.");
</script>
</body>

View file

@ -16,32 +16,32 @@
var body = document.getElementsByTagName('body')[0];
var createIframeThen = function (callback) {
var iframe = document.createElement('iframe');
iframe.src = "echo-cookie.html";
iframe.src = "/cookies/resources/echo-cookie.html";
body.appendChild(iframe);
iframe.onload = callback;
return iframe;
};
var testCookiePathFromDOM = function (testCase, test) {
var iframe = createIframeThen(test.step_func(function () {
iframe.contentWindow.setCookie(testCase.name, testCase.path);
var cookieSet = iframe.contentWindow.isCookieSet(testCase.name, testCase.path);
iframe.contentWindow.setCookie('dom-' + testCase.name, testCase.path);
var cookieSet = iframe.contentWindow.isCookieSet('dom-' + testCase.name, testCase.path);
if (testCase.match === false) {
assert_equals(cookieSet, null);
} else {
assert_not_equals(cookieSet, null);
}
iframe.contentWindow.expireCookie(testCase.name, testCase.path);
iframe.contentWindow.expireCookie('dom-' + testCase.name, testCase.path);
test.done();
}));
};
var testCookiePathFromHeader = function (testCase, test) {
var iframe = createIframeThen(test.step_func(function () {
iframe.contentWindow.fetchCookieThen(testCase.name, testCase.path).then(test.step_func(function (response) {
iframe.contentWindow.fetchCookieThen('header-' + testCase.name, testCase.path).then(test.step_func(function (response) {
assert_true(response.ok);
var cookieSet = iframe.contentWindow.isCookieSet(testCase.name, testCase.path);
iframe.contentWindow.expireCookie(testCase.name, testCase.path);
var cookieSet = iframe.contentWindow.isCookieSet('header-' + testCase.name, testCase.path);
iframe.contentWindow.expireCookie('header-' + testCase.name, testCase.path);
if (testCase.match === false) {
assert_equals(cookieSet, null);
} else {
@ -70,7 +70,7 @@ var tests = [{
"path": "/cookies/",
}, {
"name": "match-exact-page",
"path": "/cookies/path/echo-cookie.html",
"path": "/cookies/resources/echo-cookie.html",
}, {
"name": "no-match",
"path": "/cook",
@ -82,9 +82,9 @@ var tests = [{
}];
var domTests = tests.map(function (testCase) {
var testName = "`document.cookie` on /cookies/path/echo-cookie.html sets cookie with path: " + testCase.path;
var testName = "`document.cookie` on /cookies/resources/echo-cookie.html sets cookie with path: " + testCase.path;
if (testCase.match === false) {
testName = "`document.cookie` on /cookies/path/echo-cookie.html DOES NOT set cookie for path: " + testCase.path;
testName = "`document.cookie` on /cookies/resources/echo-cookie.html DOES NOT set cookie for path: " + testCase.path;
}
return [
testName,
@ -95,9 +95,9 @@ var domTests = tests.map(function (testCase) {
});
var headerTests = tests.map(function (testCase) {
var testName = "`Set-Cookie` on /cookies/path/echo-cookie.html sets cookie with path: " + testCase.path;
var testName = "`Set-Cookie` on /cookies/resources/echo-cookie.html sets cookie with path: " + testCase.path;
if (testCase.match === false) {
testName = "`Set-Cookie` on /cookies/path/echo-cookie.html DOES NOT set cookie for path: " + testCase.path;
testName = "`Set-Cookie` on /cookies/resources/echo-cookie.html DOES NOT set cookie for path: " + testCase.path;
}
return [
testName,

View file

@ -8,16 +8,16 @@
<body>
<script>
window.setCookie = function (name, path) {
document.cookie = name + '=1; path = ' + path + ';';
document.cookie = name + '=1; Path=' + path + ';';
}
window.fetchCookieThen = function (name, path) {
return fetch("/cookies/resources/set-cookie.py?name=" + encodeURIComponent(name) + "&path=" + encodeURIComponent(path));
return fetch("/cookies/resources/set-cookie.py?name=" + encodeURIComponent(name) + "&path=" + encodeURIComponent(path), {'credentials': 'include'});
};
window.isCookieSet = function (name, path) {
return document.cookie.match(name + '=1');
};
window.expireCookie = function (name, path) {
document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT; path=' + path + ';';
document.cookie = name + '=0; expires=Thu, 01 Jan 1970 00:00:01 GMT; path=' + path + ';';
};
</script>
</body>