Changeset 279585 in webkit
- Timestamp:
- Jul 6, 2021, 9:27:29 AM (4 years ago)
- Location:
- trunk/LayoutTests
- Files:
-
- 181 added
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r279582 r279585 1 2021-07-06 Chris Dumez <cdumez@apple.com> 2 3 Resync cookies web-platform-tests from upstream 4 https://bugs.webkit.org/show_bug.cgi?id=227641 5 6 Reviewed by Darin Adler. 7 8 * TestExpectations: 9 * tests-options.json: 10 1 11 2021-07-06 Youenn Fablet <youenn@apple.com> 2 12 -
trunk/LayoutTests/TestExpectations
r279572 r279585 439 439 imported/w3c/web-platform-tests/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-by-feature-policy.tentative.https.sub.html [ Skip ] 440 440 imported/w3c/web-platform-tests/clipboard-apis/feature-policy/clipboard-read/clipboard-read-enabled-on-self-origin-by-feature-policy.tentative.https.sub.html [ Skip ] 441 imported/w3c/web-platform-tests/cookies/domain/domain-attribute-host-with-and-without-leading-period.sub.https.html [ Skip ] 442 imported/w3c/web-platform-tests/cookies/domain/domain-attribute-host-with-leading-period.sub.https.html [ Skip ] 443 imported/w3c/web-platform-tests/cookies/domain/domain-attribute-matches-host.sub.https.html [ Skip ] 444 imported/w3c/web-platform-tests/cookies/domain/domain-attribute-missing.sub.html [ Skip ] 445 imported/w3c/web-platform-tests/cookies/samesite/fetch.https.html [ Skip ] 446 imported/w3c/web-platform-tests/cookies/samesite/form-get-blank-reload.https.html [ Skip ] 447 imported/w3c/web-platform-tests/cookies/samesite/form-get-blank.https.html [ Skip ] 448 imported/w3c/web-platform-tests/cookies/samesite/form-post-blank-reload.https.html [ Skip ] 449 imported/w3c/web-platform-tests/cookies/samesite/form-post-blank.https.html [ Skip ] 450 imported/w3c/web-platform-tests/cookies/samesite/iframe-reload.https.html [ Skip ] 451 imported/w3c/web-platform-tests/cookies/samesite/iframe.https.html [ Skip ] 452 imported/w3c/web-platform-tests/cookies/samesite/img.https.html [ Skip ] 453 imported/w3c/web-platform-tests/cookies/samesite/window-open-reload.https.html [ Skip ] 454 imported/w3c/web-platform-tests/cookies/samesite/window-open.https.html [ Skip ] 441 455 imported/w3c/web-platform-tests/geolocation-API/non-secure-contexts.http.html [ Skip ] 442 456 imported/w3c/web-platform-tests/geolocation-API/getCurrentPosition_permission_allow.https.html [ Skip ] … … 646 660 # Newly imported WPT tests that are flaky. 647 661 webkit.org/b/227649 imported/w3c/web-platform-tests/beacon/beacon-basic.https.window.html [ Failure Pass ] 662 imported/w3c/web-platform-tests/cookies/name/name.html [ Failure Pass ] 663 imported/w3c/web-platform-tests/cookies/prefix/__secure.header.https.html [ Failure Pass ] 664 imported/w3c/web-platform-tests/cookies/samesite-none-secure/cookies-without-samesite-must-be-secure.https.tentative.html [ Failure Pass ] 665 imported/w3c/web-platform-tests/cookies/samesite/about-blank-subresource.https.html [ Failure Pass ] 666 imported/w3c/web-platform-tests/cookies/samesite/about-blank-toplevel.https.html [ Failure Pass ] 667 imported/w3c/web-platform-tests/cookies/samesite/iframe.document.https.html [ Failure Pass ] 668 imported/w3c/web-platform-tests/cookies/samesite/multiple-samesite-attributes.https.html [ Failure Pass ] 669 imported/w3c/web-platform-tests/cookies/samesite/sandbox-iframe-nested.https.html [ Failure Pass ] 670 imported/w3c/web-platform-tests/cookies/samesite/sandbox-iframe-subresource.https.html [ Failure Pass ] 671 imported/w3c/web-platform-tests/cookies/samesite/setcookie-lax.https.html [ Failure Pass ] 672 imported/w3c/web-platform-tests/cookies/samesite/setcookie-navigation.https.html [ Failure Pass ] 673 imported/w3c/web-platform-tests/cookies/schemeful-same-site/schemeful-iframe-subresource.tentative.html [ Failure Pass ] 674 imported/w3c/web-platform-tests/cookies/schemeful-same-site/schemeful-navigation.tentative.html [ Failure Pass ] 675 imported/w3c/web-platform-tests/cookies/schemeful-same-site/schemeful-subresource.tentative.html [ Failure Pass ] 648 676 imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/microtasks/checkpoint-after-window-onerror-module.html [ Failure Pass ] 649 677 imported/w3c/web-platform-tests/html/browsers/windows/targeting-cross-origin-nested-browsing-contexts.html [ Failure Pass ] -
trunk/LayoutTests/imported/w3c/ChangeLog
r279581 r279585 1 2021-07-06 Chris Dumez <cdumez@apple.com> 2 3 Resync cookies web-platform-tests from upstream 4 https://bugs.webkit.org/show_bug.cgi?id=227641 5 6 Reviewed by Darin Adler. 7 8 Resync cookies web-platform-tests from upstream 2c19d6ee62676ac90146. 9 10 * resources/import-expectations.json: 11 * web-platform-tests/cookies/*: Updated. 12 1 13 2021-07-06 Antti Koivisto <antti@apple.com> 2 14 -
trunk/LayoutTests/imported/w3c/resources/import-expectations.json
r279409 r279585 71 71 "web-platform-tests/console": "import", 72 72 "web-platform-tests/content-security-policy": "import", 73 "web-platform-tests/cookies": " skip",73 "web-platform-tests/cookies": "import", 74 74 "web-platform-tests/cookies/resources": "import", 75 75 "web-platform-tests/cookies/secure": "import", -
trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/cookie-helper.sub.js
r253312 r279585 2 2 (_ => { 3 3 var HOST = "{{host}}"; 4 var INSECURE_PORT = ":{{ports[http][0]}}"; 4 5 var SECURE_PORT = ":{{ports[https][0]}}"; 5 var PORT = ":{{ports[http][0]}}";6 6 var CROSS_ORIGIN_HOST = "{{hosts[alt][]}}"; 7 var SECURE_CROSS_ORIGIN_HOST = "{{hosts[alt][]}}"; 7 8 window.INSECURE_ORIGIN = "http://" + HOST + INSECURE_PORT; 8 9 9 10 //For secure cookie verification 10 11 window.SECURE_ORIGIN = "https://" + HOST + SECURE_PORT; 11 window.INSECURE_ORIGIN = "http://" + HOST + PORT;12 12 13 13 //standard references 14 window.ORIGIN = "http://" + HOST + PORT; 15 window.WWW_ORIGIN = "http://{{domains[www]}}" + PORT; 16 window.SUBDOMAIN_ORIGIN = "http://{{domains[www1]}}" + PORT; 17 window.CROSS_SITE_ORIGIN = "http://" + CROSS_ORIGIN_HOST + PORT; 18 window.SECURE_CROSS_SITE_ORIGIN = "https://" + SECURE_CROSS_ORIGIN_HOST + SECURE_PORT; 19 window.CROSS_SITE_HOST = SECURE_CROSS_ORIGIN_HOST; 14 window.SECURE_SUBDOMAIN_ORIGIN = "https://{{domains[www1]}}" + SECURE_PORT; 15 window.SECURE_CROSS_SITE_ORIGIN = "https://" + CROSS_ORIGIN_HOST + SECURE_PORT; 16 window.CROSS_SITE_HOST = CROSS_ORIGIN_HOST; 20 17 21 18 // Set the global cookie name. 22 19 window.HTTP_COOKIE = "cookie_via_http"; 23 24 // If we're not on |HOST|, move ourselves there:25 if (window.location.hostname != HOST)26 window.location.hostname = HOST;27 20 })(); 28 21 29 22 // A tiny helper which returns the result of fetching |url| with credentials. 30 23 function credFetch(url) { 31 return fetch(url, {"credentials": "include"}); 24 return fetch(url, {"credentials": "include"}) 25 .then(response => { 26 if (response.status !== 200) { 27 throw new Error(response.statusText); 28 } 29 return response; 30 }); 32 31 } 33 32 … … 35 34 function redirectTo(origin, url) { 36 35 return origin + "/cookies/resources/redirectWithCORSHeaders.py?status=307&location=" + encodeURIComponent(url); 36 } 37 38 // Returns a URL on |origin| which navigates the window to the given URL (by 39 // setting window.location). 40 function navigateTo(origin, url) { 41 return origin + "/cookies/resources/navigate.html?location=" + encodeURIComponent(url); 37 42 } 38 43 … … 73 78 promise_test(t => { 74 79 var name = options.prefix + "prefixtestcookie"; 75 erase_cookie_from_js(name); 80 erase_cookie_from_js(name, options.params); 81 t.add_cleanup(() => erase_cookie_from_js(name, options.params)); 76 82 var value = "" + Math.random(); 77 83 document.cookie = name + "=" + value + ";" + options.params; … … 87 93 function set_prefixed_cookie_via_http_test(options) { 88 94 promise_test(t => { 89 var postDelete = _ => {90 var value = "" + Math.random();91 return credFetch(options.origin + "/cookies/resources/set.py?" + name + "=" + value + ";" + options.params)92 .then(_ => credFetch(options.origin + "/cookies/resources/list.py"))93 .then(r => r.json())94 .then(cookies => assert_equals(cookies[name], options.shouldExistViaHTTP ? value : undefined));95 };96 97 95 var name = options.prefix + "prefixtestcookie"; 98 if (!options.origin) { 99 options.origin = self.origin; 100 erase_cookie_from_js(name); 101 return postDelete; 102 } else { 103 return credFetch(options.origin + "/cookies/resources/drop.py?name=" + name) 104 .then(_ => postDelete()); 105 } 96 var value = "" + Math.random(); 97 98 t.add_cleanup(() => { 99 var cookie = name + "=0;expires=" + new Date(0).toUTCString() + ";" + 100 options.params; 101 102 return credFetch(options.origin + "/cookies/resources/set.py?" + cookie); 103 }); 104 105 return credFetch(options.origin + "/cookies/resources/set.py?" + name + "=" + value + ";" + options.params) 106 .then(_ => credFetch(options.origin + "/cookies/resources/list.py")) 107 .then(r => r.json()) 108 .then(cookies => assert_equals(cookies[name], options.shouldExistViaHTTP ? value : undefined)); 106 109 }, options.title); 107 110 } … … 111 114 // 112 115 116 // status for "network" cookies. 113 117 window.SameSiteStatus = { 114 118 CROSS_SITE: "cross-site", … … 116 120 STRICT: "strict" 117 121 }; 122 // status for "document.cookie". 123 window.DomSameSiteStatus = { 124 CROSS_SITE: "cross-site", 125 SAME_SITE: "same-site", 126 }; 127 128 const wait_for_message = (type, origin) => { 129 return new Promise((resolve, reject) => { 130 window.addEventListener('message', e => { 131 if (origin && e.origin != origin) { 132 reject("Message from unexpected origin in wait_for_message:" + e.origin); 133 return; 134 } 135 136 if (e.data.type && e.data.type === type) 137 resolve(e); 138 }, { once: true }); 139 }); 140 }; 118 141 119 142 // Reset SameSite test cookies on |origin|. If |origin| matches `self.origin`, assert 120 143 // (via `document.cookie`) that they were properly removed and reset. 121 function resetSameSiteCookies(origin, value) { 122 return credFetch(origin + "/cookies/resources/dropSameSite.py") 123 .then(_ => { 124 if (origin == self.origin) { 125 assert_dom_cookie("samesite_strict", value, false); 126 assert_dom_cookie("samesite_lax", value, false); 127 assert_dom_cookie("samesite_none", value, false); 128 } 129 }) 130 .then(_ => { 131 return credFetch(origin + "/cookies/resources/setSameSite.py?" + value) 132 .then(_ => { 133 if (origin == self.origin) { 134 assert_dom_cookie("samesite_strict", value, true); 135 assert_dom_cookie("samesite_lax", value, true); 136 assert_dom_cookie("samesite_none", value, true); 137 } 138 }) 139 }) 144 async function resetSameSiteCookies(origin, value) { 145 let w = window.open(origin + "/cookies/samesite/resources/puppet.html"); 146 try { 147 await wait_for_message("READY", origin); 148 w.postMessage({type: "drop", useOwnOrigin: true}, "*"); 149 await wait_for_message("drop-complete", origin); 150 if (origin == self.origin) { 151 assert_dom_cookie("samesite_strict", value, false); 152 assert_dom_cookie("samesite_lax", value, false); 153 assert_dom_cookie("samesite_none", value, false); 154 assert_dom_cookie("samesite_unspecified", value, false); 155 } 156 157 w.postMessage({type: "set", value: value, useOwnOrigin: true}, "*"); 158 await wait_for_message("set-complete", origin); 159 if (origin == self.origin) { 160 assert_dom_cookie("samesite_strict", value, true); 161 assert_dom_cookie("samesite_lax", value, true); 162 assert_dom_cookie("samesite_none", value, true); 163 assert_dom_cookie("samesite_unspecified", value, true); 164 } 165 } finally { 166 w.close(); 167 } 140 168 } 141 169 142 170 // Given an |expectedStatus| and |expectedValue|, assert the |cookies| contains the 143 // proper set of cookie names and values. 144 function verifySameSiteCookieState(expectedStatus, expectedValue, cookies) { 145 assert_equals(cookies["samesite_none"], expectedValue, "Non-SameSite cookies are always sent."); 171 // proper set of cookie names and values, according to the legacy behavior where 172 // unspecified SameSite attribute defaults to SameSite=None behavior. 173 function verifySameSiteCookieStateLegacy(expectedStatus, expectedValue, cookies, domCookieStatus) { 174 assert_equals(cookies["samesite_none"], expectedValue, "SameSite=None cookies are always sent."); 175 assert_equals(cookies["samesite_unspecified"], expectedValue, "Unspecified-SameSite cookies are always sent."); 146 176 if (expectedStatus == SameSiteStatus.CROSS_SITE) { 147 177 assert_not_equals(cookies["samesite_strict"], expectedValue, "SameSite=Strict cookies are not sent with cross-site requests."); … … 154 184 assert_equals(cookies["samesite_lax"], expectedValue, "SameSite=Lax cookies are sent with strict requests."); 155 185 } 186 187 if (cookies["domcookies"]) { 188 verifyDocumentCookieLegacy(domCookieStatus, expectedValue, cookies["domcookies"]); 189 } 190 } 191 192 // Same as above except this expects samesite_unspecified to act the same as 193 // samesite_lax (which is the behavior expected when SameSiteByDefault is 194 // enabled). 195 function verifySameSiteCookieStateWithSameSiteByDefault(expectedStatus, expectedValue, cookies, domCookieStatus) { 196 assert_equals(cookies["samesite_none"], expectedValue, "SameSite=None cookies are always sent."); 197 if (expectedStatus == SameSiteStatus.CROSS_SITE) { 198 assert_not_equals(cookies["samesite_strict"], expectedValue, "SameSite=Strict cookies are not sent with cross-site requests."); 199 assert_not_equals(cookies["samesite_lax"], expectedValue, "SameSite=Lax cookies are not sent with cross-site requests."); 200 assert_not_equals(cookies["samesite_unspecified"], expectedValue, "Unspecified-SameSite cookies are not sent with cross-site requests."); 201 } else if (expectedStatus == SameSiteStatus.LAX) { 202 assert_not_equals(cookies["samesite_strict"], expectedValue, "SameSite=Strict cookies are not sent with lax requests."); 203 assert_equals(cookies["samesite_lax"], expectedValue, "SameSite=Lax cookies are sent with lax requests."); 204 assert_equals(cookies["samesite_unspecified"], expectedValue, "Unspecified-SameSite cookies are are sent with lax requests.") 205 } else if (expectedStatus == SameSiteStatus.STRICT) { 206 assert_equals(cookies["samesite_strict"], expectedValue, "SameSite=Strict cookies are sent with strict requests."); 207 assert_equals(cookies["samesite_lax"], expectedValue, "SameSite=Lax cookies are sent with strict requests."); 208 assert_equals(cookies["samesite_unspecified"], expectedValue, "Unspecified-SameSite cookies are are sent with strict requests.") 209 } 210 211 if (cookies["domcookies"]) { 212 verifyDocumentCookieWithSameSiteByDefault(domCookieStatus, expectedValue, cookies["domcookies"]); 213 } 214 } 215 216 function verifyDocumentCookieLegacy(expectedStatus, expectedValue, domcookies) { 217 const cookies = domcookies.split(";") 218 .map(cookie => cookie.trim().split("=")) 219 .reduce((obj, cookie) => { 220 obj[cookie[0]] = cookie[1]; 221 return obj; 222 }, {}); 223 224 if (expectedStatus == DomSameSiteStatus.SAME_SITE) { 225 assert_equals(cookies["samesite_none"], expectedValue, "SameSite=None cookies are always included in document.cookie."); 226 assert_equals(cookies["samesite_unspecified"], expectedValue, "Unspecified-SameSite cookies are always included in document.cookie."); 227 assert_equals(cookies["samesite_strict"], expectedValue, "SameSite=Strict cookies are always included in document.cookie."); 228 assert_equals(cookies["samesite_lax"], expectedValue, "SameSite=Lax cookies are always included in document.cookie."); 229 } else if (expectedStatus == DomSameSiteStatus.CROSS_SITE) { 230 assert_equals(cookies["samesite_none"], expectedValue, "SameSite=None cookies are always included in document.cookie."); 231 assert_equals(cookies["samesite_unspecified"], expectedValue, "Unspecified-SameSite cookies are always included in document.cookie."); 232 assert_not_equals(cookies["samesite_strict"], expectedValue, "SameSite=Strict cookies are not included in document.cookie when cross-site."); 233 assert_not_equals(cookies["samesite_lax"], expectedValue, "SameSite=Lax cookies are not included in document.cookie when cross-site."); 234 } 235 } 236 237 function verifyDocumentCookieWithSameSiteByDefault(expectedStatus, expectedValue, domcookies) { 238 const cookies = domcookies.split(";") 239 .map(cookie => cookie.trim().split("=")) 240 .reduce((obj, cookie) => { 241 obj[cookie[0]] = cookie[1]; 242 return obj; 243 }, {}); 244 245 if (expectedStatus == DomSameSiteStatus.SAME_SITE) { 246 assert_equals(cookies["samesite_none"], expectedValue, "SameSite=None cookies are always included in document.cookie."); 247 assert_equals(cookies["samesite_unspecified"], expectedValue, "Unspecified-SameSite cookies are always included in document.cookie."); 248 assert_equals(cookies["samesite_strict"], expectedValue, "SameSite=Strict cookies are always included in document.cookie."); 249 assert_equals(cookies["samesite_lax"], expectedValue, "SameSite=Lax cookies are always included in document.cookie."); 250 } else if (expectedStatus == DomSameSiteStatus.CROSS_SITE) { 251 assert_equals(cookies["samesite_none"], expectedValue, "SameSite=None cookies are always included in document.cookie."); 252 assert_not_equals(cookies["samesite_unspecified"], expectedValue, "Unspecified-SameSite cookies are not included in document.cookie when cross-site."); 253 assert_not_equals(cookies["samesite_strict"], expectedValue, "SameSite=Strict cookies are not included in document.cookie when cross-site."); 254 assert_not_equals(cookies["samesite_lax"], expectedValue, "SameSite=Lax cookies are not included in document.cookie when cross-site."); 255 } 256 } 257 258 function isLegacySameSite() { 259 return location.search === "?legacy-samesite"; 260 } 261 262 // Get the proper verifier based on the test's variant type. 263 function getSameSiteVerifier() { 264 return isLegacySameSite() ? 265 verifySameSiteCookieStateLegacy : verifySameSiteCookieStateWithSameSiteByDefault; 156 266 } 157 267 … … 180 290 } 181 291 292 // Reset SameSite=None test cookies on |origin|. If |origin| matches 293 // `self.origin`, assert (via `document.cookie`) that they were properly 294 // removed. 295 function resetSameSiteNoneCookies(origin, value) { 296 return credFetch(origin + "/cookies/resources/dropSameSiteNone.py") 297 .then(_ => { 298 if (origin == self.origin) { 299 assert_dom_cookie("samesite_none_insecure", value, false); 300 assert_dom_cookie("samesite_none_secure", value, false); 301 } 302 }) 303 .then(_ => { 304 return credFetch(origin + "/cookies/resources/setSameSiteNone.py?" + value); 305 }) 306 } 307 308 // Reset test cookies with multiple SameSite attributes on |origin|. 309 // If |origin| matches `self.origin`, assert (via `document.cookie`) 310 // that they were properly removed. 311 function resetSameSiteMultiAttributeCookies(origin, value) { 312 return credFetch(origin + "/cookies/resources/dropSameSiteMultiAttribute.py") 313 .then(_ => { 314 if (origin == self.origin) { 315 assert_dom_cookie("samesite_unsupported", value, false); 316 assert_dom_cookie("samesite_unsupported_none", value, false); 317 assert_dom_cookie("samesite_unsupported_lax", value, false); 318 assert_dom_cookie("samesite_unsupported_strict", value, false); 319 assert_dom_cookie("samesite_none_unsupported", value, false); 320 assert_dom_cookie("samesite_lax_unsupported", value, false); 321 assert_dom_cookie("samesite_strict_unsupported", value, false); 322 assert_dom_cookie("samesite_lax_none", value, false); 323 } 324 }) 325 .then(_ => { 326 return credFetch(origin + "/cookies/resources/setSameSiteMultiAttribute.py?" + value); 327 }) 328 } 329 182 330 // 183 331 // DOM based cookie manipulation APIs … … 185 333 186 334 // erase cookie value and set for expiration 187 function erase_cookie_from_js(name) { 188 let secure = self.location.protocol == "https:" ? "Secure" : ""; 189 document.cookie = `${name}=0; path=/; expires=${new Date(0).toUTCString()}; ${secure}`; 335 function erase_cookie_from_js(name, params) { 336 document.cookie = `${name}=0; expires=${new Date(0).toUTCString()}; ${params};`; 190 337 var re = new RegExp("(?:^|; )" + name); 191 338 assert_equals(re.test(document.cookie), false, "Sanity check: " + name + " has been deleted."); -
trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/drop.py
r253312 r279585 1 from helpers import makeDropCookie, readParameter, setNoCacheAndCORSHeaders1 from cookies.resources.helpers import makeDropCookie, readParameter, setNoCacheAndCORSHeaders 2 2 3 3 def main(request, response): … … 6 6 try: 7 7 # Expire the named cookie, and return a JSON-encoded success code. 8 name = readParameter(request, paramName= "name", requireValue=True)8 name = readParameter(request, paramName=u"name", requireValue=True) 9 9 scheme = request.url_parts.scheme 10 headers.append(makeDropCookie(name, 11 return headers, '{"success": true}'10 headers.append(makeDropCookie(name, u"https" == scheme)) 11 return headers, b'{"success": true}' 12 12 except: 13 return 500, headers, '{"error" : "Empty or missing name parameter."}'13 return 500, headers, b'{"error" : "Empty or missing name parameter."}' 14 14 15 -
trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/dropSameSite.py
r253312 r279585 1 from helpers import makeDropCookie, readParameter, setNoCacheAndCORSHeaders1 from cookies.resources.helpers import makeDropCookie, setNoCacheAndCORSHeaders 2 2 3 3 def main(request, response): 4 4 """Respond to `/cookie/same-site/resources/dropSameSite.py by dropping the 5 threecookies set by setSameSiteCookies.py"""5 four cookies set by setSameSiteCookies.py""" 6 6 headers = setNoCacheAndCORSHeaders(request, response) 7 7 8 8 # Expire the cookies, and return a JSON-encoded success code. 9 headers.append(makeDropCookie("samesite_strict", False)) 10 headers.append(makeDropCookie("samesite_lax", False)) 11 headers.append(makeDropCookie("samesite_none", False)) 12 return headers, '{"success": true}' 9 headers.append(makeDropCookie(b"samesite_strict", False)) 10 headers.append(makeDropCookie(b"samesite_lax", False)) 11 headers.append(makeDropCookie(b"samesite_none", False)) 12 headers.append(makeDropCookie(b"samesite_unspecified", False)) 13 return headers, b'{"success": true}' -
trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/dropSecure.py
r253312 r279585 1 from helpers import makeDropCookie, readParameter, setNoCacheAndCORSHeaders1 from cookies.resources.helpers import makeDropCookie, setNoCacheAndCORSHeaders 2 2 3 3 def main(request, response): … … 7 7 8 8 # Expire the cookies, and return a JSON-encoded success code. 9 headers.append(makeDropCookie( "alone_secure", False))10 headers.append(makeDropCookie( "alone_insecure", False))11 return headers, '{"success": true}'9 headers.append(makeDropCookie(b"alone_secure", False)) 10 headers.append(makeDropCookie(b"alone_insecure", False)) 11 return headers, b'{"success": true}' -
trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/echo-cookie.html
r253312 r279585 20 20 document.cookie = name + '=0; expires=Thu, 01 Jan 1970 00:00:01 GMT; path=' + path + ';'; 21 21 }; 22 window.getCookies = () => document.cookie; 22 23 </script> 23 24 </body> -
trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/helpers.py
r253312 r279585 1 import urlparse 1 from urllib.parse import parse_qs 2 3 from wptserve.utils import isomorphic_encode 2 4 3 5 def setNoCacheAndCORSHeaders(request, response): 4 6 """Set Cache-Control, CORS and Content-Type headers appropriate for the cookie tests.""" 5 headers = [( "Content-Type","application/json"),6 ( "Access-Control-Allow-Credentials","true")]7 headers = [(b"Content-Type", b"application/json"), 8 (b"Access-Control-Allow-Credentials", b"true")] 7 9 8 origin = "*"9 if "origin" in request.headers:10 origin = request.headers[ "origin"]10 origin = b"*" 11 if b"origin" in request.headers: 12 origin = request.headers[b"origin"] 11 13 12 headers.append(( "Access-Control-Allow-Origin", origin))14 headers.append((b"Access-Control-Allow-Origin", origin)) 13 15 #headers.append(("Access-Control-Allow-Credentials", "true")) 14 headers.append(( "Cache-Control","no-cache"))15 headers.append(( "Expires","Fri, 01 Jan 1990 00:00:00 GMT"))16 headers.append((b"Cache-Control", b"no-cache")) 17 headers.append((b"Expires", b"Fri, 01 Jan 1990 00:00:00 GMT")) 16 18 17 19 return headers … … 20 22 """Make a Set-Cookie header for a cookie with the name, value and attributes provided.""" 21 23 def makeAV(a, v): 22 if None == v or "" == v:24 if None == v or b"" == v: 23 25 return a 24 return "%s=%s" % (a, v) 26 if isinstance(v, int): 27 return b"%s=%i" % (a, v) 28 else: 29 return b"%s=%s" % (a, v) 25 30 26 31 # ensure cookie name is always first 27 attrs = [ "%s=%s" % (name, value)]28 attrs.extend(makeAV(a, v) for (a, v) in otherAttrs.iteritems())29 return ( "Set-Cookie", "; ".join(attrs))32 attrs = [b"%s=%s" % (name, value)] 33 attrs.extend(makeAV(a, v) for (a, v) in otherAttrs.items()) 34 return (b"Set-Cookie", b"; ".join((attrs))) 30 35 31 36 def makeDropCookie(name, secure): 32 attrs = { "MaxAge": 0, "path":"/"}37 attrs = {b"max-age": 0, b"path": b"/"} 33 38 if secure: 34 attrs[ "secure"] =""35 return makeCookieHeader(name, "", attrs)39 attrs[b"secure"] = b"" 40 return makeCookieHeader(name, b"", attrs) 36 41 37 42 def readParameter(request, paramName, requireValue): 38 43 """Read a parameter from the request. Raise if requireValue is set and the 39 44 parameter has an empty value or is not present.""" 40 params = urlparse.parse_qs(request.url_parts.query)45 params = parse_qs(request.url_parts.query) 41 46 param = params[paramName][0].strip() 42 47 if len(param) == 0: 43 raise Exception( "Empty or missing name parameter.")44 return param48 raise Exception(u"Empty or missing name parameter.") 49 return isomorphic_encode(param) 45 50 46 51 def readCookies(request): … … 53 58 cookies[key] = cookie.value 54 59 return cookies 55 -
trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/imgIfMatch.py
r253312 r279585 1 import helpers1 from cookies.resources import helpers 2 2 3 3 def main(request, response): … … 5 5 the cookie isn't present, and a transparent GIF otherwise.""" 6 6 headers = helpers.setNoCacheAndCORSHeaders(request, response) 7 name = helpers.readParameter(request, paramName= "name", requireValue=True)8 value = helpers.readParameter(request, paramName= "value", requireValue=True)7 name = helpers.readParameter(request, paramName=u"name", requireValue=True) 8 value = helpers.readParameter(request, paramName=u"value", requireValue=True) 9 9 cookiesWithMatchingNames = request.cookies.get_list(name) 10 10 for cookie in cookiesWithMatchingNames: 11 11 if cookie.value == value: 12 12 # From https://github.com/mathiasbynens/small/blob/master/gif-transparent.gif 13 headers.append(( "Content-Type","image/gif"))14 gif = "\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00\x80\x00\x00\xFF\xFF\xFF\x00\x00\x00\x21\xF9\x04\x01\x00\x00\x00\x00\x2C\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02\x44\x01\x00\x3B"13 headers.append((b"Content-Type", b"image/gif")) 14 gif = b"\x47\x49\x46\x38\x39\x61\x01\x00\x01\x00\x80\x00\x00\xFF\xFF\xFF\x00\x00\x00\x21\xF9\x04\x01\x00\x00\x00\x00\x2C\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02\x44\x01\x00\x3B" 15 15 return headers, gif 16 return 500, headers, '{"error": {"message": "The cookie\'s value did not match the given value."}}'16 return 500, headers, b'{"error": {"message": "The cookie\'s value did not match the given value."}}' -
trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/list.py
r253312 r279585 1 1 import json 2 import helpers 2 from cookies.resources import helpers 3 4 from wptserve.utils import isomorphic_decode 3 5 4 6 def main(request, response): 5 7 headers = helpers.setNoCacheAndCORSHeaders(request, response) 6 8 cookies = helpers.readCookies(request) 7 return headers, json.dumps(cookies) 9 decoded_cookies = {isomorphic_decode(key): isomorphic_decode(val) for key, val in cookies.items()} 10 return headers, json.dumps(decoded_cookies) -
trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/postToParent.py
r253312 r279585 1 1 import json 2 import helpers 2 from cookies.resources import helpers 3 4 from wptserve.utils import isomorphic_decode 3 5 4 6 def main(request, response): 5 7 headers = helpers.setNoCacheAndCORSHeaders(request, response) 6 8 cookies = helpers.readCookies(request) 7 headers.append(( "Content-Type","text/html; charset=utf-8"))9 headers.append((b"Content-Type", b"text/html; charset=utf-8")) 8 10 9 tmpl = """11 tmpl = u""" 10 12 <!DOCTYPE html> 11 13 <script> 12 14 var data = %s; 15 data.type = "COOKIES"; 13 16 14 if (window.parent != window) 17 try { 18 data.domcookies = document.cookie; 19 } catch (e) {} 20 21 if (window.parent != window) { 15 22 window.parent.postMessage(data, "*"); 23 if (window.top != window.parent) 24 window.top.postMessage(data, "*"); 25 } 26 16 27 17 28 if (window.opener) … … 25 36 </script> 26 37 """ 27 return headers, tmpl % json.dumps(cookies) 38 decoded_cookies = {isomorphic_decode(key): isomorphic_decode(val) for key, val in cookies.items()} 39 return headers, tmpl % json.dumps(decoded_cookies) -
trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/redirectWithCORSHeaders.py
r253312 r279585 1 from helpers import setNoCacheAndCORSHeaders1 from cookies.resources.helpers import setNoCacheAndCORSHeaders 2 2 3 3 def main(request, response): … … 9 9 """ 10 10 status = 302 11 if "status" in request.GET:11 if b"status" in request.GET: 12 12 try: 13 status = int(request.GET.first( "status"))13 status = int(request.GET.first(b"status")) 14 14 except ValueError: 15 15 pass 16 16 headers = setNoCacheAndCORSHeaders(request, response) 17 17 18 location = request.GET.first( "location")18 location = request.GET.first(b"location") 19 19 20 headers.append(( "Location", location))20 headers.append((b"Location", location)) 21 21 22 return status, headers, ""22 return status, headers, b"" -
trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/set.py
r253312 r279585 1 import helpers 1 from cookies.resources import helpers 2 from urllib.parse import unquote 3 4 from wptserve.utils import isomorphic_encode 2 5 3 6 def main(request, response): 4 7 """Respond to `/cookie/set?{cookie}` by echoing `{cookie}` as a `Set-Cookie` header.""" 5 8 headers = helpers.setNoCacheAndCORSHeaders(request, response) 6 headers.append(("Set-Cookie", request.url_parts.query)) 7 return headers, '{"success": true}' 9 10 # Cookies may require whitespace (e.g. in the `Expires` attribute), so the 11 # query string should be decoded. 12 cookie = unquote(request.url_parts.query) 13 headers.append((b"Set-Cookie", isomorphic_encode(cookie))) 14 15 return headers, b'{"success": true}' -
trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/setSameSite.py
r253312 r279585 1 from helpers import makeCookieHeader, readParameter, setNoCacheAndCORSHeaders 1 from cookies.resources.helpers import makeCookieHeader, setNoCacheAndCORSHeaders 2 3 from wptserve.utils import isomorphic_encode 2 4 3 5 def main(request, response): 4 """Respond to `/cookie/set/samesite?{value}` by setting threecookies:6 """Respond to `/cookie/set/samesite?{value}` by setting four cookies: 5 7 1. `samesite_strict={value};SameSite=Strict;path=/` 6 8 2. `samesite_lax={value};SameSite=Lax;path=/` 7 3. `samesite_none={value};path=/`""" 9 3. `samesite_none={value};SameSite=None;path=/` 10 4. `samesite_unspecified={value};path=/` 11 Then navigate to a page that will post a message back to the opener with the set cookies""" 8 12 headers = setNoCacheAndCORSHeaders(request, response) 9 value = request.url_parts.query13 value = isomorphic_encode(request.url_parts.query) 10 14 11 headers.append(makeCookieHeader("samesite_strict", value, {"SameSite":"Strict","path":"/"})) 12 headers.append(makeCookieHeader("samesite_lax", value, {"SameSite":"Lax","path":"/"})) 13 headers.append(makeCookieHeader("samesite_none", value, {"path":"/"})) 14 return headers, '{"success": true}' 15 headers.append((b"Content-Type", b"text/html; charset=utf-8")) 16 headers.append(makeCookieHeader(b"samesite_strict", value, {b"SameSite":b"Strict", b"path":b"/"})) 17 headers.append(makeCookieHeader(b"samesite_lax", value, {b"SameSite":b"Lax", b"path":b"/"})) 18 # SameSite=None cookies must be Secure. 19 headers.append(makeCookieHeader(b"samesite_none", value, {b"SameSite":b"None", b"path":b"/", b"Secure": b""})) 20 headers.append(makeCookieHeader(b"samesite_unspecified", value, {b"path":b"/"})) 21 22 document = b""" 23 <!DOCTYPE html> 24 <script> 25 // A same-site navigation, which should attach all cookies including SameSite ones. 26 // This is necessary because this page may have been reached via a cross-site navigation, so 27 // we might not have access to some SameSite cookies from here. 28 window.location = "../samesite/resources/echo-cookies.html"; 29 </script> 30 """ 31 32 return headers, document -
trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/setSecure.py
r253312 r279585 1 from helpers import makeCookieHeader, readParameter, setNoCacheAndCORSHeaders 1 from cookies.resources.helpers import makeCookieHeader, readParameter, setNoCacheAndCORSHeaders 2 3 from wptserve.utils import isomorphic_encode 2 4 3 5 def main(request, response): … … 6 8 alone_insecure={value};path=/""" 7 9 headers = setNoCacheAndCORSHeaders(request, response) 8 value = request.url_parts.query10 value = isomorphic_encode(request.url_parts.query) 9 11 10 headers.append(makeCookieHeader( "alone_secure", value, {"secure": "","path":"/"}))11 headers.append(makeCookieHeader( "alone_insecure", value, {"path":"/"}))12 return headers, '{"success": true}'12 headers.append(makeCookieHeader(b"alone_secure", value, {b"secure": b"", b"path": b"/"})) 13 headers.append(makeCookieHeader(b"alone_insecure", value, {b"path": b"/"})) 14 return headers, b'{"success": true}' -
trunk/LayoutTests/tests-options.json
r279427 r279585 615 615 "slow" 616 616 ], 617 "imported/w3c/web-platform-tests/cookies/attributes/domain.sub.html": [ 618 "slow" 619 ], 620 "imported/w3c/web-platform-tests/cookies/attributes/expires.html": [ 621 "slow" 622 ], 623 "imported/w3c/web-platform-tests/cookies/attributes/invalid.html": [ 624 "slow" 625 ], 626 "imported/w3c/web-platform-tests/cookies/attributes/max-age.html": [ 627 "slow" 628 ], 629 "imported/w3c/web-platform-tests/cookies/attributes/path-redirect.html": [ 630 "slow" 631 ], 632 "imported/w3c/web-platform-tests/cookies/attributes/path.html": [ 633 "slow" 634 ], 635 "imported/w3c/web-platform-tests/cookies/attributes/resources/domain-child.sub.html": [ 636 "slow" 637 ], 638 "imported/w3c/web-platform-tests/cookies/attributes/resources/secure-non-secure-child.html": [ 639 "slow" 640 ], 641 "imported/w3c/web-platform-tests/cookies/attributes/secure-non-secure.html": [ 642 "slow" 643 ], 644 "imported/w3c/web-platform-tests/cookies/attributes/secure.https.html": [ 645 "slow" 646 ], 647 "imported/w3c/web-platform-tests/cookies/encoding/charset.html": [ 648 "slow" 649 ], 650 "imported/w3c/web-platform-tests/cookies/name/name-ctl.html": [ 651 "slow" 652 ], 653 "imported/w3c/web-platform-tests/cookies/name/name.html": [ 654 "slow" 655 ], 656 "imported/w3c/web-platform-tests/cookies/ordering/ordering.sub.html": [ 657 "slow" 658 ], 659 "imported/w3c/web-platform-tests/cookies/ordering/resources/ordering-child.sub.html": [ 660 "slow" 661 ], 662 "imported/w3c/web-platform-tests/cookies/path/match.html": [ 663 "slow" 664 ], 665 "imported/w3c/web-platform-tests/cookies/samesite-none-secure/cookies-without-samesite-must-be-secure.https.tentative.html": [ 666 "slow" 667 ], 668 "imported/w3c/web-platform-tests/cookies/samesite/fetch.https.html": [ 669 "slow" 670 ], 671 "imported/w3c/web-platform-tests/cookies/samesite/form-get-blank.https.html": [ 672 "slow" 673 ], 674 "imported/w3c/web-platform-tests/cookies/samesite/form-post-blank.https.html": [ 675 "slow" 676 ], 677 "imported/w3c/web-platform-tests/cookies/samesite/iframe-reload.https.html": [ 678 "slow" 679 ], 680 "imported/w3c/web-platform-tests/cookies/samesite/iframe.document.https.html": [ 681 "slow" 682 ], 683 "imported/w3c/web-platform-tests/cookies/samesite/iframe.https.html": [ 684 "slow" 685 ], 686 "imported/w3c/web-platform-tests/cookies/samesite/img.https.html": [ 687 "slow" 688 ], 689 "imported/w3c/web-platform-tests/cookies/samesite/multiple-samesite-attributes.https.html": [ 690 "slow" 691 ], 692 "imported/w3c/web-platform-tests/cookies/samesite/setcookie-navigation.https.html": [ 693 "slow" 694 ], 695 "imported/w3c/web-platform-tests/cookies/samesite/window-open.https.html": [ 696 "slow" 697 ], 698 "imported/w3c/web-platform-tests/cookies/schemeful-same-site/schemeful-navigation.tentative.html": [ 699 "slow" 700 ], 701 "imported/w3c/web-platform-tests/cookies/schemeful-same-site/schemeful-subresource.tentative.html": [ 702 "slow" 703 ], 704 "imported/w3c/web-platform-tests/cookies/value/value-ctl.html": [ 705 "slow" 706 ], 707 "imported/w3c/web-platform-tests/cookies/value/value.html": [ 708 "slow" 709 ], 617 710 "imported/w3c/web-platform-tests/cors/304.htm": [ 618 711 "slow"
Note:
See TracChangeset
for help on using the changeset viewer.