Title: [253312] trunk/LayoutTests
Revision
253312
Author
[email protected]
Date
2019-12-09 17:48:58 -0800 (Mon, 09 Dec 2019)

Log Message

Import secure cookie tests from WPT
https://bugs.webkit.org/show_bug.cgi?id=204193

Reviewed by Carlos Alberto Lopez Perez.

LayoutTests/imported/w3c:

* resources/import-expectations.json:
* web-platform-tests/cookies/resources/cookie-helper.sub.js: Added.
(credFetch):
(assert_dom_cookie):
(assert_cookie):
(resetSameSiteCookies):
(resetSecureCookies):
* web-platform-tests/cookies/resources/drop.py: Added.
(main):
* web-platform-tests/cookies/resources/dropSameSite.py: Added.
(main):
* web-platform-tests/cookies/resources/dropSecure.py: Added.
(main):
* web-platform-tests/cookies/resources/echo-cookie.html: Added.
* web-platform-tests/cookies/resources/echo-json.py: Added.
(main):
* web-platform-tests/cookies/resources/helpers.py: Added.
(setNoCacheAndCORSHeaders):
(makeCookieHeader):
(makeCookieHeader.makeAV):
(makeDropCookie):
(readParameter):
(readCookies):
* web-platform-tests/cookies/resources/imgIfMatch.py: Added.
(main):
* web-platform-tests/cookies/resources/list.py: Added.
(main):
* web-platform-tests/cookies/resources/postToParent.py: Added.
(main):
* web-platform-tests/cookies/resources/redirectWithCORSHeaders.py: Added.
(main):
* web-platform-tests/cookies/resources/set-cookie.py: Added.
(main):
* web-platform-tests/cookies/resources/set.py: Added.
(main):
* web-platform-tests/cookies/resources/setSameSite.py: Added.
(main):
* web-platform-tests/cookies/resources/setSecure.py: Added.
(main):
* web-platform-tests/cookies/resources/testharness-helpers.js: Added.
(executeNextTest):
(executeTestsSerially):
* web-platform-tests/cookies/secure/set-from-dom.https.sub-expected.txt: Added.
* web-platform-tests/cookies/secure/set-from-dom.https.sub.html: Added.
* web-platform-tests/cookies/secure/set-from-dom.sub-expected.txt: Added.
* web-platform-tests/cookies/secure/set-from-dom.sub.html: Added.
* web-platform-tests/cookies/secure/set-from-http.https.sub-expected.txt: Added.
* web-platform-tests/cookies/secure/set-from-http.https.sub.html: Added.
* web-platform-tests/cookies/secure/set-from-http.https.sub.html.headers: Added.
* web-platform-tests/cookies/secure/set-from-http.sub-expected.txt: Added.
* web-platform-tests/cookies/secure/set-from-http.sub.html: Added.
* web-platform-tests/cookies/secure/set-from-http.sub.html.headers: Added.
* web-platform-tests/cookies/secure/set-from-ws.sub-expected.txt: Added.
* web-platform-tests/cookies/secure/set-from-ws.sub.html: Added.
* web-platform-tests/cookies/secure/set-from-wss.https.sub-expected.txt: Added.
* web-platform-tests/cookies/secure/set-from-wss.https.sub.html: Added.

LayoutTests:

Mark newly imported test as failing.
Pending fix for WPE/GTK in webkit.org/b/169356

* platform/gtk/TestExpectations:
* platform/mac-wk1/TestExpectations:
* platform/wpe/TestExpectations:
* platform/ios-wk2/imported/w3c/web-platform-tests/content-security-policy/reporting/report-same-origin-with-cookies-expected.txt: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (253311 => 253312)


--- trunk/LayoutTests/ChangeLog	2019-12-10 01:12:02 UTC (rev 253311)
+++ trunk/LayoutTests/ChangeLog	2019-12-10 01:48:58 UTC (rev 253312)
@@ -1,3 +1,18 @@
+2019-12-09  Patrick Griffis  <[email protected]>
+
+        Import secure cookie tests from WPT
+        https://bugs.webkit.org/show_bug.cgi?id=204193
+
+        Reviewed by Carlos Alberto Lopez Perez.
+
+        Mark newly imported test as failing.
+        Pending fix for WPE/GTK in webkit.org/b/169356
+
+        * platform/gtk/TestExpectations:
+        * platform/mac-wk1/TestExpectations:
+        * platform/wpe/TestExpectations:
+        * platform/ios-wk2/imported/w3c/web-platform-tests/content-security-policy/reporting/report-same-origin-with-cookies-expected.txt: Added.
+
 2019-12-09  Megan Gardner  <[email protected]>
 
         Fill HighlightRangeGroup and HighlightMap with values from _javascript_

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (253311 => 253312)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2019-12-10 01:12:02 UTC (rev 253311)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2019-12-10 01:48:58 UTC (rev 253312)
@@ -1,3 +1,67 @@
+2019-12-09  Patrick Griffis  <[email protected]>
+
+        Import secure cookie tests from WPT
+        https://bugs.webkit.org/show_bug.cgi?id=204193
+
+        Reviewed by Carlos Alberto Lopez Perez.
+
+        * resources/import-expectations.json:
+        * web-platform-tests/cookies/resources/cookie-helper.sub.js: Added.
+        (credFetch):
+        (assert_dom_cookie):
+        (assert_cookie):
+        (resetSameSiteCookies):
+        (resetSecureCookies):
+        * web-platform-tests/cookies/resources/drop.py: Added.
+        (main):
+        * web-platform-tests/cookies/resources/dropSameSite.py: Added.
+        (main):
+        * web-platform-tests/cookies/resources/dropSecure.py: Added.
+        (main):
+        * web-platform-tests/cookies/resources/echo-cookie.html: Added.
+        * web-platform-tests/cookies/resources/echo-json.py: Added.
+        (main):
+        * web-platform-tests/cookies/resources/helpers.py: Added.
+        (setNoCacheAndCORSHeaders):
+        (makeCookieHeader):
+        (makeCookieHeader.makeAV):
+        (makeDropCookie):
+        (readParameter):
+        (readCookies):
+        * web-platform-tests/cookies/resources/imgIfMatch.py: Added.
+        (main):
+        * web-platform-tests/cookies/resources/list.py: Added.
+        (main):
+        * web-platform-tests/cookies/resources/postToParent.py: Added.
+        (main):
+        * web-platform-tests/cookies/resources/redirectWithCORSHeaders.py: Added.
+        (main):
+        * web-platform-tests/cookies/resources/set-cookie.py: Added.
+        (main):
+        * web-platform-tests/cookies/resources/set.py: Added.
+        (main):
+        * web-platform-tests/cookies/resources/setSameSite.py: Added.
+        (main):
+        * web-platform-tests/cookies/resources/setSecure.py: Added.
+        (main):
+        * web-platform-tests/cookies/resources/testharness-helpers.js: Added.
+        (executeNextTest):
+        (executeTestsSerially):
+        * web-platform-tests/cookies/secure/set-from-dom.https.sub-expected.txt: Added.
+        * web-platform-tests/cookies/secure/set-from-dom.https.sub.html: Added.
+        * web-platform-tests/cookies/secure/set-from-dom.sub-expected.txt: Added.
+        * web-platform-tests/cookies/secure/set-from-dom.sub.html: Added.
+        * web-platform-tests/cookies/secure/set-from-http.https.sub-expected.txt: Added.
+        * web-platform-tests/cookies/secure/set-from-http.https.sub.html: Added.
+        * web-platform-tests/cookies/secure/set-from-http.https.sub.html.headers: Added.
+        * web-platform-tests/cookies/secure/set-from-http.sub-expected.txt: Added.
+        * web-platform-tests/cookies/secure/set-from-http.sub.html: Added.
+        * web-platform-tests/cookies/secure/set-from-http.sub.html.headers: Added.
+        * web-platform-tests/cookies/secure/set-from-ws.sub-expected.txt: Added.
+        * web-platform-tests/cookies/secure/set-from-ws.sub.html: Added.
+        * web-platform-tests/cookies/secure/set-from-wss.https.sub-expected.txt: Added.
+        * web-platform-tests/cookies/secure/set-from-wss.https.sub.html: Added.
+
 2019-12-09  youenn fablet  <[email protected]>
 
         NetworkResourceLoader should consume its sandbox extensions when starting a fetch through service worker

Modified: trunk/LayoutTests/imported/w3c/resources/import-expectations.json (253311 => 253312)


--- trunk/LayoutTests/imported/w3c/resources/import-expectations.json	2019-12-10 01:12:02 UTC (rev 253311)
+++ trunk/LayoutTests/imported/w3c/resources/import-expectations.json	2019-12-10 01:48:58 UTC (rev 253312)
@@ -57,6 +57,8 @@
     "web-platform-tests/console": "skip", 
     "web-platform-tests/content-security-policy": "import", 
     "web-platform-tests/cookies": "skip", 
+    "web-platform-tests/cookies/resources": "import", 
+    "web-platform-tests/cookies/secure": "import", 
     "web-platform-tests/core-aam": "skip", 
     "web-platform-tests/cors": "import", 
     "web-platform-tests/credential-management": "import", 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/reporting/report-same-origin-with-cookies-expected.txt (253311 => 253312)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/reporting/report-same-origin-with-cookies-expected.txt	2019-12-10 01:12:02 UTC (rev 253311)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/reporting/report-same-origin-with-cookies-expected.txt	2019-12-10 01:48:58 UTC (rev 253312)
@@ -2,5 +2,5 @@
 
 PASS Image should not load 
 PASS Violation report status OK. 
-FAIL Test report cookies. assert_true: Report should contain cookie: cspViolationReportCookie2 expected true got false
+PASS Test report cookies. 
 

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/cookie-helper.sub.js (0 => 253312)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/cookie-helper.sub.js	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/cookie-helper.sub.js	2019-12-10 01:48:58 UTC (rev 253312)
@@ -0,0 +1,192 @@
+// Set up exciting global variables for cookie tests.
+(_ => {
+  var HOST = "{{host}}";
+  var SECURE_PORT = ":{{ports[https][0]}}";
+  var PORT = ":{{ports[http][0]}}";
+  var CROSS_ORIGIN_HOST = "{{hosts[alt][]}}";
+  var SECURE_CROSS_ORIGIN_HOST = "{{hosts[alt][]}}";
+
+  //For secure cookie verification
+  window.SECURE_ORIGIN = "https://" + HOST + SECURE_PORT;
+  window.INSECURE_ORIGIN = "http://" + HOST + PORT;
+
+  //standard references
+  window.ORIGIN = "http://" + HOST + PORT;
+  window.WWW_ORIGIN = "http://{{domains[www]}}" + PORT;
+  window.SUBDOMAIN_ORIGIN = "http://{{domains[www1]}}" + PORT;
+  window.CROSS_SITE_ORIGIN = "http://" + CROSS_ORIGIN_HOST + PORT;
+  window.SECURE_CROSS_SITE_ORIGIN = "https://" + SECURE_CROSS_ORIGIN_HOST + SECURE_PORT;
+  window.CROSS_SITE_HOST = SECURE_CROSS_ORIGIN_HOST;
+
+  // Set the global cookie name.
+  window.HTTP_COOKIE = "cookie_via_http";
+
+  // If we're not on |HOST|, move ourselves there:
+  if (window.location.hostname != HOST)
+    window.location.hostname = HOST;
+})();
+
+// A tiny helper which returns the result of fetching |url| with credentials.
+function credFetch(url) {
+  return fetch(url, {"credentials": "include"});
+}
+
+// Returns a URL on |origin| which redirects to a given absolute URL.
+function redirectTo(origin, url) {
+  return origin + "/cookies/resources/redirectWithCORSHeaders.py?status=307&location=" + encodeURIComponent(url);
+}
+
+// Asserts that `document.cookie` contains or does not contain (according to
+// the value of |present|) a cookie named |name| with a value of |value|.
+function assert_dom_cookie(name, value, present) {
+  var re = new RegExp("(?:^|; )" + name + "=" + value + "(?:$|;)");
+  assert_equals(re.test(document.cookie), present, "`" + name + "=" + value + "` in `document.cookie`");
+}
+
+function assert_cookie(origin, obj, name, value, present) {
+  assert_equals(obj[name], present ? value : undefined, "`" + name + "=" + value + "` in request to `" + origin + "`.");
+}
+
+// Remove the cookie named |name| from |origin|, then set it on |origin| anew.
+// If |origin| matches `self.origin`, also assert (via `document.cookie`) that
+// the cookie was correctly removed and reset.
+function create_cookie(origin, name, value, extras) {
+  alert("Create_cookie: " + origin + "/cookies/resources/drop.py?name=" + name);
+  return credFetch(origin + "/cookies/resources/drop.py?name=" + name)
+    .then(_ => {
+      if (origin == self.origin)
+        assert_dom_cookie(name, value, false);
+    })
+    .then(_ => {
+      return credFetch(origin + "/cookies/resources/set.py?" + name + "=" + value + ";path=/;" + extras)
+        .then(_ => {
+          if (origin == self.origin)
+            assert_dom_cookie(name, value, true);
+        });
+    });
+}
+
+//
+// Prefix-specific test helpers
+//
+function set_prefixed_cookie_via_dom_test(options) {
+  promise_test(t => {
+    var name = options.prefix + "prefixtestcookie";
+    erase_cookie_from_js(name);
+    var value = "" + Math.random();
+    document.cookie = name + "=" + value + ";" + options.params;
+
+    assert_dom_cookie(name, value, options.shouldExistInDOM);
+
+    return credFetch("/cookies/resources/list.py")
+      .then(r => r.json())
+      .then(cookies => assert_equals(cookies[name], options.shouldExistViaHTTP ? value : undefined));
+  }, options.title);
+}
+
+function set_prefixed_cookie_via_http_test(options) {
+  promise_test(t => {
+    var postDelete = _ => {
+      var value = "" + Math.random();
+      return credFetch(options.origin + "/cookies/resources/set.py?" + name + "=" + value + ";" + options.params)
+        .then(_ => credFetch(options.origin + "/cookies/resources/list.py"))
+        .then(r => r.json())
+        .then(cookies => assert_equals(cookies[name], options.shouldExistViaHTTP ? value : undefined));
+    };
+
+    var name = options.prefix + "prefixtestcookie";
+    if (!options.origin) {
+      options.origin = self.origin;
+      erase_cookie_from_js(name);
+      return postDelete;
+    } else {
+      return credFetch(options.origin + "/cookies/resources/drop.py?name=" + name)
+        .then(_ => postDelete());
+    }
+  }, options.title);
+}
+
+//
+// SameSite-specific test helpers:
+//
+
+window.SameSiteStatus = {
+  CROSS_SITE: "cross-site",
+  LAX: "lax",
+  STRICT: "strict"
+};
+
+// Reset SameSite test cookies on |origin|. If |origin| matches `self.origin`, assert
+// (via `document.cookie`) that they were properly removed and reset.
+function resetSameSiteCookies(origin, value) {
+  return credFetch(origin + "/cookies/resources/dropSameSite.py")
+    .then(_ => {
+      if (origin == self.origin) {
+        assert_dom_cookie("samesite_strict", value, false);
+        assert_dom_cookie("samesite_lax", value, false);
+        assert_dom_cookie("samesite_none", value, false);
+      }
+    })
+    .then(_ => {
+      return credFetch(origin + "/cookies/resources/setSameSite.py?" + value)
+        .then(_ => {
+          if (origin == self.origin) {
+            assert_dom_cookie("samesite_strict", value, true);
+            assert_dom_cookie("samesite_lax", value, true);
+            assert_dom_cookie("samesite_none", value, true);
+          }
+        })
+    })
+}
+
+// Given an |expectedStatus| and |expectedValue|, assert the |cookies| contains the
+// proper set of cookie names and values.
+function verifySameSiteCookieState(expectedStatus, expectedValue, cookies) {
+    assert_equals(cookies["samesite_none"], expectedValue, "Non-SameSite cookies are always sent.");
+    if (expectedStatus == SameSiteStatus.CROSS_SITE) {
+      assert_not_equals(cookies["samesite_strict"], expectedValue, "SameSite=Strict cookies are not sent with cross-site requests.");
+      assert_not_equals(cookies["samesite_lax"], expectedValue, "SameSite=Lax cookies are not sent with cross-site requests.");
+    } else if (expectedStatus == SameSiteStatus.LAX) {
+      assert_not_equals(cookies["samesite_strict"], expectedValue, "SameSite=Strict cookies are not sent with lax requests.");
+      assert_equals(cookies["samesite_lax"], expectedValue, "SameSite=Lax cookies are sent with lax requests.");
+    } else if (expectedStatus == SameSiteStatus.STRICT) {
+      assert_equals(cookies["samesite_strict"], expectedValue, "SameSite=Strict cookies are sent with strict requests.");
+      assert_equals(cookies["samesite_lax"], expectedValue, "SameSite=Lax cookies are sent with strict requests.");
+    }
+}
+
+//
+// LeaveSecureCookiesAlone-specific test helpers:
+//
+
+window.SecureStatus = {
+  INSECURE_COOKIE_ONLY: "1",
+  BOTH_COOKIES: "2",
+};
+
+//Reset SameSite test cookies on |origin|. If |origin| matches `self.origin`, assert
+//(via `document.cookie`) that they were properly removed and reset.
+function resetSecureCookies(origin, value) {
+return credFetch(origin + "/cookies/resources/dropSecure.py")
+ .then(_ => {
+   if (origin == self.origin) {
+     assert_dom_cookie("alone_secure", value, false);
+     assert_dom_cookie("alone_insecure", value, false);
+   }
+ })
+ .then(_ => {
+     return credFetch(origin + "/cookie/resources/setSecure.py?" + value)
+ })
+}
+
+//
+// DOM based cookie manipulation APIs
+//
+
+// erase cookie value and set for expiration
+function erase_cookie_from_js(name) {
+  let secure = self.location.protocol == "https:" ? "Secure" : "";
+  document.cookie = `${name}=0; path=/; expires=${new Date(0).toUTCString()}; ${secure}`;
+  var re = new RegExp("(?:^|; )" + name);
+  assert_equals(re.test(document.cookie), false, "Sanity check: " + name + " has been deleted.");
+}

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/drop.py (0 => 253312)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/drop.py	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/drop.py	2019-12-10 01:48:58 UTC (rev 253312)
@@ -0,0 +1,15 @@
+from helpers import makeDropCookie, readParameter, setNoCacheAndCORSHeaders
+
+def main(request, response):
+    """Respond to `/cookie/drop?name={name}` by expiring the cookie named `{name}`."""
+    headers = setNoCacheAndCORSHeaders(request, response)
+    try:
+        # Expire the named cookie, and return a JSON-encoded success code.
+        name = readParameter(request, paramName="name", requireValue=True)
+        scheme = request.url_parts.scheme
+        headers.append(makeDropCookie(name,  "https" == scheme))
+        return headers, '{"success": true}'
+    except:
+        return 500, headers, '{"error" : "Empty or missing name parameter."}'
+
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/dropSameSite.py (0 => 253312)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/dropSameSite.py	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/dropSameSite.py	2019-12-10 01:48:58 UTC (rev 253312)
@@ -0,0 +1,12 @@
+from helpers import makeDropCookie, readParameter, setNoCacheAndCORSHeaders
+
+def main(request, response):
+    """Respond to `/cookie/same-site/resources/dropSameSite.py by dropping the
+    three cookies set by setSameSiteCookies.py"""
+    headers = setNoCacheAndCORSHeaders(request, response)
+
+    # Expire the cookies, and return a JSON-encoded success code.
+    headers.append(makeDropCookie("samesite_strict", False))
+    headers.append(makeDropCookie("samesite_lax", False))
+    headers.append(makeDropCookie("samesite_none", False))
+    return headers, '{"success": true}'

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/dropSecure.py (0 => 253312)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/dropSecure.py	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/dropSecure.py	2019-12-10 01:48:58 UTC (rev 253312)
@@ -0,0 +1,11 @@
+from helpers import makeDropCookie, readParameter, setNoCacheAndCORSHeaders
+
+def main(request, response):
+    """Respond to `/cookie/drop/secure` by dropping the two cookie set by
+    `setSecureTestCookies()`"""
+    headers = setNoCacheAndCORSHeaders(request, response)
+
+    # Expire the cookies, and return a JSON-encoded success code.
+    headers.append(makeDropCookie("alone_secure", False))
+    headers.append(makeDropCookie("alone_insecure", False))
+    return headers, '{"success": true}'

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/echo-cookie.html (0 => 253312)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/echo-cookie.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/echo-cookie.html	2019-12-10 01:48:58 UTC (rev 253312)
@@ -0,0 +1,24 @@
+<!doctype html>
+<html>
+<head>
+  <meta charset=utf-8>
+  <title>helper iframe for matching cookie path tests</title>
+  <meta name=help href=""
+</head>
+<body>
+<script>
+window.setCookie = function (name, 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), {'credentials': 'include'});
+};
+window.isCookieSet = function (name, path) {
+  return document.cookie.match(name + '=1');
+};
+window.expireCookie = function (name, path) {
+  document.cookie = name + '=0; expires=Thu, 01 Jan 1970 00:00:01 GMT; path=' + path + ';';
+};
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/echo-json.py (0 => 253312)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/echo-json.py	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/echo-json.py	2019-12-10 01:48:58 UTC (rev 253312)
@@ -0,0 +1,15 @@
+import json
+
+def main(request, response):
+    headers = [("Content-Type", "application/json"),
+               ("Access-Control-Allow-Credentials", "true")]
+
+    if "origin" in request.headers:
+        headers.append(("Access-Control-Allow-Origin", request.headers["origin"]))
+
+    values = []
+    for key in request.cookies:
+        for value in request.cookies.get_list(key):
+            values.append("\"%s\": \"%s\"" % (key, value))
+    body = "{ %s }" % ",".join(values)
+    return headers, body

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/helpers.py (0 => 253312)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/helpers.py	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/helpers.py	2019-12-10 01:48:58 UTC (rev 253312)
@@ -0,0 +1,55 @@
+import urlparse
+
+def setNoCacheAndCORSHeaders(request, response):
+    """Set Cache-Control, CORS and Content-Type headers appropriate for the cookie tests."""
+    headers = [("Content-Type", "application/json"),
+               ("Access-Control-Allow-Credentials", "true")]
+
+    origin = "*"
+    if "origin" in request.headers:
+        origin = request.headers["origin"]
+
+    headers.append(("Access-Control-Allow-Origin", origin))
+    #headers.append(("Access-Control-Allow-Credentials", "true"))
+    headers.append(("Cache-Control", "no-cache"))
+    headers.append(("Expires", "Fri, 01 Jan 1990 00:00:00 GMT"))
+
+    return headers
+
+def makeCookieHeader(name, value, otherAttrs):
+    """Make a Set-Cookie header for a cookie with the name, value and attributes provided."""
+    def makeAV(a, v):
+        if None == v or "" == v:
+            return a
+        return "%s=%s" % (a, v)
+
+    # ensure cookie name is always first
+    attrs = ["%s=%s" % (name, value)]
+    attrs.extend(makeAV(a, v) for (a,v) in otherAttrs.iteritems())
+    return ("Set-Cookie", "; ".join(attrs))
+
+def makeDropCookie(name, secure):
+    attrs = {"MaxAge": 0, "path": "/"}
+    if secure:
+        attrs["secure"] = ""
+    return makeCookieHeader(name, "", attrs)
+
+def readParameter(request, paramName, requireValue):
+    """Read a parameter from the request. Raise if requireValue is set and the
+    parameter has an empty value or is not present."""
+    params = urlparse.parse_qs(request.url_parts.query)
+    param = params[paramName][0].strip()
+    if len(param) == 0:
+        raise Exception("Empty or missing name parameter.")
+    return param
+
+def readCookies(request):
+    """Read the cookies from the client present in the request."""
+    cookies = {}
+    for key in request.cookies:
+        for cookie in request.cookies.get_list(key):
+            # do we care we'll clobber cookies here? If so, do we
+            # need to modify the test to take cookie names and value lists?
+            cookies[key] = cookie.value
+    return cookies
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/imgIfMatch.py (0 => 253312)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/imgIfMatch.py	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/imgIfMatch.py	2019-12-10 01:48:58 UTC (rev 253312)
@@ -0,0 +1,16 @@
+import helpers
+
+def main(request, response):
+    """Respond to `/cookie/imgIfMatch?name={name}&value={value}` with a 404 if
+       the cookie isn't present, and a transparent GIF otherwise."""
+    headers = helpers.setNoCacheAndCORSHeaders(request, response)
+    name = helpers.readParameter(request, paramName="name", requireValue=True)
+    value = helpers.readParameter(request, paramName="value", requireValue=True)
+    cookiesWithMatchingNames = request.cookies.get_list(name)
+    for cookie in cookiesWithMatchingNames:
+        if cookie.value == value:
+            # From https://github.com/mathiasbynens/small/blob/master/gif-transparent.gif
+            headers.append(("Content-Type","image/gif"))
+            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"
+            return headers, gif
+    return 500, headers, '{"error": {"message": "The cookie\'s value did not match the given value."}}'

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/list.py (0 => 253312)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/list.py	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/list.py	2019-12-10 01:48:58 UTC (rev 253312)
@@ -0,0 +1,7 @@
+import json
+import helpers
+
+def main(request, response):
+    headers = helpers.setNoCacheAndCORSHeaders(request, response)
+    cookies = helpers.readCookies(request)
+    return headers, json.dumps(cookies)

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/postToParent.py (0 => 253312)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/postToParent.py	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/postToParent.py	2019-12-10 01:48:58 UTC (rev 253312)
@@ -0,0 +1,27 @@
+import json
+import helpers
+
+def main(request, response):
+    headers = helpers.setNoCacheAndCORSHeaders(request, response)
+    cookies = helpers.readCookies(request)
+    headers.append(("Content-Type", "text/html; charset=utf-8"))
+
+    tmpl = """
+<!DOCTYPE html>
+<script>
+  var data = ""
+
+  if (window.parent != window)
+    window.parent.postMessage(data, "*");
+
+  if (window.opener)
+    window.opener.postMessage(data, "*");
+
+  window.addEventListener("message", e => {
+    console.log(e);
+    if (e.data == "reload")
+      window.location.reload();
+  });
+</script>
+"""
+    return headers, tmpl % json.dumps(cookies)

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/redirectWithCORSHeaders.py (0 => 253312)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/redirectWithCORSHeaders.py	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/redirectWithCORSHeaders.py	2019-12-10 01:48:58 UTC (rev 253312)
@@ -0,0 +1,22 @@
+from helpers import setNoCacheAndCORSHeaders
+
+def main(request, response):
+    """Simple handler that causes redirection.
+
+    The request should typically have two query parameters:
+    status - The status to use for the redirection. Defaults to 302.
+    location - The resource to redirect to.
+    """
+    status = 302
+    if "status" in request.GET:
+        try:
+            status = int(request.GET.first("status"))
+        except ValueError:
+            pass
+    headers = setNoCacheAndCORSHeaders(request, response)
+
+    location = request.GET.first("location")
+
+    headers.append(("Location", location))
+
+    return status, headers, ""

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/set-cookie.py (0 => 253312)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/set-cookie.py	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/set-cookie.py	2019-12-10 01:48:58 UTC (rev 253312)
@@ -0,0 +1,29 @@
+
+import sys
+import urlparse
+
+def main(request, response):
+    """
+    Returns cookie name and path from query params in a Set-Cookie header.
+
+    e.g.
+
+    > GET /cookies/resources/set-cookie.py?name=match-slash&path=%2F HTTP/1.1
+    > Host: localhost:8000
+    > User-Agent: curl/7.43.0
+    > Accept: */*
+    >
+    < HTTP/1.1 200 OK
+    < Content-Type: application/json
+    < Set-Cookie: match-slash=1; Path=/; Expires=Wed, 09 Jun 2021 10:18:14 GMT
+    < Server: BaseHTTP/0.3 Python/2.7.12
+    < Date: Tue, 04 Oct 2016 18:16:06 GMT
+    < Content-Length: 80
+    """
+    params = urlparse.parse_qs(request.url_parts.query)
+    headers = [
+        ("Content-Type", "application/json"),
+        ("Set-Cookie", "{name[0]}=1; Path={path[0]}; Expires=Wed, 09 Jun 2021 10:18:14 GMT".format(**params))
+    ]
+    body = "{}"
+    return headers, body

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/set.py (0 => 253312)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/set.py	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/set.py	2019-12-10 01:48:58 UTC (rev 253312)
@@ -0,0 +1,7 @@
+import helpers
+
+def main(request, response):
+    """Respond to `/cookie/set?{cookie}` by echoing `{cookie}` as a `Set-Cookie` header."""
+    headers = helpers.setNoCacheAndCORSHeaders(request, response)
+    headers.append(("Set-Cookie", request.url_parts.query))
+    return headers, '{"success": true}'

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/setSameSite.py (0 => 253312)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/setSameSite.py	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/setSameSite.py	2019-12-10 01:48:58 UTC (rev 253312)
@@ -0,0 +1,14 @@
+from helpers import makeCookieHeader, readParameter, setNoCacheAndCORSHeaders
+
+def main(request, response):
+    """Respond to `/cookie/set/samesite?{value}` by setting three cookies:
+    1. `samesite_strict={value};SameSite=Strict;path=/`
+    2. `samesite_lax={value};SameSite=Lax;path=/`
+    3. `samesite_none={value};path=/`"""
+    headers = setNoCacheAndCORSHeaders(request, response)
+    value = request.url_parts.query
+
+    headers.append(makeCookieHeader("samesite_strict", value, {"SameSite":"Strict","path":"/"}))
+    headers.append(makeCookieHeader("samesite_lax", value, {"SameSite":"Lax","path":"/"}))
+    headers.append(makeCookieHeader("samesite_none", value, {"path":"/"}))
+    return headers, '{"success": true}'

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/setSecure.py (0 => 253312)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/setSecure.py	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/setSecure.py	2019-12-10 01:48:58 UTC (rev 253312)
@@ -0,0 +1,12 @@
+from helpers import makeCookieHeader, readParameter, setNoCacheAndCORSHeaders
+
+def main(request, response):
+    """Respond to `/cookie/set/secure?{value}` by setting two cookies:
+    alone_secure={value};secure;path=/`
+    alone_insecure={value};path=/"""
+    headers = setNoCacheAndCORSHeaders(request, response)
+    value = request.url_parts.query
+
+    headers.append(makeCookieHeader("alone_secure", value, {"secure": "","path": "/"}))
+    headers.append(makeCookieHeader("alone_insecure", value, {"path": "/"}))
+    return headers, '{"success": true}'

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/testharness-helpers.js (0 => 253312)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/testharness-helpers.js	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/resources/testharness-helpers.js	2019-12-10 01:48:58 UTC (rev 253312)
@@ -0,0 +1,49 @@
+// Given an array of potentially asynchronous tests, this function will execute
+// each in serial, ensuring that one and only one test is executing at a time.
+//
+// The test array should look like this:
+//
+//
+//     var tests = [
+//       [
+//         "Test description goes here.",
+//         function () {
+//           // Test code goes here. `this` is bound to the test object.
+//         }
+//       ],
+//       ...
+//     ];
+//
+// The |setup| and |teardown| arguments are functions which are executed before
+// and after each test, respectively.
+function executeTestsSerially(testList, setup, teardown) {
+  var tests = testList.map(function (t) {
+    return {
+      test: async_test(t[0]),
+      code: t[1]
+    };
+  });
+
+  var executeNextTest = function () {
+    var current = tests.shift();
+    if (current === undefined) {
+      return;
+    }
+
+    // Setup the test fixtures.
+    if (setup) {
+      setup();
+    }
+
+    // Bind a callback to tear down the test fixtures.
+    if (teardown) {
+      current.test.add_cleanup(teardown);
+    }
+
+    // Execute the test.
+    current.test.step(current.code);
+  };
+
+  add_result_callback(function () { setTimeout(executeNextTest, 0) });
+  executeNextTest();
+}

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-dom.https.sub-expected.txt (0 => 253312)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-dom.https.sub-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-dom.https.sub-expected.txt	2019-12-10 01:48:58 UTC (rev 253312)
@@ -0,0 +1,4 @@
+
+PASS 'secure' cookie visible in `document.cookie` 
+PASS 'secure' cookie visible in HTTP request 
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-dom.https.sub.html (0 => 253312)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-dom.https.sub.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-dom.https.sub.html	2019-12-10 01:48:58 UTC (rev 253312)
@@ -0,0 +1,47 @@
+<!doctype html>
+<html>
+<head>
+  <meta charset=utf-8>
+  <title>Set 'secure' cookie from `document.cookie` on a secure page</title>
+  <meta name=help href=""
+  <script src=""
+  <script src=""
+  <script src=""
+</head>
+<body>
+<div id=log></div>
+<script>
+  var tests = [
+    [
+      "'secure' cookie visible in `document.cookie`",
+      function () {
+        document.cookie = "secure_from_secure_dom=1; secure; path=/";
+        assert_not_equals(document.cookie.match(/secure_from_secure_dom=1/), null);
+        this.done();
+      }
+    ],
+    [
+      "'secure' cookie visible in HTTP request",
+      function () {
+        document.cookie = "secure_from_secure_dom=1; secure; path=/";
+        assert_not_equals(document.cookie.match(/secure_from_secure_dom=1/), null);
+        fetch("https://{{host}}:{{ports[https][0]}}/cookies/resources/echo-json.py",
+              { "credentials": "include" })
+          .then(this.step_func(function (r) {
+            return r.json();
+          }))
+          .then(this.step_func_done(function (j) {
+            assert_equals(j["secure_from_secure_dom"], "secure_from_secure_dom=1");
+          }));
+      }
+    ]
+  ];
+
+  function clearKnownCookie() {
+    document.cookie = "secure_from_secure_dom=0; Secure; expires=Thu, 01 Jan 1970 00:00:01 GMT; path=/";
+  }
+
+  executeTestsSerially(tests, clearKnownCookie, clearKnownCookie);
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-dom.sub-expected.txt (0 => 253312)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-dom.sub-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-dom.sub-expected.txt	2019-12-10 01:48:58 UTC (rev 253312)
@@ -0,0 +1,4 @@
+
+PASS 'secure' cookie not set in `document.cookie` 
+PASS 'secure' cookie not sent in HTTP request 
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-dom.sub.html (0 => 253312)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-dom.sub.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-dom.sub.html	2019-12-10 01:48:58 UTC (rev 253312)
@@ -0,0 +1,47 @@
+<!doctype html>
+<html>
+<head>
+  <meta charset=utf-8>
+  <title>Set 'secure' cookie from `document.cookie` on a non-secure page</title>
+  <meta name=help href=""
+  <script src=""
+  <script src=""
+  <script src=""
+</head>
+<body>
+<div id=log></div>
+<script>
+  var tests = [
+    [
+      "'secure' cookie not set in `document.cookie`",
+      function () {
+        var originalCookie = document.cookie;
+        document.cookie = "secure_from_nonsecure_dom=1; secure; path=/";
+        assert_equals(document.cookie, originalCookie);
+        this.done();
+      }
+    ],
+    [
+      "'secure' cookie not sent in HTTP request",
+      function () {
+        document.cookie = "secure_from_nonsecure_dom=1; secure; path=/";
+        fetch("https://{{host}}:{{ports[https][0]}}/cookies/resources/echo-json.py", { "credentials": "include" })
+          .then(this.step_func(function (r) {
+              return r.json();
+          }))
+          .then(this.step_func_done(function (j) {
+              assert_equals(j["secure_from_nonsecure_dom"], undefined);
+          }));
+      }
+    ]
+  ];
+
+  function clearKnownCookie() {
+    document.cookie = "secure_from_nonsecure_dom=0; Secure; expires=Thu, 01 Jan 1970 00:00:01 GMT; path=/";
+  }
+
+  executeTestsSerially(tests, clearKnownCookie, clearKnownCookie);
+</script>
+</body>
+</html>
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-http.https.sub-expected.txt (0 => 253312)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-http.https.sub-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-http.https.sub-expected.txt	2019-12-10 01:48:58 UTC (rev 253312)
@@ -0,0 +1,4 @@
+
+PASS 'secure' cookie present in `document.cookie` 
+PASS 'secure' cookie sent in HTTP request 
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-http.https.sub.html (0 => 253312)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-http.https.sub.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-http.https.sub.html	2019-12-10 01:48:58 UTC (rev 253312)
@@ -0,0 +1,36 @@
+<!doctype html>
+<html>
+<head>
+  <meta charset=utf-8>
+  <title>Set 'secure' cookie from `Set-Cookie` HTTP header on a secure page</title>
+  <meta name=help href=""
+  <script src=""
+  <script src=""
+  <script src=""
+</head>
+<body>
+<div id=log></div>
+<script>
+  function clearKnownCookie() {
+    document.cookie = "secure_from_secure_http=0; Secure; expires=Thu, 01 Jan 1970 00:00:01 GMT; path=/";
+  }
+
+  test(function () {
+    assert_not_equals(document.cookie.match(/secure_from_secure_http=1/), null);
+  }, "'secure' cookie present in `document.cookie`");
+
+  promise_test(function (t) {
+    t.add_cleanup(clearKnownCookie);
+    return fetch("https://{{host}}:{{ports[https][0]}}/cookies/resources/echo-json.py",
+                 { "credentials": "include" })
+      .then(function (r) {
+        return r.json();
+      })
+      .then(function (j) {
+        assert_equals(j["secure_from_secure_http"], "secure_from_secure_http=1");
+      });
+  }, "'secure' cookie sent in HTTP request");
+</script>
+</body>
+</html>
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-http.https.sub.html.headers (0 => 253312)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-http.https.sub.html.headers	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-http.https.sub.html.headers	2019-12-10 01:48:58 UTC (rev 253312)
@@ -0,0 +1,5 @@
+Expires: Mon, 26 Jul 1997 05:00:00 GMT
+Cache-Control: no-store, no-cache, must-revalidate
+Cache-Control: post-check=0, pre-check=0, false
+Pragma: no-cache
+Set-Cookie: secure_from_secure_http=1; Secure; Path=/

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-http.sub-expected.txt (0 => 253312)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-http.sub-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-http.sub-expected.txt	2019-12-10 01:48:58 UTC (rev 253312)
@@ -0,0 +1,4 @@
+
+PASS 'secure' cookie not present in `document.cookie` 
+PASS 'secure' cookie not sent in HTTP request 
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-http.sub.html (0 => 253312)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-http.sub.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-http.sub.html	2019-12-10 01:48:58 UTC (rev 253312)
@@ -0,0 +1,36 @@
+<!doctype html>
+<html>
+<head>
+  <meta charset=utf-8>
+  <title>Set 'secure' cookie from `Set-Cookie` HTTP header on a non-secure page</title>
+  <meta name=help href=""
+  <script src=""
+  <script src=""
+  <script src=""
+</head>
+<body>
+<div id=log></div>
+<script>
+  function clearKnownCookie() {
+    document.cookie = "secure_from_nonsecure_http=0; Secure; expires=Thu, 01 Jan 1970 00:00:01 GMT; path=/";
+  }
+
+  test(function () {
+    assert_equals(document.cookie.match(/secure_from_nonsecure_http=1/), null);
+  }, "'secure' cookie not present in `document.cookie`");
+
+  promise_test(function (t) {
+    t.add_cleanup(clearKnownCookie);
+    return fetch("https://{{host}}:{{ports[https][0]}}/cookies/resources/echo-json.py",
+                 { "credentials": "include" })
+      .then(function (r) {
+        return r.json();
+      })
+      .then(function (j) {
+        assert_equals(j["secure_from_nonsecure_http"], undefined);
+      });
+  }, "'secure' cookie not sent in HTTP request");
+</script>
+</body>
+</html>
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-http.sub.html.headers (0 => 253312)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-http.sub.html.headers	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-http.sub.html.headers	2019-12-10 01:48:58 UTC (rev 253312)
@@ -0,0 +1,5 @@
+Expires: Mon, 26 Jul 1997 05:00:00 GMT
+Cache-Control: no-store, no-cache, must-revalidate
+Cache-Control: post-check=0, pre-check=0, false
+Pragma: no-cache
+Set-Cookie: secure_from_nonsecure_http=1; Secure; Path=/

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-ws.sub-expected.txt (0 => 253312)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-ws.sub-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-ws.sub-expected.txt	2019-12-10 01:48:58 UTC (rev 253312)
@@ -0,0 +1,3 @@
+
+PASS 'secure' cookie not sent in WSS request when set from WS 
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-ws.sub.html (0 => 253312)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-ws.sub.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-ws.sub.html	2019-12-10 01:48:58 UTC (rev 253312)
@@ -0,0 +1,45 @@
+<!doctype html>
+<html>
+<head>
+  <meta charset=utf-8>
+  <title>Set 'secure' cookie from `Set-Cookie` HTTP header on a non-secure WebSocket</title>
+  <meta name=help href=""
+  <script src=""
+  <script src=""
+  <script src=""
+</head>
+<body>
+<div id=log></div>
+<script>
+  function clearKnownCookie() {
+    document.cookie = "ws_test_secure_from_nonsecure=0; Secure; expires=Thu, 01 Jan 1970 00:00:01 GMT; path=/";
+  }
+
+  async_test(function (t) {
+    t.add_cleanup(clearKnownCookie);
+    assert_equals(document.cookie.match(/ws_test_secure_from_nonsecure=/), null);
+
+    clearKnownCookie();
+    var ws = new WebSocket("ws://{{host}}:{{ports[ws][0]}}/set-cookie-secure?secure_from_nonsecure");
+    ws._onclose_ = t.step_func_done(function () {
+      assert_unreached("'close' should not fire before 'open'.");
+    });
+    ws._onopen_ = t.step_func(function (e) {
+      ws._onclose_ = null;
+      ws.close();
+      assert_false(/ws_test_secure_from_nonsecure=test/.test(document.cookie));
+
+      var ws2 = new WebSocket("wss://{{host}}:{{ports[wss][0]}}/echo-cookie");
+      ws2._onclose_ = t.step_func_done(function () {
+        assert_unreached("'close' should not fire before 'open'.");
+      });
+      ws2._onmessage_ = t.step_func_done(function (e) {
+        ws2._onclose_ = null;
+        ws2.close();
+        assert_false(/ws_test_secure_from_nonsecure=test/.test(e.data));
+      });
+    });
+  }, "'secure' cookie not sent in WSS request when set from WS");
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-wss.https.sub-expected.txt (0 => 253312)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-wss.https.sub-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-wss.https.sub-expected.txt	2019-12-10 01:48:58 UTC (rev 253312)
@@ -0,0 +1,3 @@
+
+PASS 'secure' cookie not sent in HTTP request 
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-wss.https.sub.html (0 => 253312)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-wss.https.sub.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/cookies/secure/set-from-wss.https.sub.html	2019-12-10 01:48:58 UTC (rev 253312)
@@ -0,0 +1,44 @@
+<!doctype html>
+<html>
+<head>
+  <meta charset=utf-8>
+  <title>Set 'secure' cookie from `Set-Cookie` HTTP header on a secure WebSocket</title>
+  <meta name=help href=""
+  <script src=""
+  <script src=""
+  <script src=""
+</head>
+<body>
+<div id=log></div>
+<script>
+  function clearKnownCookie() {
+    document.cookie = "ws_test_secure_from_secure=0; Secure; expires=Thu, 01 Jan 1970 00:00:01 GMT; path=/";
+  }
+
+  async_test(function (t) {
+    t.add_cleanup(clearKnownCookie);
+    assert_equals(document.cookie.match(/ws_test_secure_from_secure=/), null);
+
+    clearKnownCookie();
+    var ws = new WebSocket("wss://{{host}}:{{ports[wss][0]}}/set-cookie-secure?secure_from_secure");
+    ws._onclose_ = t.step_func_done(function () {
+      assert_unreached("'close' should not fire before 'open'.");
+    });
+    ws._onopen_ = t.step_func(function (e) {
+      ws._onclose_ = null;
+      ws.close();
+      assert_regexp_match(document.cookie, /ws_test_secure_from_secure=test/);
+      var ws2 = new WebSocket("wss://{{host}}:{{ports[wss][0]}}/echo-cookie");
+      ws2._onclose_ = t.step_func_done(function () {
+        assert_unreached("'close' should not fire before 'open'.");
+      });
+      ws2._onmessage_ = t.step_func_done(function (e) {
+        ws2._onclose_ = null;
+        ws2.close();
+        assert_regexp_match(e.data, /ws_test_secure_from_secure=test/);
+      });
+    });
+  }, "'secure' cookie not sent in HTTP request");
+</script>
+</body>
+</html>

Modified: trunk/LayoutTests/platform/gtk/TestExpectations (253311 => 253312)


--- trunk/LayoutTests/platform/gtk/TestExpectations	2019-12-10 01:12:02 UTC (rev 253311)
+++ trunk/LayoutTests/platform/gtk/TestExpectations	2019-12-10 01:48:58 UTC (rev 253312)
@@ -3954,6 +3954,8 @@
 webkit.org/b/204675 imported/w3c/web-platform-tests/offscreen-canvas/the-offscreen-canvas/initial.reset.pattern.worker.html [ Failure ]
 webkit.org/b/204675 imported/w3c/web-platform-tests/offscreen-canvas/filter/offscreencanvas.filter.w.html [ Missing ]
 
+webkit.org/b/169356 imported/w3c/web-platform-tests/cookies/secure/set-from-dom.sub.html [ Failure ]
+
 #////////////////////////////////////////////////////////////////////////////////////////
 # End of non-crashing, non-flaky tests failing
 #////////////////////////////////////////////////////////////////////////////////////////

Copied: trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/content-security-policy/reporting/report-same-origin-with-cookies-expected.txt (from rev 253311, trunk/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/reporting/report-same-origin-with-cookies-expected.txt) (0 => 253312)


--- trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/content-security-policy/reporting/report-same-origin-with-cookies-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/content-security-policy/reporting/report-same-origin-with-cookies-expected.txt	2019-12-10 01:48:58 UTC (rev 253312)
@@ -0,0 +1,6 @@
+
+
+PASS Image should not load 
+PASS Violation report status OK. 
+FAIL Test report cookies. assert_true: Report should contain cookie: cspViolationReportCookie2 expected true got false
+

Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (253311 => 253312)


--- trunk/LayoutTests/platform/mac-wk1/TestExpectations	2019-12-10 01:12:02 UTC (rev 253311)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations	2019-12-10 01:48:58 UTC (rev 253312)
@@ -395,6 +395,10 @@
 # So we shouldn't bother with this test in WebKit1.
 storage/indexeddb/modern/exceed-open-file-limit.html
 
+# Only fails in WK1
+imported/w3c/web-platform-tests/cookies/secure/set-from-wss.https.sub.html [ Failure ]
+imported/w3c/web-platform-tests/cookies/secure/set-from-ws.sub.html [ Failure ]
+
 ### END OF (2) Failures without bug reports
 ########################################
 

Modified: trunk/LayoutTests/platform/wpe/TestExpectations (253311 => 253312)


--- trunk/LayoutTests/platform/wpe/TestExpectations	2019-12-10 01:12:02 UTC (rev 253311)
+++ trunk/LayoutTests/platform/wpe/TestExpectations	2019-12-10 01:48:58 UTC (rev 253312)
@@ -498,6 +498,8 @@
 webkit.org/b/200165 imported/w3c/web-platform-tests/websockets/cookies/007.html [ Failure ]
 webkit.org/b/200165 imported/w3c/web-platform-tests/websockets/cookies/004.html [ Failure ]
 
+webkit.org/b/169356 imported/w3c/web-platform-tests/cookies/secure/set-from-dom.sub.html [ Failure ]
+
 #////////////////////////////////////////////////////////////////////////////////////////
 # 3. UNRESOLVED TESTS
 #////////////////////////////////////////////////////////////////////////////////////////
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to