Reland "Port XHR access-control LayoutTests to Web Platform Tests"

This is a reland of a03f32888a033a56d15b552f888bad33f5a71ae5.
In the original CL, wpt-exporter merged the provisional PR on GitHub
prematurely at patchset 3, even though the CL had not landed.
The final checked-in patchset 12 was therefore not exported, and the
change between PS3 and PS12 was eventually clobbered by the importer:
https://chromium.googlesource.com/chromium/src/+log/master/third_party/WebKit/LayoutTests/external/wpt/XMLHttpRequest/allow-lists-starting-with-comma.htm

Original change's description:
> Port XHR access-control LayoutTests to Web Platform Tests
>
> Porting access-control-allow-lists-starting-with-comma.html
> from LayoutTests to Web Platform Tests
>
> Bug: 745385
> Change-Id: I035fe6b26463ff9e2bcf70af2be80464849766d4
> Reviewed-on: https://chromium-review.googlesource.com/571249
> Commit-Queue: Austin James Ahlstrom <aahlstrom@google.com>
> Reviewed-by: Takeshi Yoshino <tyoshino@chromium.org>
> Reviewed-by: Yutaka Hirano <yhirano@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#489850}

Bug: 754619, 745385
Change-Id: I5dfdb8c9ccb4fe4fcae94c237eaee3196103e7f8
Reviewed-on: https://chromium-review.googlesource.com/648046
Reviewed-by: Quinten Yearsley <qyearsley@chromium.org>
Commit-Queue: Robert Ma <robertma@chromium.org>
Cr-Commit-Position: refs/heads/master@{#499302}
diff --git a/XMLHttpRequest/allow-lists-starting-with-comma.htm b/XMLHttpRequest/allow-lists-starting-with-comma.htm
index 03cc7cb..4a4e5e2 100644
--- a/XMLHttpRequest/allow-lists-starting-with-comma.htm
+++ b/XMLHttpRequest/allow-lists-starting-with-comma.htm
@@ -4,30 +4,30 @@
     <title>Allow lists starting with a comma should be parsed correctly</title>
     <script src="/resources/testharness.js"></script>
     <script src="/resources/testharnessreport.js"></script>
+    <script src="/common/get-host-info.sub.js"></script>
   </head>
   <body>
   <script type="text/javascript">
-    var test = async_test();
-
-    test.step(function() {
-      var xhr = new XMLHttpRequest();
-      var url = "resources/access-control-allow-lists.py?headers=,y-lol,x-print,%20,,,y-print&origin=http://127.0.0.1:8000";
-      xhr.open("GET", url, false);
-      xhr.setRequestHeader('x-print', 'unicorn')
-      xhr.setRequestHeader('y-print', 'narwhal')
+    async_test(function(test) {
+      const client = new XMLHttpRequest();
+      let url = "XMLHttpRequest/resources/access-control-allow-lists.py?headers=,y-lol,x-print,%20,,,y-print&origin=" +
+          get_host_info().HTTP_ORIGIN;
+      client.open("GET", get_host_info().HTTP_REMOTE_ORIGIN + '/' + url, false);
+      client.setRequestHeader('x-print', 'unicorn')
+      client.setRequestHeader('y-print', 'narwhal')
       // Sending GET request with custom headers
-      assert_equals(xhr.send(null), undefined);
-      var response = JSON.parse(xhr.response);
+      assert_equals(client.send(null), undefined);
+      const response = JSON.parse(client.response);
       assert_equals(response['x-print'], "unicorn");
       assert_equals(response['y-print'], "narwhal");
 
-      url = "resources/access-control-allow-lists.py?methods=,,PUT,GET&origin=http://127.0.0.1:8000";
-      xhr.open("PUT", url, false);
+      url = "XMLHttpRequest/resources/access-control-allow-lists.py?methods=,,PUT,GET&origin=" +
+          get_host_info().HTTP_ORIGIN;
+      client.open("PUT", get_host_info().HTTP_REMOTE_ORIGIN + '/' + url, false);
       // Sending PUT request
-      assert_equals(xhr.send(null), undefined);
+      assert_equals(client.send(null), undefined);
       test.done();
-    });
+    }, "Allow lists starting with a comma should be parsed correctly");
   </script>
   </body>
   </html>
-
diff --git a/XMLHttpRequest/resources/access-control-allow-lists.py b/XMLHttpRequest/resources/access-control-allow-lists.py
index c020cd2..526d365 100644
--- a/XMLHttpRequest/resources/access-control-allow-lists.py
+++ b/XMLHttpRequest/resources/access-control-allow-lists.py
@@ -8,15 +8,13 @@
             response.headers.set("Access-Control-Allow-Origin", request.GET["origin"])
 
     if "headers" in request.GET:
-        response.headers.set("Access-Control-Allow-Headers", '{'+request.GET["headers"]+'}')
+        response.headers.set("Access-Control-Allow-Headers", request.GET["headers"])
     if "methods" in request.GET:
-        response.headers.set("Access-Control-Allow-Methods", '{'+request.GET["methods"]+'}')
+        response.headers.set("Access-Control-Allow-Methods", request.GET["methods"])
 
     headers = dict(request.headers)
 
     for header in headers:
         headers[header] = headers[header][0]
 
-    headers["get_value"] = "" if "get_value" not in request.GET else request.GET["get_value"]
-
     return json.dumps(headers)